Skip to content

Commit e5d1b94

Browse files
committed
Update release pipeline in v1.21
1 parent 91b6a19 commit e5d1b94

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed

.github/workflows/release.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,106 @@ jobs:
7272
echo '❌ Release failed due to branch mismatch: expected ${{ inputs.version }} to be released from ${{ env.RELEASE_BRANCH }}, got ${{ github.ref_name }}' >> $GITHUB_STEP_SUMMARY
7373
exit 1
7474
75+
# For non-patch releases (A.B.C where C == 0), we expect the release to
76+
# be triggered from the A.B maintenance branch or A.x development branch
77+
- name: "Fail if non-patch release is created from wrong release branch"
78+
if: ${{ endsWith(env.RELEASE_VERSION_WITHOUT_STABILITY, '.0') && env.RELEASE_BRANCH != github.ref_name && env.DEV_BRANCH != github.ref_name }}
79+
run: |
80+
echo '❌ Release failed due to branch mismatch: expected ${{ inputs.version }} to be released from ${{ env.RELEASE_BRANCH }} or ${{ env.DEV_BRANCH }}, got ${{ github.ref_name }}' >> $GITHUB_STEP_SUMMARY
81+
exit 1
82+
83+
# If a non-patch release is created from its A.x development branch,
84+
# create the A.B maintenance branch from the current one and push it
85+
- name: "Create and push new release branch for non-patch release"
86+
if: ${{ endsWith(env.RELEASE_VERSION_WITHOUT_STABILITY, '.0') && env.DEV_BRANCH == github.ref_name }}
87+
run: |
88+
echo '🆕 Creating new release branch ${{ env.RELEASE_BRANCH }} from ${{ github.ref_name }}' >> $GITHUB_STEP_SUMMARY
89+
git checkout -b ${RELEASE_BRANCH}
90+
git push origin ${RELEASE_BRANCH}
91+
92+
#
93+
# Preliminary checks done - generate SBOM before tagging
94+
#
95+
- name: Checkout repository (Base Branch)
96+
uses: actions/checkout@v5
97+
with:
98+
ref: ${{ github.event.pull_request.base.ref || github.ref }}
99+
token: ${{ secrets.GITHUB_TOKEN }}
100+
- name: "Setup PHP environment"
101+
id: setup-php
102+
uses: ./.github/actions/setup
103+
with:
104+
php-version: ${{ env.PHP_VERSION }}
105+
driver-version: ${{ env.DRIVER_VERSION }}
106+
working-directory: '.'
107+
continue-on-error: true
108+
109+
- name: "Generate/Update composer.lock"
110+
id: composer-lock
111+
if: steps.setup-php.outcome == 'success'
112+
run: |
113+
echo "Resolving dependencies and generating composer.lock..."
114+
composer update --lock --no-install --ignore-platform-reqs
115+
echo "composer.lock generated with resolved versions"
116+
continue-on-error: true
117+
118+
- name: "Setup SBOM environment"
119+
id: setup-sbom
120+
if: steps.composer-lock.outcome == 'success'
121+
uses: ./.github/actions/setup-sbom
122+
continue-on-error: true
123+
124+
- name: "Generate SBOM"
125+
id: generate-sbom
126+
if: steps.setup-sbom.outcome == 'success'
127+
uses: ./.github/actions/update-sbom
128+
with:
129+
php-version: ${{ env.PHP_VERSION }}
130+
working-directory: '.'
131+
output-file: ${{ env.SBOM_FILE }}
132+
output-format: 'json'
133+
continue-on-error: true
134+
135+
- name: "Check for SBOM changes"
136+
id: sbom_status
137+
if: steps.generate-sbom.outcome == 'success'
138+
run: |
139+
JQ_NORMALIZER='del(.serialNumber) | del(.metadata.timestamp) | walk(if type == "object" and .timestamp then .timestamp = "TIMESTAMP_NORMALIZED" else . end)'
140+
141+
if ! git show HEAD:${{ env.SBOM_FILE }} > /dev/null 2>&1; then
142+
echo "HAS_CHANGES=true" >> $GITHUB_OUTPUT
143+
echo "SBOM file is new"
144+
exit 0
145+
fi
146+
147+
if diff -q \
148+
<(git show HEAD:${{ env.SBOM_FILE }} | jq -r "$JQ_NORMALIZER") \
149+
<(cat ${{ env.SBOM_FILE }} | jq -r "$JQ_NORMALIZER"); then
150+
echo "HAS_CHANGES=false" >> $GITHUB_OUTPUT
151+
echo "No changes detected in SBOM"
152+
else
153+
echo "HAS_CHANGES=true" >> $GITHUB_OUTPUT
154+
echo "Changes detected in SBOM"
155+
fi
156+
continue-on-error: true
157+
158+
- name: "Commit SBOM changes"
159+
if: steps.sbom_status.outputs.HAS_CHANGES == 'true'
160+
run: |
161+
git add ${{ env.SBOM_FILE }}
162+
git commit -m "chore: Update SBOM for release ${{ inputs.version }}"
163+
git push
164+
echo "📦 SBOM updated and committed" >> $GITHUB_STEP_SUMMARY
165+
continue-on-error: true
166+
167+
- name: "Report SBOM status"
168+
run: |
169+
if [[ "${{ steps.generate-sbom.outcome }}" == "success" ]]; then
170+
echo "✅ SBOM generation completed successfully" >> $GITHUB_STEP_SUMMARY
171+
else
172+
echo "⚠️ SBOM generation skipped or failed - continuing with release" >> $GITHUB_STEP_SUMMARY
173+
fi
174+
75175
#
76176
# Preliminary checks done - commence the release process
77177
#

0 commit comments

Comments
 (0)