Skip to content

Release

Release #1

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
type:
description: What type of version increment should be done?
default: patch
type: choice
options:
- patch
- minor
- major
required: true
releaseMessage:
description: The message to put in the release
type: string
required: false
permissions:
contents: read
actions: read
security-events: write
jobs:
qa:
name: Quality Assurance
permissions:
contents: read
actions: read
security-events: write
uses: ./.github/workflows/quality-assurance.yml
if: github.ref == 'refs/heads/main'
versioning:
name: Versioning
runs-on: ubuntu-22.04
permissions:
contents: read
if: github.ref == 'refs/heads/main'
outputs:
version: ${{ steps.version.outputs.version }}
minor_version: ${{ steps.version.outputs.minor_version }}
major_version: ${{ steps.version.outputs.major_version }}
previous_version: ${{ steps.version.outputs.previous_version }}
previous_version_ref: ${{ steps.version.outputs.previous_version_ref }}
steps:
- uses: oss-actions/[email protected]
id: version
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
type: ${{ inputs.type }}
release:
name: Release
runs-on: ubuntu-22.04
permissions:
contents: write
needs: [qa, versioning]
if: github.ref != needs.versioning.outputs.previous_version_ref
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Build
run: npm install && npm run ci:build && npm prune --production
- name: Apply version ${{ needs.versioning.outputs.version }}
env:
VERSION: ${{ needs.versioning.outputs.version }}
run: |
node -e 'const pkg = require("./package.json"); pkg.version = process.env.VERSION.substring(1); fs.writeFileSync("package.json", JSON.stringify(pkg, null, 2) + "\n")'
- name: Release
env:
VERSION: ${{ needs.versioning.outputs.version }}
MINOR_VERSION: ${{ needs.versioning.outputs.minor_version }}
MAJOR_VERSION: ${{ needs.versioning.outputs.major_version }}
RELEASE_MESSAGE: |
${{ inputs.releaseMessage || format('Release version {0}', needs.versioning.outputs.version) }}
GH_TOKEN: ${{ github.token }}
run: |
rm -rf .gitignore
if [ -f release.gitignore ]; then
mv release.gitignore .gitignore
fi
git rm --cached `git ls-files -i -c --exclude-from=.gitignore`
git add .
git config user.name github-actions
git config user.email [email protected]
git commit -m "$RELEASE_MESSAGE"
git tag "$VERSION"
git tag -f "$MINOR_VERSION"
git tag -f "$MAJOR_VERSION"
# We don't want to use -f either on tag or push. If something goes wrong it goes wrong.
# Absolutely no UB is allowed here.
git push -u origin "$VERSION"
# Here we have to force push in case of previous versions.
git push -fu origin {$MINOR_VERSION,$MAJOR_VERSION}
gh release create --verify-tag -t "$RELEASE_MESSAGE" -d "$VERSION"