Skip to content

Publish affine-reader #1

Publish affine-reader

Publish affine-reader #1

name: Publish affine-reader
on:
workflow_dispatch:
inputs:
version:
description: "The new version number (e.g., 1.2.3)"
required: true
type: string
dry-run:
description: "If true, perform a dry run without actually publishing"
required: false
type: boolean
default: false
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write # Allow to push commits
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: "10.10.0" # Or specify a particular pnpm version
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
working-directory: ./
- name: Bump version in package.json
working-directory: ./packages/affine-reader
run: |
npm version ${{ inputs.version }} --no-git-tag-version --allow-same-version
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Commit package.json changes
working-directory: ./
run: |
git add packages/affine-reader/package.json
git commit -m "chore(release): affine-reader@${{ inputs.version }}"
- name: Setup .npmrc file
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
- name: Publish to npm
working-directory: ./packages/affine-reader
run: |
if [ "${{ inputs.dry-run }}" = "true" ]; then
pnpm publish . --no-git-checks --dry-run
else
pnpm publish . --no-git-checks
fi
- name: Push commit
if: success() && inputs.dry-run != 'true' # Only push if publish was successful and not a dry run
run: git push
working-directory: ./