Merge pull request #2 from usenotra/bump-version-0.0.7 #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 package | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - package.json | |
| permissions: | |
| contents: read | |
| env: | |
| FORCE_COLOR: 3 | |
| jobs: | |
| verify: | |
| name: Verify package | |
| runs-on: ubuntu-latest | |
| outputs: | |
| changed: ${{ steps.version.outputs.changed }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | |
| with: | |
| fetch-depth: 2 | |
| persist-credentials: false | |
| - name: Check package version changed | |
| id: version | |
| shell: bash | |
| run: | | |
| CURRENT_VERSION="$(node -p "require('./package.json').version")" | |
| PREVIOUS_VERSION="$(git show HEAD^:package.json | node -p "JSON.parse(require('fs').readFileSync(0, 'utf8')).version")" | |
| if [ "$CURRENT_VERSION" = "$PREVIOUS_VERSION" ]; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| echo "package.json changed, but version stayed at $CURRENT_VERSION." | |
| exit 0 | |
| fi | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| echo "version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT" | |
| echo "Package version changed from $PREVIOUS_VERSION to $CURRENT_VERSION." | |
| - name: Setup Bun | |
| if: steps.version.outputs.changed == 'true' | |
| uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 | |
| with: | |
| bun-version: 1.3.11 | |
| - name: Setup Node | |
| if: steps.version.outputs.changed == 'true' | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
| with: | |
| node-version: 22 | |
| registry-url: https://registry.npmjs.org | |
| - name: Install dependencies | |
| if: steps.version.outputs.changed == 'true' | |
| run: bun install --frozen-lockfile | |
| - name: Typecheck | |
| if: steps.version.outputs.changed == 'true' | |
| run: bun run typecheck | |
| publish: | |
| name: Publish to npm | |
| runs-on: ubuntu-latest | |
| needs: verify | |
| if: needs.verify.outputs.changed == 'true' | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | |
| with: | |
| persist-credentials: false | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 | |
| with: | |
| bun-version: 1.3.11 | |
| - name: Setup Node | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
| with: | |
| node-version: 22 | |
| registry-url: https://registry.npmjs.org | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Verify dependency signatures | |
| run: npm audit signatures | |
| - name: Publish | |
| run: npm publish --provenance --access public |