Update version in package.json to 0.1.1 #3
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 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - package.json | |
| permissions: | |
| contents: read | |
| id-token: write | |
| jobs: | |
| changes: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| publish: ${{ steps.release.outputs.publish }} | |
| version: ${{ steps.release.outputs.version }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Detect version bump | |
| id: release | |
| run: | | |
| set -euo pipefail | |
| NEW=$(jq -r .version package.json) | |
| OLD=$(git show HEAD^:package.json | jq -r .version) | |
| if [ "$OLD" = "$NEW" ]; then | |
| echo "No version bump (${OLD} -> ${NEW}), skipping publish" | |
| echo "publish=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| if npm view "@decodo/cli@${NEW}" version >/dev/null 2>&1; then | |
| echo "Version ${NEW} already on npm, skipping publish" | |
| echo "publish=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| echo "Publishing new version ${NEW} (was ${OLD})" | |
| echo "publish=true" >> "$GITHUB_OUTPUT" | |
| echo "version=${NEW}" >> "$GITHUB_OUTPUT" | |
| publish: | |
| needs: changes | |
| if: needs.changes.outputs.publish == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| registry-url: https://registry.npmjs.org | |
| cache: pnpm | |
| cache-dependency-path: pnpm-lock.yaml | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Lint | |
| run: pnpm lint | |
| - name: Typecheck | |
| run: pnpm typecheck | |
| - name: Build | |
| run: pnpm build | |
| - name: Test | |
| run: pnpm test | |
| - name: Ensure npm supports trusted publishing | |
| run: npm install -g npm@latest | |
| - name: Publish to npm | |
| run: pnpm publish --no-git-checks --access public |