-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5641 from alphagov/automate-publish-release-to-gi…
…thub Automate GitHub Release
- Loading branch information
Showing
2 changed files
with
74 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: 'RELEASE: Publish to GitHub' | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
publish-release-to-github: | ||
name: Publish release to GitHub | ||
runs-on: Ubuntu-22.04 | ||
permissions: | ||
contents: write | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
|
||
- name: Setup Node | ||
uses: actions/[email protected] | ||
with: | ||
node-version-file: .nvmrc | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Set up Git | ||
run: | | ||
git config user.name '${{ github.actor }}' | ||
git config user.email '${{ github.actor }}@users.noreply.github.com' | ||
- name: Create GitHub tag | ||
id: create-github-tag | ||
run: | | ||
ALL_PACKAGE_VERSION=$(npm run version --silent --workspace govuk-frontend) | ||
TAG="v${ALL_PACKAGE_VERSION}" | ||
if [ $(git tag -l "$TAG") ]; then | ||
echo "⚠️ Tag $TAG already exists. Please delete $TAG via the GitHub UI and re-run this workflow" | ||
exit 1 | ||
else | ||
echo "🗒 Tagging repo using tag version: $TAG ..." | ||
git tag -a $TAG -m "GOV.UK Frontend release $TAG" | ||
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} --tags | ||
echo "🗒 Tag $TAG created and pushed to remote." | ||
echo "GH_TAG=${TAG}" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Create GitHub archive | ||
run: git archive -o ./release-${{ steps.create-github-tag.outputs.GH_TAG }}.zip HEAD:dist | ||
|
||
- name: Generate release notes | ||
uses: actions/[email protected] | ||
with: | ||
script: | | ||
const { generateReleaseNotes } = await import('${{ github.workspace }}/.github/workflows/scripts/changelog-release-helper.mjs') | ||
await generateReleaseNotes() | ||
- name: Create GitHub release | ||
run: | | ||
GH_TAG=${{ steps.create-github-tag.outputs.GH_TAG }} | ||
RELEASE_NAME="GOV.UK Frontend $GH_TAG" | ||
RELEASE_BODY=$(cat release-notes-body) | ||
if gh release view "$GH_TAG" > /dev/null 2>&1; then | ||
echo "⚠️ Release $GH_TAG already exists. Please delete the release and tag via the GitHub UI and re-run this workflow" | ||
exit 1 | ||
else | ||
gh release create "$GH_TAG" ./release-"${GH_TAG}".zip --title "GOV.UK Frontend ${RELEASE_NAME}" --notes "$RELEASE_BODY" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters