2.9.7 #1173
Workflow file for this run
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 tag pushes on Github | |
| on: | |
| push: | |
| tags: | |
| - v** | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Cache node modules | |
| uses: actions/cache@v4 | |
| env: | |
| cache-name: cache-node-modules | |
| with: | |
| # npm cache files are stored in `~/.npm` on Linux/macOS | |
| path: ~/.npm | |
| key: node-${{ matrix.node_version }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| node-${{ matrix.node_version }}-build-${{ env.cache-name }}- | |
| - uses: actions/setup-node@v4 | |
| - name: Check if version already exists | |
| id: version-check | |
| run: | | |
| package_version=$(node -p "require('./package.json').version") | |
| exists=$(gh api repos/${{ github.repository }}/releases/tags/v$package_version >/dev/null 2>&1 && echo "true" || echo "") | |
| if [ -n "$exists" ]; | |
| then | |
| echo "Version v$package_version already exists" | |
| echo "::warning file=package.json,line=1::Version v$package_version already exists - no release will be created. If you want to create a new release, please update the version in package.json and push again." | |
| echo "skipped=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Version v$package_version does not exist. Creating release..." | |
| echo "skipped=false" >> $GITHUB_OUTPUT | |
| echo "tag=v$package_version" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - run: npm ci | |
| if: ${{ steps.version-check.outputs.skipped == 'false' }} | |
| - run: npm run pack | |
| if: ${{ steps.version-check.outputs.skipped == 'false' }} | |
| - name: Create draft Github Release | |
| if: ${{ steps.version-check.outputs.skipped == 'false' }} | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: dist/bump-*.tar.gz | |
| draft: true | |
| tag_name: ${{ steps.version-check.outputs.tag }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_REPOSITORY: bump-sh/cli |