From c7152205ba9b6f3c8ef06eb8829e0d26a2dc8323 Mon Sep 17 00:00:00 2001 From: Mogyuchi Date: Thu, 21 Mar 2024 18:35:32 +0900 Subject: [PATCH] ci: fix release-please --- .github/workflows/release-please.yml | 34 ++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index a351400ac..fe003a9b7 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -1,8 +1,5 @@ name: release-please -env: - RELEASE_PLEASE_AUTHOR: github-actions[bot] - on: push: branches: ["main"] @@ -10,16 +7,13 @@ on: permissions: {} jobs: - release-please: + create-token: if: github.repository.fork == false - permissions: - contents: write - pull-requests: write + permissions: {} runs-on: ubuntu-latest outputs: - release_created: ${{ steps.release.outputs.release_created }} - tag_name: ${{ steps.release.outputs.tag_name }} - pr: ${{ steps.release.outputs.pr }} + token: ${{ steps.generate_token.outputs.token }} + app-name: ${{ format('{0}[bot]', steps.generate_token.outputs.app-slug) }} steps: - name: Generate a token id: generate_token @@ -27,13 +21,25 @@ jobs: with: app-id: ${{ secrets.MAZI_RELEASE_APP_ID }} private-key: ${{ secrets.MAZI_RELEASE_APP_PRIVATE_KEY }} + + release-please: + permissions: + contents: write + pull-requests: write + needs: [create-token] + runs-on: ubuntu-latest + outputs: + release_created: ${{ steps.release.outputs.release_created }} + tag_name: ${{ steps.release.outputs.tag_name }} + pr: ${{ steps.release.outputs.pr }} + steps: - uses: google-github-actions/release-please-action@cc61a07e2da466bebbc19b3a7dd01d6aecb20d1e # v4.0.2 id: release with: - token: ${{ steps.generate_token.outputs.token }} + token: ${{ needs.create-token.outputs.token }} config-file: .github/release-please/release-please-config.json manifest-file: .github/release-please/.release-please-manifest.json - skip-github-pull-request: ${{ startsWith(github.event.head_commit.message, 'release:') && github.event.head_commit.author.name == format('{0}[bot]', steps.generate_token.outputs.app-slug) }} + skip-github-pull-request: ${{ startsWith(github.event.head_commit.message, 'release:') && github.event.head_commit.author.name == needs.create-token.outputs.app-name }} publish-crates: needs: release-please @@ -81,7 +87,7 @@ jobs: echo "pr_number=$(printf "$HEAD_COMMIT_MESSAGE" | head -n1 | sed -nE 's/.+\(#([0-9]+)\)$/\1/p')" >> "$GITHUB_OUTPUT" update-release-comment: - needs: [release-please, publish-release, get-pr-number] + needs: [create-token, release-please, publish-release, get-pr-number] if: ${{ needs.release-please.outputs.release_created }} permissions: pull-requests: write @@ -91,7 +97,7 @@ jobs: id: fc with: issue-number: ${{ needs.get-pr-number.outputs.pr_number }} - comment-author: ${{ env.RELEASE_PLEASE_AUTHOR }} + comment-author: ${{ needs.create-token.outputs.app-name }} body-includes: ":robot: Release is at ${{ github.event.repository.html_url }}/releases/tag/untagged-" - if: steps.fc.conclusion == 'success' uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0