Skip to content

PHPC-2384, PHPC-2399, PHPC-2400: Publish SSDLC assets on release #1584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 13, 2024

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Jun 13, 2024

This PR fixes the following issues:

In order to have all resources available when we publish SSDLC assets, it is necessary to run the static analysis and release packaging workflows as part of the release workflow. Through this we can ensure that up-to-date code scanning results are available for export, and that we can fetch all generated files to add them to the authorised publication document.

Along with the necessary changes to publish all assets, I've also made a couple of improvements related to the release process:

  • The token generation and checkout now uses the secure-checkout action from drivers-github-tools
  • Creating version bump commits and the release tag are also handled through actions from drivers-github-tools
  • The changelog added to package.xml is no longer read from the tag, but rather generated using the GitHub API from the existing tag. This cleans up the tag message in the process
  • Windows packages are now built in a reusable workflow that is called as part of a matrix. The advantage is that signing and attaching a Windows build will now no longer wait until all builds have completed, but only until that particular build is done. This should make better use of available action runners
  • Build artifacts are no longer uploaded to save on space

For a sample workflow run, see this example in my fork. Note that I've only built Windows packages for a single version to reduce resource usage.

@alcaeus alcaeus requested a review from jmikola June 13, 2024 10:48
@alcaeus alcaeus force-pushed the publish-ssdlc-assets-on-release branch from d36da66 to 03dbe44 Compare June 13, 2024 10:49
@@ -41,7 +41,7 @@ runs:
- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
arch: ${{ inputs.arch }}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This happened to "just work" before, but broke down once the action was used in a job that didn't use the matrix strategy. Took me longer to figure out than I care to admit...

@@ -140,7 +140,8 @@ function get_next_minor_version(array $versions): array
];
}

if ($argc !== 2) {
// Allow 2 arguments as the bump-version action always passes a version number, even when not needed
if (! in_array($argc, [2, 3])) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version bump script always passes the version number as an argument, so I decided to allow an additional argument without using it.

@alcaeus alcaeus changed the base branch from master to v1.19 June 13, 2024 11:13
@alcaeus alcaeus changed the title PHPC-2384, PHPC-2399, PHPC-2340: Publish SSDLC assets on publish PHPC-2384, PHPC-2399, PHPC-2340: Publish SSDLC assets on release Jun 13, 2024
@alcaeus alcaeus changed the title PHPC-2384, PHPC-2399, PHPC-2340: Publish SSDLC assets on release PHPC-2384, PHPC-2399, PHPC-2400: Publish SSDLC assets on release Jun 13, 2024
Copy link
Member

@jmikola jmikola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions and one optional suggestion.

arch: ${{ matrix.arch }}
ts: ${{ matrix.ts }}
upload_release_asset: true
secrets: inherit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- name: "Upload release artifacts"
run: gh release upload ${{ github.ref_name }} ${{ env.PACKAGE_FILE }} ${{ env.PACKAGE_FILE }}.sig
continue-on-error: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the removal of continue-on-error: true intentional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was. I put it there initially because any tag build would trigger the package workflow, regardless of whether there was a GitHub release to go with it. With the change, the package workflow is only triggered from the release workflow, so if the upload fails we want to be alerted instead of the workflow run passing as if nothing went wrong.

# Use get-version as a dummy as a version_bump_script is required
# We run the bump script manually earlier so we can sanity-check the version number and print nice output
version_bump_script: "./bin/update-release-version.php get-version"
commit_template: 'Package ${VERSION}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noted that bump-version/action.yml uses envsubst. Does that guarantee that we won't get any unexpected substitutions on the following line when COMMIT_MESSAGE=$COMMIT_MESSAGE is run?

I realize this is unlikely given the values we'd use for commit_template.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll bring this up with @blink1073, but I don't think so.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand it, it is only substituting what you have in the commit template, so VERSION in this case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I was misunderstanding and thought that the COMMIT_MESSAGE= line might inadvertently perform another substitution if a $VAR string remained after envsubst (e.g. malformed $VERSION value).

But it's clear that $COMMIT_MESSAGE is the only substitution happening there. And that line is the standard snippet to append to the GitHub environment. Sorry for the noise.


- name: "Set summary"
run: |
echo '🚀 Created tag and drafted release for version [${{ inputs.version }}](${{ env.RELEASE_URL }})' >> $GITHUB_STEP_SUMMARY
echo '✍️ You may now update the release notes and publish the release when ready' >> $GITHUB_STEP_SUMMARY

static-analysis:
needs: prepare-release
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted that jobs.<job_id>.needs accepts either a string or array. I was confused at first because you used an array for a single value in build-windows-package.yml.

- name: "Upload SBOM as release artifact"
run: gh release upload ${{ inputs.version }} ${{ env.S3_ASSETS }}/cyclonedx.sbom.json
# Silk currently errors out when downloading the SBOM. Don't let this fail the entire build
continue-on-error: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted this is also in place for "Download SBOM file from Silk".

Is this expected to be permanent to make the release process resilient to Silk outages?

Copy link
Member Author

@alcaeus alcaeus Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, although I've only added it here since the inventory asset group for PHPC didn't have an SBOM Lite file associated with it. It works now but forgot to remove this.
Edit: this is removed now.

@alcaeus alcaeus enabled auto-merge (squash) June 13, 2024 15:18
@alcaeus alcaeus merged commit 9f0789f into mongodb:v1.19 Jun 13, 2024
53 checks passed
@alcaeus alcaeus deleted the publish-ssdlc-assets-on-release branch June 13, 2024 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants