release(v1.2.3): prepare (#123) #163
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: | |
| branches: | |
| - 'master' | |
| # Manual trigger | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| name: Publish to npm | |
| permissions: | |
| contents: write | |
| id-token: write | |
| if: github.event_name == 'workflow_dispatch' || contains( github.event.head_commit.message, 'release' ) | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 | |
| - name: Set up pnpm | |
| uses: pnpm/action-setup@08c4be7e2e672a47d11bd04269e27e5f3e8529cb # v6 | |
| with: | |
| run_install: true | |
| - name: Set up Node.js | |
| uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6 | |
| with: | |
| node-version: '24' | |
| cache: 'pnpm' | |
| - name: Get release version | |
| id: get_release_version | |
| run: echo "version=$(jq -r .version ./package.json)" >> $GITHUB_OUTPUT | |
| - name: Compile | |
| run: pnpm compile | |
| - name: Publish packages | |
| run: pnpm -r publish --tag=latest --provenance | |
| - name: Tag version | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag v${{ steps.get_release_version.outputs.version }} --force | |
| MAJOR_VERSION=$(echo ${{ steps.get_release_version.outputs.version }} | cut -d. -f1) | |
| git tag v${MAJOR_VERSION} --force | |
| git tag latest --force | |
| git push origin v${{ steps.get_release_version.outputs.version }} --force | |
| git push origin v${MAJOR_VERSION} --force | |
| git push origin latest --force | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Pack | |
| run: pnpm -r pack | |
| - name: Push artifacts | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: pki-lite-${{ steps.get_release_version.outputs.version }} | |
| path: ./*.tgz | |
| github-release: | |
| runs-on: ubuntu-latest | |
| name: Create GitHub Release | |
| needs: publish | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| - name: Get release version | |
| id: get_release_version | |
| run: VERSION_FILE=$(ls *.tgz | head -n 1) && echo "version=$(echo $VERSION_FILE | sed -E 's/^pki-lite-(.*)\.tgz$/\1/')" >> $GITHUB_OUTPUT | |
| - name: Create Release | |
| id: create_release | |
| uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3 | |
| with: | |
| draft: false | |
| prerelease: ${{ contains(steps.get_release_version.outputs.version, '-') }} | |
| generate_release_notes: true | |
| tag_name: v${{ steps.get_release_version.outputs.version }} | |
| files: './*.tgz' |