release 'minor' version by @omBratteng #31
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 | |
run-name: "release '${{ github.event.inputs.version }}' version by @${{ github.actor }}" | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version' | |
required: true | |
default: 'patch' | |
type: choice | |
options: | |
- 'major' | |
- 'minor' | |
- 'patch' | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
permissions: | |
id-token: write # Enable OIDC | |
pull-requests: write | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- uses: chainguard-dev/actions/setup-gitsign@main | |
- name: Enable Corepack | |
run: corepack enable | |
- uses: actions/[email protected] | |
with: | |
node-version: 22 | |
cache: pnpm | |
- uses: pnpm/[email protected] | |
- name: Cache node_modules | |
id: cache-node_modules | |
uses: actions/[email protected] | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-node_modules- | |
${{ runner.os }}- | |
- name: Install dependencies | |
if: steps.cache-node_modules.outputs.cache-hit != 'true' | |
run: | | |
pnpm install --frozen-lockfile | |
- name: Setup git | |
run: | | |
git config --global tag.gpgsign true | |
- name: Bump version | |
run: | | |
OLD_VERSION=$(node -p "require('./package.json').version") | |
npm version ${{ github.event.inputs.version }} --no-git-tag-version | |
VERSION=$(node -p "require('./package.json').version") | |
sed -i "s/$OLD_VERSION/$VERSION/g" README.md | |
- name: Prune dist | |
run: | | |
rm -rf dist | |
- name: Build | |
run: | | |
pnpm build | |
git add -A dist | |
- name: Publish | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
VERSION=$(node -p "require('./package.json').version") | |
git commit -m "release: $VERSION" -a | |
git push | |
gh release create $VERSION --generate-notes |