Revert package.json to 1.14.2 — accidental v2.0.0 release #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: Release | |
| on: | |
| push: | |
| branches: [main] | |
| paths: ['package.json'] | |
| jobs: | |
| check-version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.check.outputs.version }} | |
| changed: ${{ steps.check.outputs.changed }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 2 | |
| - id: check | |
| run: | | |
| CURRENT=$(node -p "require('./package.json').version") | |
| PREVIOUS=$(git show HEAD~1:package.json | node -p "JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')).version" || echo "0.0.0") | |
| echo "version=$CURRENT" >> "$GITHUB_OUTPUT" | |
| if [ "$CURRENT" != "$PREVIOUS" ]; then | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| publish-and-release: | |
| needs: check-version | |
| if: needs.check-version.outputs.changed == 'true' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 18 | |
| registry-url: https://registry.npmjs.org | |
| - name: Run tests | |
| run: npm test | |
| - name: Publish to npm | |
| run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Create git tag | |
| run: | | |
| VERSION="v${{ needs.check-version.outputs.version }}" | |
| git tag "$VERSION" | |
| git push origin "$VERSION" | |
| - name: Extract changelog section | |
| id: changelog | |
| run: | | |
| VERSION="${{ needs.check-version.outputs.version }}" | |
| NOTES=$(sed -n "/^## \[v${VERSION}\]/,/^## \[v/{ /^## \[v${VERSION}\]/d; /^## \[v/d; p; }" .devcontainer/CHANGELOG.md) | |
| if [ -z "$NOTES" ]; then | |
| NOTES="Release v${VERSION}" | |
| fi | |
| echo "$NOTES" > /tmp/release-notes.md | |
| - name: Create GitHub Release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION="v${{ needs.check-version.outputs.version }}" | |
| gh release create "$VERSION" \ | |
| --title "$VERSION" \ | |
| --notes-file /tmp/release-notes.md |