This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
Release #2
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 | |
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/auto-semver@v0 | |
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: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
git tag "$VERSION" | |
git tag -f "$MINOR_VERSION" | |
git tag -f "$MAJOR_VERSION" | |
git push -u origin "$VERSION" | |
git push -fu origin {$MINOR_VERSION,$MAJOR_VERSION} | |
npm publish |