Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Release

Release #6

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/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 }} (major: ${{ needs.versioning.outputs.major_version }}, minor: ${{ needs.versioning.outputs.minor_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: Git Author Config
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Versioning
run: git tag $VERSION
env:
VERSION: ${{ needs.versioning.outputs.version }}
- name: Versioning (minor)
run: git tag -f $VERSION
env:
VERSION: ${{ needs.versioning.outputs.minor_version }}
- name: Versioning (major)
run: git tag -f $VERSION
env:
VERSION: ${{ needs.versioning.outputs.major_version }}
- name: Push tags
run: |
git push -u origin $VERSION
git push -fu origin {$MINOR_VERSION,$MAJOR_VERSION}
env:
VERSION: ${{ needs.versioning.outputs.version }}
MINOR_VERSION: ${{ needs.versioning.outputs.minor_version }}
MAJOR_VERSION: ${{ needs.versioning.outputs.major_version }}
- name: NPM Authentication
run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: NPM Publish
run: npm publish