Skip to content

Commit 153a4dc

Browse files
authored
Merge pull request #7029 from alphagov/add-dry-run-to-release-steps
Add Dry Run functionality to release Actions
2 parents e084f2f + 8e49bb8 commit 153a4dc

2 files changed

Lines changed: 54 additions & 2 deletions

File tree

.github/workflows/publish-release-to-github.yaml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
name: 'RELEASE: GitHub release'
2+
run-name: "RELEASE: GitHub release${{ inputs.dry_run && ' (Dry run)' || '' }}"
23

34
on:
45
workflow_dispatch:
6+
inputs:
7+
dry_run:
8+
type: boolean
9+
description: Dry run
10+
default: true
511

612
jobs:
713
publish-release-to-github:
@@ -47,7 +53,17 @@ jobs:
4753
fi
4854
4955
- name: Create GitHub archive
50-
run: git archive -o ./release-${{ steps.create-github-tag.outputs.GH_TAG }}.zip HEAD:dist
56+
id: archive
57+
run: |
58+
ARCHIVE_FILE_PATH="./release-${{ steps.create-github-tag.outputs.GH_TAG }}.zip"
59+
git archive -o "${ARCHIVE_FILE_PATH}" HEAD:dist
60+
echo "ARCHIVE_FILE_PATH=${ARCHIVE_FILE_PATH}" >> $GITHUB_OUTPUT
61+
62+
- name: Upload GitHub archive artifact
63+
uses: actions/upload-artifact@v7
64+
with:
65+
path: ${{steps.archive.outputs.ARCHIVE_FILE_PATH}}
66+
archive: false # file is already compressed
5167

5268
- name: Generate release notes
5369
uses: actions/github-script@v9.0.0
@@ -57,15 +73,28 @@ jobs:
5773
5874
await generateReleaseNotes('${{ steps.create-github-tag.outputs.GH_TAG }}')
5975
76+
- name: Print information on release notes
77+
run: |
78+
{
79+
echo "## Generated release notes"
80+
cat release-notes-body
81+
echo '## Files in archive'
82+
echo '```bash'
83+
tree dist
84+
echo '```'
85+
} >> $GITHUB_STEP_SUMMARY
86+
6087
- name: Create GitHub release
88+
if: inputs.dry_run == false
6189
run: |
6290
GH_TAG=${{ steps.create-github-tag.outputs.GH_TAG }}
6391
RELEASE_NAME="GOV.UK Frontend $GH_TAG"
6492
RELEASE_BODY=$(cat release-notes-body)
93+
ARCHIVE_FILE_PATH="${{steps.archive.outputs.ARCHIVE_FILE_PATH}}"
6594
6695
if gh release view "$GH_TAG" > /dev/null 2>&1; then
6796
echo "⚠️ Release $GH_TAG already exists. Please delete the release and tag via the GitHub UI and re-run this workflow"
6897
exit 1
6998
else
70-
gh release create "$GH_TAG" ./release-"${GH_TAG}".zip --title "${RELEASE_NAME}" --notes "$RELEASE_BODY"
99+
gh release create "$GH_TAG" "$ARCHIVE_FILE_PATH" --title "${RELEASE_NAME}" --notes "$RELEASE_BODY"
71100
fi

.github/workflows/publish-to-npm.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
name: 'RELEASE: npm publish'
2+
run-name: "RELEASE: npm publish${{ inputs.dry_run && ' (Dry run)' || '' }}"
23

34
on:
45
workflow_dispatch:
6+
inputs:
7+
dry_run:
8+
type: boolean
9+
description: Dry run
10+
default: true
511

612
jobs:
713
publish:
@@ -32,5 +38,22 @@ jobs:
3238
- name: Build npm package
3339
run: npm run build:package
3440

41+
- name: Print information on package
42+
id: pack
43+
run: |
44+
echo '```bash' >> $GITHUB_STEP_SUMMARY
45+
# Redirect the stderr which contains the useful meta data to the Action summary
46+
ARCHIVE_FILE_PATH=$(npm pack --workspace govuk-frontend 2>> $GITHUB_STEP_SUMMARY)
47+
echo '```' >> $GITHUB_STEP_SUMMARY
48+
49+
echo "ARCHIVE_FILE_PATH=${ARCHIVE_FILE_PATH}" >> $GITHUB_OUTPUT
50+
51+
- name: Upload npm package archive artifact
52+
uses: actions/upload-artifact@v7
53+
with:
54+
path: ${{steps.pack.outputs.ARCHIVE_FILE_PATH}}
55+
archive: false # file is already compressed
56+
3557
- name: Publish to npm
58+
if: inputs.dry_run == false
3659
run: npm publish --workspace govuk-frontend --provenance --tag ${{steps.generate_tag.outputs.NPM_TAG}}

0 commit comments

Comments
 (0)