Skip to content

Official release

Official release #2

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: 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@v6
with:
token: ${{ secrets.PR_TOKEN }}
commit-message: "[OFFICIAL RELEASE] ${{ steps.version.outputs.result }}"
committer: foxbot76 <[email protected]>
author: foxbot76 <[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: foxbot76
draft: false