|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + release-please: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + outputs: |
| 13 | + release_created: ${{ steps.release.outputs.release_created }} |
| 14 | + permissions: |
| 15 | + contents: write |
| 16 | + pull-requests: write |
| 17 | + issues: write |
| 18 | + steps: |
| 19 | + - uses: googleapis/release-please-action@v4 |
| 20 | + id: release |
| 21 | + with: |
| 22 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 23 | + config-file: release-please-config.json |
| 24 | + manifest-file: .release-please-manifest.json |
| 25 | + |
| 26 | + npm-publish: |
| 27 | + needs: release-please |
| 28 | + if: ${{ needs.release-please.outputs.release_created }} |
| 29 | + runs-on: ubuntu-latest |
| 30 | + permissions: |
| 31 | + contents: read |
| 32 | + id-token: write |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v4 |
| 35 | + - name: Setup Node.js |
| 36 | + uses: actions/setup-node@v4 |
| 37 | + with: |
| 38 | + node-version: '22' |
| 39 | + registry-url: 'https://registry.npmjs.org' |
| 40 | + cache: 'npm' |
| 41 | + - name: Install dependencies |
| 42 | + run: npm ci |
| 43 | + - name: Build the package |
| 44 | + run: npm run build |
| 45 | + - name: Publish to NPMJS.org |
| 46 | + run: npm publish --provenance --access public |
| 47 | + env: |
| 48 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 49 | + |
| 50 | + upload-release-bundle: |
| 51 | + needs: release-please |
| 52 | + if: ${{ needs.release-please.outputs.release_created }} |
| 53 | + runs-on: ubuntu-latest |
| 54 | + permissions: |
| 55 | + contents: write |
| 56 | + id-token: write |
| 57 | + |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v4 |
| 60 | + |
| 61 | + - name: Setup Node Environment |
| 62 | + run: npm ci |
| 63 | + |
| 64 | + - name: Set repository name env var |
| 65 | + run: echo "REPO_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV |
| 66 | + |
| 67 | + - name: Build plugin bundle |
| 68 | + run: npm run bundle |
| 69 | + |
| 70 | + - name: Create zipped bundle |
| 71 | + run: | |
| 72 | + (cd ./dist && zip -r ../${REPO_NAME}.zip .) |
| 73 | + tar -C ./dist -czvf ${REPO_NAME}.tar.gz ./ |
| 74 | +
|
| 75 | + - name: Upload zipped bundle to GitHub release |
| 76 | + env: |
| 77 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + run: gh release upload ${{ needs.release-please.outputs.tag_name }} ${REPO_NAME}.zip ${REPO_NAME}.tar.gz |
0 commit comments