Skip to content

Automate package publishing via CI/CD #1

Automate package publishing via CI/CD

Automate package publishing via CI/CD #1

Workflow file for this run

# Prerelease packages are published to the 'dev' tag on npm on every update to main

Check failure on line 1 in .github/workflows/prerelease.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/prerelease.yml

Invalid workflow file

(Line: 30, Col: 14): Unexpected symbol: 'sha::7'. Located at position 8 within expression: github.sha::7
name: Publish prerelease package
on:
push:
branches:
- main
permissions:
id-token: write
jobs:
prerelease:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 24
registry-url: 'https://registry.npmjs.org/'
- name: Install dependencies
run: npm ci
- name: Bump prerelease version based on latest stable version tag
id: latest
run: |
LATEST_TAG=$(git tag --list "v*.*.*" --sort=-v:refname | grep -v '-' | head -n1)
npm version "$${LATEST_TAG#v}" --no-git-tag-version
npm version prerelease --preid="dev.${{ github.sha::7 }}" --no-git-tag-version
echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Publish prerelease to npm (with 'dev' tag)
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --tag dev --access public