Release react minor-update #4
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 package to npm" | |
on: | |
workflow_dispatch: | |
inputs: | |
package: | |
description: "リリースするパッケージ (api, react, cra-template)" | |
required: true | |
default: api | |
type: choice | |
options: | |
- api | |
- react | |
- cra-template | |
new_version: | |
description: "リリースのバージョニング (major: 破壊的変更, minor: 機能追加, patch: バグ修正)" | |
required: true | |
default: minor | |
type: choice | |
options: | |
- major | |
- minor | |
- patch | |
defaults: | |
run: | |
shell: bash | |
working-directory: ./ | |
env: | |
# テレメトリーを無効 | |
TURBO_TELEMETRY_DISABLED: 1 | |
concurrency: | |
# 同時にリリースできないようにグループは固定値とする | |
group: release | |
cancel-in-progress: false | |
run-name: Release ${{ github.event.inputs.package }} ${{ github.event.inputs.new_version }}-update | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
# pushをするために必要 | |
contents: write | |
# npm tokenを取得する場合に必要 (publish provenance を有効) | |
id-token: write | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-tags: "false" | |
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
with: | |
node-version-file: ".node-version" | |
cache: "npm" | |
registry-url: "https://registry.npmjs.org" | |
# Git push するために設定する | |
- name: setup git config | |
# 参考資料: | |
# - https://github.com/orgs/community/discussions/40405 | |
# - https://docs.github.com/en/actions/learn-github-actions/contexts | |
# このワークフローを実行したユーザー情報からダミーのユーザー名とメールアドレスを設定する | |
run: | | |
git config user.name "${{ github.actor }}" | |
git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com" | |
- name: Install dependencies | |
run: npm ci | |
- name: build | |
run: npm run build:packages | |
- name: bump version | |
run: npm version ${{ inputs.new_version || 'minor' }} --no-git-tag-version -w packages/${{ inputs.package }} | |
- name: create new app version | |
id: new_app_version | |
run: | | |
PKG_VERSION=$(node -e "console.log(require('./packages/${{ inputs.package }}/package.json').version)") | |
echo "VERSION=$PKG_VERSION" >> $GITHUB_OUTPUT | |
- name: create new tag | |
run: | | |
git add packages/${{ inputs.package }}/package.json package-lock.json | |
git commit -m "[${{ inputs.package }}] Version v${{ steps.new_app_version.outputs.VERSION }}" | |
git tag -a "${{ inputs.package }}-v${{ steps.new_app_version.outputs.VERSION }}" -m "[${{ inputs.package }}] Version v${{ steps.new_app_version.outputs.VERSION }}" | |
- name: push | |
run: | | |
git push origin "${{ inputs.package }}-v${{ steps.new_app_version.outputs.VERSION }}" | |
git push origin main | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: publish | |
run: npm publish --provenance -w packages/${{ inputs.package }} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |