Automate GitHub Release #2
Workflow file for this run
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
name: Publish release to GitHub | |
on: | |
workflow_dispatch: | |
pull_request: | |
jobs: | |
publish-release-to-github: | |
name: Publish release to GitHub | |
runs-on: Ubuntu-22.04 | |
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-actions[bot]' | |
git config user.email 'github-actions[bot]@users.noreply.github.com' | |
- name: Create GitHub tag | |
id: create-github-tag | |
run: | | |
ALL_PACKAGE_VERSION=$(npm run version --silent --workspace govuk-frontend) | |
TAG="v5.8.1-internal.0" | |
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 --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.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) | |
gh release create "$GH_TAG" ./release-"${GH_TAG}".zip --title "GOV.UK Frontend ${RELEASE_NAME}" --notes "$RELEASE_BODY" --draft |