Release (Manual) #4
This file contains hidden or 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 (Manual) | |
on: | |
workflow_dispatch: | |
inputs: | |
release_type: | |
description: "Type of release" | |
required: true | |
default: "version" | |
type: choice | |
options: | |
- version | |
- publish | |
jobs: | |
version: | |
if: github.event.inputs.release_type == 'version' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
actions: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
registry-url: "https://registry.npmjs.org" | |
- name: Install pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 10 | |
run_install: false | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- name: Setup pnpm cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Build | |
run: pnpm run build | |
- name: Run tests | |
run: pnpm test | |
- name: Create Release Pull Request | |
uses: changesets/action@v1 | |
with: | |
version: pnpm changeset:version | |
commit: "chore: version packages" | |
title: "chore: version packages" | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }} | |
publish: | |
if: github.event.inputs.release_type == 'publish' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
actions: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
registry-url: "https://registry.npmjs.org" | |
- name: Install pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 10 | |
run_install: false | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- name: Setup pnpm cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Build | |
run: pnpm run build | |
- name: Run tests | |
run: pnpm test | |
- name: Publish to NPM | |
uses: changesets/action@v1 | |
with: | |
publish: pnpm changeset:publish | |
commit: "chore: publish packages" | |
title: "chore: publish packages" | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |