fix: add contents:write permission for GitHub Release creation #2
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*' # Trigger on version tags like v3.0.0, v3.1.0, etc. | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Required for creating GitHub releases | |
| id-token: write # Required for npm trusted publishing (OIDC) | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' # Use Node 20 LTS | |
| registry-url: 'https://registry.npmjs.org' | |
| cache: 'npm' | |
| always-auth: true | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run tests | |
| run: npm run test:lib -- --watch=false --browsers=ChromeHeadless | |
| - name: Build production library | |
| run: npm run build-prod:lib | |
| - name: Copy files to dist | |
| run: | | |
| npm run copy:readme | |
| npm run copy:changelog | |
| npm run copy:license | |
| - name: Determine npm tag | |
| id: npm-tag | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| if [[ "$VERSION" == *"beta"* ]] || [[ "$VERSION" == *"alpha"* ]] || [[ "$VERSION" == *"rc"* ]]; then | |
| echo "tag=next" >> $GITHUB_OUTPUT | |
| else | |
| echo "tag=latest" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Publish to npm (Trusted Publishing) | |
| run: npm publish ./dist/angular-editor --tag ${{ steps.npm-tag.outputs.tag }} --provenance --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| body_path: CHANGELOG.md | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |