-
Notifications
You must be signed in to change notification settings - Fork 266
PHPLIB-1434: Publish SSDLC assets upon release #1342
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,7 +93,6 @@ jobs: | |
aws_region_name: ${{ vars.AWS_REGION_NAME }} | ||
aws_secret_id: ${{ secrets.AWS_SECRET_ID }} | ||
|
||
# Create a draft release with release message filled in | ||
- name: "Prepare release message" | ||
run: | | ||
cat > release-message <<'EOL' | ||
|
@@ -103,7 +102,6 @@ jobs: | |
- name: "Create draft release" | ||
run: echo "RELEASE_URL=$(gh release create ${{ inputs.version }} --target ${{ github.ref_name }} --title "${{ inputs.version }}" --notes-file release-message --draft)" >> "$GITHUB_ENV" | ||
|
||
# This step creates the signed release tag | ||
- name: "Create release tag" | ||
uses: mongodb-labs/drivers-github-tools/git-sign@v2 | ||
with: | ||
|
@@ -119,11 +117,89 @@ jobs: | |
- name: "Push changes from release branch" | ||
run: git push | ||
|
||
# Pushing the release tag starts build processes that then produce artifacts for the release | ||
- name: "Push release tag" | ||
run: git push origin ${{ inputs.version }} | ||
|
||
- 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 | ||
name: "Run Static Analysis" | ||
uses: ./.github/workflows/static-analysis.yml | ||
with: | ||
ref: refs/tags/${{ inputs.version }} | ||
permissions: | ||
security-events: write | ||
id-token: write | ||
|
||
publish-ssdlc-assets: | ||
needs: static-analysis | ||
environment: release | ||
name: "Publish SSDLC Assets" | ||
runs-on: ubuntu-latest | ||
permissions: | ||
security-events: read | ||
id-token: write | ||
contents: write | ||
|
||
steps: | ||
- name: "Create temporary app token" | ||
uses: actions/create-github-app-token@v1 | ||
id: app-token | ||
with: | ||
app-id: ${{ vars.APP_ID }} | ||
private-key: ${{ secrets.APP_PRIVATE_KEY }} | ||
|
||
- name: "Store GitHub token in environment" | ||
run: echo "GH_TOKEN=${{ steps.app-token.outputs.token }}" >> "$GITHUB_ENV" | ||
shell: bash | ||
|
||
- uses: actions/checkout@v4 | ||
with: | ||
ref: refs/tags/${{ inputs.version }} | ||
token: ${{ env.GH_TOKEN }} | ||
|
||
# Sets the S3_ASSETS environment variable used later | ||
- name: "Set up drivers-github-tools" | ||
uses: mongodb-labs/drivers-github-tools/setup@v2 | ||
with: | ||
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }} | ||
aws_region_name: ${{ vars.AWS_REGION_NAME }} | ||
aws_secret_id: ${{ secrets.AWS_SECRET_ID }} | ||
|
||
- name: "Generate authorized publication document" | ||
uses: mongodb-labs/drivers-github-tools/authorized-pub@v2 | ||
with: | ||
product_name: "MongoDB PHP Driver (library)" | ||
release_version: ${{ inputs.version }} | ||
filenames: "" | ||
token: ${{ env.GH_TOKEN }} | ||
|
||
- name: "Download SBOM file from Silk" | ||
uses: mongodb-labs/drivers-github-tools/sbom@v2 | ||
with: | ||
silk_asset_group: mongodb-php-driver-library | ||
|
||
- name: "Upload SBOM as release artifact" | ||
run: gh release upload ${{ inputs.version }} ${{ env.S3_ASSETS }}/cyclonedx.sbom.json | ||
continue-on-error: true | ||
|
||
- name: "Generate SARIF report from code scanning alerts" | ||
uses: mongodb-labs/drivers-github-tools/code-scanning-export@v2 | ||
with: | ||
ref: ${{ inputs.version }} | ||
output-file: ${{ env.S3_ASSETS }}/code-scanning-alerts.json | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not clear to me where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is set by the setup action above. I'll add a comment for this |
||
|
||
- name: "Generate compliance report" | ||
uses: mongodb-labs/drivers-github-tools/compliance-report@v2 | ||
with: | ||
token: ${{ env.GH_TOKEN }} | ||
|
||
- name: Upload S3 assets | ||
uses: mongodb-labs/drivers-github-tools/upload-s3-assets@v2 | ||
with: | ||
version: ${{ inputs.version }} | ||
product_name: mongo-php-library |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,12 @@ on: | |
- "v*.*" | ||
- "master" | ||
- "feature/*" | ||
tags: | ||
- "*" | ||
workflow_call: | ||
inputs: | ||
ref: | ||
description: "The git ref to check" | ||
type: string | ||
required: true | ||
|
||
env: | ||
PHP_VERSION: "8.2" | ||
|
@@ -27,6 +31,8 @@ jobs: | |
steps: | ||
- name: "Checkout" | ||
uses: "actions/checkout@v4" | ||
with: | ||
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || github.ref }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't familiar with the syntax, but I consulted the Expressions docs to infer that it's a ternary statement and equivalent to the following:
|
||
|
||
- name: "Setup" | ||
uses: "./.github/actions/setup" | ||
|
@@ -41,20 +47,3 @@ jobs: | |
uses: "github/codeql-action/upload-sarif@v3" | ||
with: | ||
sarif_file: psalm.sarif | ||
|
||
rector: | ||
name: "Rector" | ||
runs-on: "ubuntu-22.04" | ||
|
||
steps: | ||
- name: "Checkout" | ||
uses: "actions/checkout@v4" | ||
|
||
- name: "Setup" | ||
uses: "./.github/actions/setup" | ||
with: | ||
php-version: ${{ env.PHP_VERSION }} | ||
driver-version: ${{ env.DRIVER_VERSION }} | ||
|
||
- name: "Run Rector" | ||
run: "vendor/bin/rector --ansi --dry-run" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default, I assume this would invoke all jobs in the referenced file and that's why you added a conditional on the Rector job.
I noted that this is re-using an entire workflow (
jobs.<job_id>.uses
), as opposed to an action being imported into a step (jobs.<job_id>.steps[*].uses
).I'm a bit confused about how this single
static-analysis
job would map to multiple jobs instatic-analysis.yml
if you hadn't specified a condition to exclude Rector. Would they just be run in sequence? Reusing Workflows doesn't address this, and the example therein only has a single job defined in the import file. To that end, I wonder if it'd make more sense to split the Psalm and Rector jobs into separate files (e.g.static-analysis-psalm.yml
andstatic-analysis-rector.yml
) if there isn't much commonality between them anyway.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - unlike actions that contain a set of functionality to be included in a job, this allows to reuse an entire workflow as a job in a different workflow, without sharing data with any other job.
As for what this looks like, I wasn't sure at first either but it actually looks rather nice: https://github.com/alcaeus/mongo-php-library/actions/runs/9447195881. I'll split the workflow up into separate workflows for psalm and rector.