release #3
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: release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: {} | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| cache-dependency-path: package-lock.json | |
| - name: Install | |
| run: npm ci | |
| - name: Test | |
| run: npm test | |
| - name: Pack | |
| id: pack | |
| run: | | |
| TARBALL="$(npm pack --silent)" | |
| echo "tarball=$TARBALL" >> "$GITHUB_OUTPUT" | |
| - name: Upload Tarball Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: npm-tarball | |
| path: ${{ steps.pack.outputs.tarball }} | |
| - name: Create GitHub Release (attach tarball) | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: ${{ steps.pack.outputs.tarball }} | |
| - name: Publish to GitHub Packages (npm.pkg.github.com) | |
| run: | | |
| npm config set registry https://npm.pkg.github.com | |
| npm pkg set name="@${{ github.repository_owner }}/git-ai" | |
| npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish to npmjs.org (optional) | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| if: ${{ env.NODE_AUTH_TOKEN != '' }} | |
| run: | | |
| npm config set registry https://registry.npmjs.org | |
| npm publish --access public |