TrackSeries CLI v0.4.1 #8
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 installer | |
| on: | |
| release: | |
| types: | |
| - published | |
| permissions: | |
| contents: read | |
| id-token: write | |
| jobs: | |
| publish: | |
| name: Publish @trackseries/cli | |
| if: startsWith(github.event.release.tag_name, 'cli-v') | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| registry-url: https://registry.npmjs.org | |
| package-manager-cache: false | |
| - name: Use npm 12 | |
| run: npm install --global npm@12 | |
| - name: Prepare release version | |
| id: metadata | |
| shell: bash | |
| run: | | |
| version="${{ github.event.release.tag_name }}" | |
| version="${version#cli-v}" | |
| npm version "$version" --no-git-tag-version --allow-same-version | |
| if [[ "$version" == *-* ]]; then | |
| expected_prerelease=true | |
| echo "tag=next" >> "$GITHUB_OUTPUT" | |
| else | |
| expected_prerelease=false | |
| echo "tag=latest" >> "$GITHUB_OUTPUT" | |
| fi | |
| if [[ "${{ github.event.release.prerelease }}" != "$expected_prerelease" ]]; then | |
| echo "GitHub prerelease status does not match version ${version}." >&2 | |
| exit 1 | |
| fi | |
| - name: Install package dependencies | |
| run: npm ci --ignore-scripts | |
| - name: Validate npm version | |
| shell: bash | |
| run: | | |
| version="$(node --print "require('./package.json').version")" | |
| tag="${{ steps.metadata.outputs.tag }}" | |
| dist_tags="$(npm view "@trackseries/cli" dist-tags --json)" | |
| published="$( | |
| DIST_TAGS="$dist_tags" TAG="$tag" node \ | |
| --eval "const tags = JSON.parse(process.env.DIST_TAGS); process.stdout.write(tags[process.env.TAG] ?? '')" | |
| )" | |
| node scripts/assert-newer-version.js "$version" "$published" | |
| if npm view "@trackseries/cli@${version}" version >/dev/null 2>&1; then | |
| echo "@trackseries/cli@${version} is already published." >&2 | |
| exit 1 | |
| fi | |
| - name: Test package | |
| run: npm test | |
| - name: Publish package | |
| run: npm publish --access public --tag "${{ steps.metadata.outputs.tag }}" |