Merge pull request #72 from linearis-oss/fix/update-repo-urls #19
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 to npm | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| permissions: | |
| id-token: write # Required for OIDC | |
| contents: read | |
| jobs: | |
| publish: | |
| # Only run on main branch | |
| if: github.ref_name == github.event.repository.default_branch || startsWith(github.ref, 'refs/tags/') | |
| runs-on: ubuntu-latest | |
| environment: npm-publish | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Extract version from tag | |
| id: extract_version | |
| run: | | |
| TAG=${GITHUB_REF#refs/tags/v} | |
| echo "version=$TAG" >> $GITHUB_OUTPUT | |
| echo "Extracted version: $TAG" | |
| - name: Verify tag format | |
| run: | | |
| VERSION="${{ steps.extract_version.outputs.version }}" | |
| if ! [[ "$VERSION" =~ ^[0-9]{4}\.[0-9]{1,2}\.[0-9]+$ ]]; then | |
| echo "Error: Tag version '$VERSION' does not match YYYY.MM.N format" | |
| exit 1 | |
| fi | |
| - name: Verify version matches package.json | |
| run: | | |
| PACKAGE_VERSION=$(node -p "require('./package.json').version") | |
| TAG_VERSION="${{ steps.extract_version.outputs.version }}" | |
| if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then | |
| echo "Error: package.json version ($PACKAGE_VERSION) does not match tag version ($TAG_VERSION)" | |
| exit 1 | |
| fi | |
| echo "Version check passed: $PACKAGE_VERSION" | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Clean install | |
| run: npm install | |
| - name: Build | |
| run: npm run build --if-present | |
| - name: Run tests | |
| run: npm test | |
| - name: Publish to npm | |
| run: npm publish --provenance --access public | |
| - name: Verify publish success | |
| run: | | |
| echo "✅ Successfully published linearis@${{ steps.extract_version.outputs.version }}" | |
| echo "📦 Package URL: https://www.npmjs.com/package/linearis" |