release #22
This file contains 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: | |
workflow_dispatch: | |
inputs: | |
bumpType: | |
description: Bump Type | |
required: true | |
type: choice | |
options: | |
- patch | |
- minor | |
- major | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
registry-url: "https://registry.npmjs.org" | |
- uses: pnpm/action-setup@v2 | |
name: Install pnpm | |
id: pnpm-install | |
with: | |
version: 7 | |
run_install: false | |
- run: pnpm install | |
- run: pnpm test run | |
- run: pnpm build | |
- name: Configure git user | |
run: | | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config user.name "github-actions[bot]" | |
- name: Bump package.json version | |
id: bump | |
run: | | |
pnpm version ${{ github.event.inputs.bumpType }} | |
echo "VERSION=v$(cat package.json | jq -r '.version')" >> $GITHUB_OUTPUT | |
git push | |
git push --tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Release | |
run: | | |
pnpm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Get the version | |
id: get_version | |
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} | |
- name: Get commit summary | |
id: get_commit_summary | |
run: | | |
PREVIOUS_TAG=$(git tag --sort=-creatordate | sed -n 2p) | |
echo "PREVIOUS_TAG: $PREVIOUS_TAG" | |
COMMIT_SUMMARY="$(git log --oneline --pretty=tformat:"%h %s" $PREVIOUS_TAG..${{ github.ref }})" | |
COMMIT_SUMMARY="${COMMIT_SUMMARY//$'\n'/'%0A'}" | |
echo ::set-output name=COMMIT_SUMMARY::$COMMIT_SUMMARY | |
- name: Create Release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.get_version.outputs.VERSION }} | |
release_name: Release ${{ steps.get_version.outputs.VERSION }} | |
body: | | |
${{ steps.get_commit_summary.outputs.COMMIT_SUMMARY }} | |
draft: true | |
prerelease: true |