Publish to npm #12
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 GitHub Packages | |
| # Publishing a GitHub Release is the normal trigger. workflow_dispatch remains | |
| # available for retrying the current package version from main. | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| publish: | |
| if: github.repository == 'deckflow/html-editor' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out the release | |
| uses: actions/checkout@v6 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '24' | |
| registry-url: 'https://npm.pkg.github.com' | |
| scope: '@deckflow' | |
| package-manager-cache: false | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Verify release tag | |
| env: | |
| RELEASE_TAG: ${{ github.event.release.tag_name }} | |
| run: >- | |
| node --input-type=module -e ' | |
| import { readFileSync } from "node:fs"; | |
| const { version } = JSON.parse(readFileSync("package.json", "utf8")); | |
| const tag = process.env.RELEASE_TAG; | |
| if (tag && tag !== version && tag !== `v${version}`) { | |
| throw new Error(`Release tag ${tag} does not match package version ${version}`); | |
| } | |
| console.log(`Publishing @deckflow/html-editor@${version}`); | |
| ' | |
| - name: Test package | |
| run: npm test | |
| - name: Inspect package contents | |
| run: npm pack --dry-run | |
| - name: Publish package | |
| run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |