chore: release v1.1.2 #12
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: release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Tag name to release (e.g. v1.2.3). If empty, skip release/publish steps." | |
| required: false | |
| type: string | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| env: | |
| RELEASE_TAG: ${{ github.ref_type == 'tag' && github.ref_name || inputs.tag }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Checkout input tag | |
| if: ${{ inputs.tag != '' && github.ref_type != 'tag' }} | |
| run: git checkout "${{ inputs.tag }}" | |
| - name: Setup Node (build/test) | |
| 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: Sync version from Tag | |
| if: ${{ env.RELEASE_TAG != '' }} | |
| run: | | |
| VERSION=${RELEASE_TAG#v} | |
| echo "Syncing version to $VERSION" | |
| npm version $VERSION --no-git-tag-version --allow-same-version | |
| - 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) | |
| if: ${{ env.RELEASE_TAG != '' }} | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ env.RELEASE_TAG }} | |
| files: ${{ steps.pack.outputs.tarball }} | |
| - name: Setup Node (GitHub Packages) | |
| if: ${{ env.RELEASE_TAG != '' }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| registry-url: "https://npm.pkg.github.com" | |
| scope: "@${{ github.repository_owner }}" | |
| - name: Publish to GitHub Packages (npm.pkg.github.com) | |
| if: ${{ env.RELEASE_TAG != '' }} | |
| run: | | |
| npm pkg set name="@${{ github.repository_owner }}/git-ai" | |
| npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Node (npmjs.org) | |
| if: ${{ env.RELEASE_TAG != '' }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Publish to npmjs.org (optional) | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| if: ${{ env.RELEASE_TAG != '' && env.NODE_AUTH_TOKEN != '' }} | |
| run: | | |
| npm publish --access public |