Skip to content

Commit

Permalink
ci: publish Docker image before releasing (#91)
Browse files Browse the repository at this point in the history
Signed-off-by: Mogyuchi <[email protected]>
  • Loading branch information
Mogyuchi authored Feb 11, 2024
1 parent e48d9d2 commit 09b1eba
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/files/release-please/release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
72 changes: 65 additions & 7 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'

0 comments on commit 09b1eba

Please sign in to comment.