Automate GitHub Release #11
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: 'RELEASE: Publish to GitHub' | |
on: | |
workflow_dispatch: | |
pull_request: | |
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-actions[bot]' | |
git config user.email 'github-actions[bot]@users.noreply.github.com' | |
- name: Get current version | |
id: get-version | |
run: | | |
ALL_PACKAGE_VERSION=$(npm run version --silent --workspace govuk-frontend) | |
TAG="v5.8.1-internal.0" | |
- name: Create GitHub archive | |
run: git archive -o ./release-${{ steps.get-version.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.get-version.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" --draft | |
fi |