Publish #24
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 15 * *' # at AM 9 JST on day of month 15 | |
concurrency: | |
group: ${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4 | |
with: | |
node-version: '18' | |
cache: 'yarn' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install dependencies | |
run: yarn install --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' | |
yarn version --${{ github.event_name == 'schedule' && 'patch' || github.event.inputs.versionClass }} | |
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, | |
}) |