Skip to content

Commit

Permalink
build: fix release-please workflow (#138)
Browse files Browse the repository at this point in the history
This should resolve the issue with release-please not properly tagging releases
  • Loading branch information
ywwg authored Mar 19, 2024
1 parent f3e6735 commit 4f6168c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/build-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ on:
release_tag_name:
required: true
type: string
release_title:
workflow_dispatch: # for manual testing
inputs:
release_tag_name:
required: true
type: string

Expand All @@ -14,7 +16,7 @@ permissions:
repository-projects: read

env:
DEFAULT_GO_VERSION: 1.21.8
DEFAULT_GO_VERSION: 1.21

name: Build Artifacts
jobs:
Expand All @@ -37,19 +39,20 @@ jobs:
uses: goreleaser/goreleaser-action@v4
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
distribution: goreleaser
version: latest
args: release --snapshot --clean
args: release --skip=publish,announce --clean

- name: Bundle release assets
uses: softprops/action-gh-release@v1
with:
draft: true
append_body: true
tag_name: ${{ inputs.release_tag_name }}
name: ${{ inputs.release_title }}
tag_name: ${{ inputs.release_tag_name }}
name: ${{ inputs.release_tag_name }}
files: |
README.md
CHANGELOG.md
./dist/*.tar.gz
./dist/*.tar.gz
35 changes: 27 additions & 8 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ permissions:
repository-projects: read

env:
DEFAULT_GO_VERSION: 1.21.8
DEFAULT_GO_VERSION: 1.21

name: Run Release Please
jobs:
Expand All @@ -19,20 +19,39 @@ jobs:
- uses: google-github-actions/release-please-action@v4
id: release
with:
release-type: go
command: manifest
token: ${{secrets.GITHUB_TOKEN}}
token: ${{ secrets.GITHUB_TOKEN }}
default-branch: main
outputs:
releases_created: ${{ steps.release.outputs.releases_created }}
release_tag_sha: ${{ steps.release.outputs.release_tag_sha }}
release_tag_name: ${{ steps.release.outputs.tag_name }}
release_title: >
${{ format('mimir-proxies: v{0}.{1}.{2}', steps.release.outputs.major, steps.release.outputs.minor, steps.release.outputs.patch) }}
call-workflow-build-artifacts:

# The docs say that release-please is supposed to tag releases automatically,
# but for some reason that never happens, so we do it manually.
tag-release:
needs: release-please
if: ${{ needs.release-please.outputs.releases_created }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Fetch all history for all tags and branches.
# Needed for the releaser to know what version to tag.
with:
fetch-depth: 0
- name: Tag the created release
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
git tag ${{ needs.release-please.outputs.release_tag_name }} ${{ needs.release-please.outputs.release_tag_sha }} -m ${{ needs.release-please.outputs.release_tag_name }}
git push origin ${{ needs.release-please.outputs.release_tag_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
call-workflow-build-artifacts:
needs: [release-please, tag-release]
if: ${{ needs.release-please.outputs.releases_created }}
uses: ./.github/workflows/build-artifacts.yml
with:
release_tag_name: ${{ needs.release-please.outputs.release_tag_name }}
release_title: ${{ needs.release-please.outputs.release_title }}
release_tag_name: ${{ needs.release-please.outputs.release_tag_name }}
secrets: inherit

0 comments on commit 4f6168c

Please sign in to comment.