diff --git a/.github/files/release-please/release-please-config.json b/.github/files/release-please/release-please-config.json index 872afbd..b00d182 100644 --- a/.github/files/release-please/release-please-config.json +++ b/.github/files/release-please/release-please-config.json @@ -68,7 +68,7 @@ "release-type": "rust", "bump-minor-pre-major": true, "bump-patch-for-minor-pre-major": false, - "draft": false, + "draft": true, "prerelease": false, "include-component-in-tag": false, "pull-request-title-pattern": "release: v${version}" diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 155a0eb..4d3fc41 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -27,6 +27,9 @@ jobs: token: ${{ steps.generate_token.outputs.token }} config-file: .github/files/release-please/release-please-config.json manifest-file: .github/files/release-please/.release-please-manifest.json + skip-github-pull-request: + ${{ startsWith(github.event.head_commit.message, 'release:') && + github.event.head_commit.author.name == 'mazi-release[bot]' }} docker-publish: needs: release-please @@ -38,29 +41,84 @@ jobs: with: tag-name: ${{ needs.release-please.outputs.tag_name }} - follow_up-pr: + publish-release: needs: [release-please, docker-publish] if: ${{ needs.release-please.outputs.release_created }} permissions: - pull-requests: write + contents: write env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_REPO: ${{ github.repository }} runs-on: ubuntu-latest steps: - - name: Create published label - run: | - gh label create 'autorelease: published' --color=EDEDED || true + - run: gh release edit ${{ needs.release-please.outputs.tag_name }} --draft=false + + get-pr-number: + needs: [release-please] + if: ${{ needs.release-please.outputs.release_created }} + permissions: {} + runs-on: ubuntu-latest + outputs: + pr_number: ${{ steps.pr-number.outputs.pr_number }} + steps: - name: Get PR number id: pr-number run: | echo "pr_number=$(printf '${{ github.event.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] + if: ${{ needs.release-please.outputs.release_created }} + permissions: + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: peter-evans/find-comment@d5fe37641ad8451bdd80312415672ba26c86575e # v3.0.0 + id: fc + with: + issue-number: ${{ needs.get-pr-number.outputs.pr_number }} + comment-author: "github-actions[bot]" + 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 + with: + token: ${{ secrets.GITHUB_TOKEN }} + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ needs.get-pr-number.outputs.pr_number }} + body: | + :robot: Release is at ${{ github.event.repository.html_url }}/releases/tag/${{ needs.release-please.outputs.tag_name }} :sunflower: + edit-mode: replace + + add-docker-comment: + needs: [release-please, docker-publish, get-pr-number] + if: ${{ needs.release-please.outputs.release_created }} + permissions: + pull-requests: write + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + runs-on: ubuntu-latest + steps: - name: Add comment to PR run: | printf ':robot: Successfully published to ${{ needs.docker-publish.outputs.image_url }} :truck:\n```\n${{ join(needs.docker-publish.outputs.image_tags, '\n') }}\n```' \ - | gh pr comment ${{ steps.pr-number.outputs.pr_number }} --body-file=- + | gh pr comment ${{ needs.get-pr-number.outputs.pr_number }} --body-file=- + + label-published: + needs: [release-please, publish-release, get-pr-number] + if: ${{ needs.release-please.outputs.release_created }} + permissions: + pull-requests: write + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + runs-on: ubuntu-latest + steps: + - name: Create published label + run: | + gh label create 'autorelease: published' --color=EDEDED || true - name: Change labels on PR run: | - gh pr edit ${{ steps.pr-number.outputs.pr_number }} \ + gh pr edit ${{ needs.get-pr-number.outputs.pr_number }} \ --remove-label='autorelease: tagged' \ --add-label='autorelease: published'