automation-v.0.0.1-release-alpha-feems-etc-all-!-* #66
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: Publish npm Package | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Extract version from release tag | |
| if: github.event_name == 'release' | |
| run: | | |
| VERSION="${{ github.event.release.tag_name }}" | |
| # Remove 'v' prefix if present, or use the tag as version base | |
| VERSION=$(echo "$VERSION" | sed 's/^v//') | |
| # If version doesn't match semver, use run number as patch version | |
| if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then | |
| VERSION="1.0.${{ github.run_number }}" | |
| fi | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| # Set the version in package.json - fail if npm version fails for unexpected reasons | |
| npm version "$VERSION" --no-git-tag-version --allow-same-version | |
| - name: Set version for workflow_dispatch | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| VERSION="1.0.${{ github.run_number }}" | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| npm version "$VERSION" --no-git-tag-version --allow-same-version | |
| - name: Publish to npm | |
| run: npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |