Official release #6
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: Official release | |
on: | |
workflow_dispatch: # Manually on demand | |
inputs: | |
versionBump: | |
description: 'Type of version bump' | |
required: true | |
default: 'patch' | |
type: choice | |
options: | |
- patch | |
- minor | |
- major | |
jobs: | |
publish-config: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
node: [20.x] # This should be LTS | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch the history, or this action won't work | |
- name: Use Node.js ${{ matrix.node }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node }} | |
- name: Install dependencies | |
run: npm ci | |
- name: Build | |
run: npm run build | |
- name: Test | |
run: npm test | |
- name: Prepare release | |
env: | |
VERSION_BUMP: ${{ inputs.versionBump }} | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "Github Action" | |
npm run release -- ${VERSION_BUMP} | |
- name: Determine the version bump | |
id: version | |
uses: actions/github-script@v7 | |
with: | |
result-encoding: string | |
script: | | |
const package = require('./package.json'); | |
return package.version | |
- name: Extract the commit body | |
id: extract_release | |
# The body may be multiline, therefore we need to escape some characters | |
run: | | |
VERSION="${{ github.ref }}" | |
VERSION=${VERSION##*/v} | |
echo "::set-output name=VERSION::$VERSION" | |
BODY=$(git show -s --format=%b) | |
BODY="${BODY//'%'/'%25'}" | |
BODY="${BODY//$'\n'/'%0A'}" | |
BODY="${BODY//$'\r'/'%0D'}" | |
echo "::set-output name=BODY::$BODY" | |
- name: Create Pull Request | |
id: cpr | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
token: ${{ secrets.PR_TOKEN }} | |
commit-message: '[OFFICIAL RELEASE] ${{ steps.version.outputs.result }}' | |
committer: foxriver76 <[email protected]> | |
author: foxriver76 <[email protected]> | |
signoff: false | |
branch: official-release | |
delete-branch: true | |
title: '[OFFICIAL RELEASE] ${{ steps.version.outputs.result }}' | |
body: | | |
${{ steps.extract_release.outputs.BODY }} | |
labels: | | |
automated pr 🔧 | |
assignees: foxriver76 | |
draft: false |