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: Publish | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| channel: | |
| description: "Select release channel" | |
| type: choice | |
| default: prerelease | |
| options: | |
| - prerelease | |
| - release | |
| workflow_call: | |
| inputs: | |
| channel: | |
| description: "release or prerelease" | |
| required: false | |
| default: prerelease | |
| type: string | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| env: | |
| RELEASE_CHANNEL: ${{ inputs.channel }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.PUBLISH_TOKEN }} | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10.28.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20.20.0 | |
| cache: pnpm | |
| registry-url: https://registry.npmjs.org | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Run tests | |
| run: pnpm run test | |
| - name: Build package | |
| run: pnpm run build | |
| - name: Configure git user | |
| run: | | |
| git config user.name "safwanyp CI/CD" | |
| git config user.email "safwanparkar6@gmail.com" | |
| - name: Bump version with standard-version | |
| env: | |
| HUSKY: 0 | |
| run: | | |
| if [ "$RELEASE_CHANNEL" = "prerelease" ]; then | |
| pnpm dlx standard-version --prerelease rc | |
| else | |
| pnpm dlx standard-version | |
| fi | |
| - name: Capture version | |
| run: node -p "'RELEASE_VERSION=' + require('./package.json').version" >> "$GITHUB_ENV" | |
| - name: Publish to npm | |
| run: | | |
| if [ "$RELEASE_CHANNEL" = "prerelease" ]; then | |
| pnpm publish --access public --tag rc --provenance | |
| else | |
| pnpm publish --access public --provenance | |
| fi | |
| - name: Push commit and tags | |
| run: | | |
| git push --follow-tags --no-verify | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ env.RELEASE_VERSION }} | |
| name: v${{ env.RELEASE_VERSION }} | |
| generate_release_notes: true | |
| prerelease: ${{ env.RELEASE_CHANNEL == 'prerelease' }} | |
| token: ${{ secrets.PUBLISH_TOKEN }} |