build: change github action semantic-release to release-please #1
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
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| dry_run: | |
| description: 'Dry-run mode' | |
| required: true | |
| default: true | |
| type: boolean | |
| package_folder: | |
| description: 'Package folder path' | |
| required: true | |
| default: './Packages/ga.fuquna.rosettaui' | |
| type: string | |
| permissions: | |
| id-token: write # Required for OIDC | |
| contents: write | |
| pull-requests: write | |
| issues: write | |
| name: release-please | |
| jobs: | |
| release-please: | |
| if: ${{ github.event_name != 'workflow_dispatch' }} | |
| runs-on: ubuntu-latest | |
| outputs: | |
| # releases_created と paths_released を後続のジョブから参照できるようにする | |
| releases_created: ${{ steps.release.outputs.releases_created }} | |
| paths_released: ${{ steps.release.outputs.paths_released }} | |
| steps: | |
| - uses: googleapis/release-please-action@v4 | |
| id: release | |
| # リリースされたパッケージをnpm publishするジョブ | |
| publish: | |
| # release-pleaseジョブが完了してから実行 | |
| needs: release-please | |
| runs-on: ubuntu-latest | |
| # release-pleaseジョブでリリースが作成された場合にのみ実行 | |
| if: ${{ needs.release-please.outputs.releases_created == 'true' }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Update npm | |
| run: npm install -g npm@latest | |
| # `release-please`の出力からリリースされたパッケージを特定し、npm publishを実行 | |
| - name: Publish to npm | |
| run: | | |
| # paths_released をパースして、リリースされたパッケージをループ処理 | |
| PACKAGES_TO_PUBLISH=$(echo '${{ needs.release-please.outputs.paths_released }}' | jq -r '.[]') | |
| if [ -z "$PACKAGES_TO_PUBLISH" ]; then | |
| echo "No packages were released, skipping npm publish." | |
| exit 0 | |
| fi | |
| echo "Packages to publish: $PACKAGES_TO_PUBLISH" | |
| for package_path in $PACKAGES_TO_PUBLISH; do | |
| echo "Publishing $package_path..." | |
| cd "$package_path" | |
| npm publish | |
| cd - # 元のディレクトリに戻る | |
| done | |
| manual-publish: | |
| if: ${{ github.event_name == 'workflow_dispatch' }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write # npm publishに必要なOIDC認証のため(推奨) | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Update npm | |
| run: npm install -g npm@latest | |
| - name: Publish to NPM | |
| working-directory: ${{ github.event.inputs.package_folder }} | |
| env: | |
| DRY_RUN: ${{ github.event.inputs.dry_run }} | |
| run: | | |
| if [ "$DRY_RUN" = "true" ]; then | |
| npm publish --dry-run | |
| else | |
| npm publish | |
| fi |