Publish #23
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: Publish | |
on: | |
workflow_dispatch: | |
inputs: | |
versionClass: | |
type: choice | |
required: true | |
options: | |
- 'patch' | |
- 'minor' | |
- 'major' | |
schedule: | |
- cron: '0 0 20 * *' # at AM 9 JST on day of month 20 | |
concurrency: | |
group: ${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
- uses: pnpm/action-setup@d882d12c64e032187b2edb46d3a0d003b7a43598 # v2.4.0 | |
- uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 | |
with: | |
node-version-file: '.node-version' | |
cache: 'pnpm' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install dependencies | |
run: pnpm i --frozen-lockfile | |
- name: Bump version and publish | |
id: bump-version | |
run: | | |
git config user.name '[bot] github action (${{ github.workflow }})' | |
git config user.email 'engineer-team@knowledgework.com' | |
pnpm version ${{ github.event_name == 'schedule' && 'patch' || github.event.inputs.versionClass }} | |
pnpm release | |
echo "new_version=$(jq -r .version package.json)" >> "$GITHUB_OUTPUT" | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Create release | |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
await github.rest.repos.createRelease({ | |
owner: "${{github.repository_owner}}", | |
repo: "${{github.repository}}".split('/')[1], | |
tag_name: "v${{ steps.bump-version.outputs.new_version }}", | |
generate_release_notes: true, | |
}) |