Skip to content

Commit 426ec99

Browse files
committed
Full Pipeline for Release with SBOM
1 parent a1acf6c commit 426ec99

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed

.github/workflows/release-with-sbom.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,33 @@ jobs:
2828
contents: write
2929

3030
steps:
31+
- name: "Create release output"
32+
run: echo '🎬 Release process for version ${{ inputs.version }} started by @${{ github.triggering_actor }}' >> $GITHUB_STEP_SUMMARY
33+
34+
- name: "Generate token and checkout repository"
35+
uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
36+
with:
37+
app_id: ${{ vars.APP_ID }}
38+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
39+
40+
- name: "Store version numbers in env variables"
41+
run: |
42+
echo RELEASE_VERSION=${{ inputs.version }} >> $GITHUB_ENV
43+
echo RELEASE_BRANCH=v$(echo ${{ inputs.version }} | cut -d '.' -f-2) >> $GITHUB_ENV
44+
45+
- name: "Ensure release tag does not already exist"
46+
run: |
47+
if [[ $(git tag -l ${RELEASE_VERSION}) == ${RELEASE_VERSION} ]]; then
48+
echo '❌ Release failed: tag for version ${{ inputs.version }} already exists' >> $GITHUB_STEP_SUMMARY
49+
exit 1
50+
fi
51+
52+
- name: "Fail if branch names don't match"
53+
if: ${{ github.ref_name != env.RELEASE_BRANCH }}
54+
run: |
55+
echo '❌ Release failed due to branch mismatch: expected ${{ inputs.version }} to be released from ${{ env.RELEASE_BRANCH }}, got ${{ github.ref_name }}' >> $GITHUB_STEP_SUMMARY
56+
exit 1
57+
3158
#
3259
# Preliminary checks done - generate SBOM before tagging
3360
#
@@ -121,3 +148,93 @@ jobs:
121148
else
122149
echo "⚠️ SBOM generation skipped or failed - continuing with release" >> $GITHUB_STEP_SUMMARY
123150
fi
151+
#
152+
# Preliminary checks done - commence the release process
153+
#
154+
155+
- name: "Set up drivers-github-tools"
156+
uses: mongodb-labs/drivers-github-tools/setup@v2
157+
with:
158+
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
159+
aws_region_name: ${{ vars.AWS_REGION_NAME }}
160+
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
161+
162+
- name: "Prepare release message"
163+
run: |
164+
cat > release-message <<'EOL'
165+
${{ format(env.default-release-message, inputs.version, inputs.jira-version-number) }}
166+
EOL
167+
168+
- name: "Create draft release"
169+
run: echo "RELEASE_URL=$(gh release create ${{ inputs.version }} --target ${{ github.ref_name }} --title "${{ inputs.version }}" --notes-file release-message --draft)" >> "$GITHUB_ENV"
170+
171+
- name: "Create release tag"
172+
uses: mongodb-labs/drivers-github-tools/tag-version@v2
173+
with:
174+
version: ${{ inputs.version }}
175+
tag_message_template: 'Release ${VERSION}'
176+
177+
# TODO: Manually merge using ours strategy. This avoids merge-up pull requests being created
178+
# Process is:
179+
# 1. switch to next branch (according to merge-up action)
180+
# 2. merge release branch using --strategy=ours
181+
# 3. push next branch
182+
# 4. switch back to release branch, then push
183+
184+
- name: "Set summary"
185+
run: |
186+
echo '🚀 Created tag and drafted release for version [${{ inputs.version }}](${{ env.RELEASE_URL }})' >> $GITHUB_STEP_SUMMARY
187+
echo '✍️ You may now update the release notes and publish the release when ready' >> $GITHUB_STEP_SUMMARY
188+
189+
static-analysis:
190+
needs: prepare-release
191+
name: "Run Static Analysis"
192+
uses: ./.github/workflows/static-analysis.yml
193+
with:
194+
ref: refs/tags/${{ inputs.version }}
195+
permissions:
196+
security-events: write
197+
id-token: write
198+
199+
publish-ssdlc-assets:
200+
needs: static-analysis
201+
environment: release
202+
name: "Publish SSDLC Assets"
203+
runs-on: ubuntu-latest
204+
permissions:
205+
security-events: read
206+
id-token: write
207+
contents: write
208+
209+
steps:
210+
- name: "Generate token and checkout repository"
211+
uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
212+
with:
213+
app_id: ${{ vars.APP_ID }}
214+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
215+
ref: refs/tags/${{ inputs.version }}
216+
217+
# Sets the S3_ASSETS environment variable used later
218+
- name: "Set up drivers-github-tools"
219+
uses: mongodb-labs/drivers-github-tools/setup@v2
220+
with:
221+
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
222+
aws_region_name: ${{ vars.AWS_REGION_NAME }}
223+
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
224+
225+
- name: "Generate SSDLC Reports"
226+
uses: mongodb-labs/drivers-github-tools/full-report@v2
227+
with:
228+
product_name: "MongoDB PHP Driver (library)"
229+
release_version: ${{ inputs.version }}
230+
silk_asset_group: mongodb-php-driver-library
231+
232+
- name: "Upload SBOM as release artifact"
233+
run: gh release upload ${{ inputs.version }} ${{ env.S3_ASSETS }}/cyclonedx.sbom.json
234+
continue-on-error: true
235+
236+
- name: Upload S3 assets
237+
uses: mongodb-labs/drivers-github-tools/upload-s3-assets@v2
238+
with:
239+
version: ${{ inputs.version }}
240+
product_name: mongo-php-library

0 commit comments

Comments
 (0)