Publish affine-reader #5
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: 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" | |
| registry-url: 'https://registry.npmjs.org' | |
| - 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: Publish to npm | |
| working-directory: ./packages/affine-reader | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| 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: ./ |