-
Notifications
You must be signed in to change notification settings - Fork 1
Add reusable goreleaser-release workflow #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
monty-sei
wants to merge
1
commit into
main
Choose a base branch
from
monty/goreleaser-reusable-workflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| name: GoReleaser | ||
| run-name: UCI / GoReleaser Release | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| go-version: | ||
| description: "Go version. Mutually exclusive with go-version-file." | ||
| required: false | ||
| type: string | ||
| default: '' | ||
| go-version-file: | ||
| description: "Path to go.mod (or other) for Go version detection. Mutually exclusive with go-version." | ||
| required: false | ||
| type: string | ||
| default: '' | ||
| goreleaser-version: | ||
| description: "GoReleaser version expression (e.g. '~> v2', 'v2.4.4', 'latest', 'nightly')." | ||
| required: false | ||
| type: string | ||
| default: '~> v2' | ||
| args: | ||
| description: "Arguments passed to goreleaser." | ||
| required: false | ||
| type: string | ||
| default: 'release --clean' | ||
| working-directory: | ||
| description: "Repo subdirectory containing .goreleaser.yaml." | ||
| required: false | ||
| type: string | ||
| default: '.' | ||
| ref: | ||
| description: "Git ref to checkout. Empty checks out the triggering ref." | ||
| required: false | ||
| type: string | ||
| default: '' | ||
| checkout-latest-tag: | ||
| description: "After checkout, switch to the latest tag (sorted by v:refname). Useful when triggered by workflow_run." | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| submodules: | ||
| description: "Submodule checkout option, passed to actions/checkout (false | true | recursive)." | ||
| required: false | ||
| type: string | ||
| default: 'false' | ||
| fetch-depth: | ||
| description: "Fetch depth for actions/checkout. 0 = full history (required by GoReleaser to compute changelog)." | ||
| required: false | ||
| type: number | ||
| default: 0 | ||
| runs-on: | ||
| description: "Runner label." | ||
| required: false | ||
| type: string | ||
| default: 'ubuntu-latest' | ||
| prebuild-script: | ||
| description: "Inline shell run after checkout, before goreleaser. Use for system deps or per-repo prep." | ||
| required: false | ||
| type: string | ||
| default: '' | ||
| secrets: | ||
| UCI_GITHUB_TOKEN: | ||
| description: "Optional override for the token used to create the GitHub Release. Defaults to github.token." | ||
| required: false | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| goreleaser: | ||
| name: Publish | ||
| runs-on: ${{ inputs.runs-on }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: ${{ inputs.fetch-depth }} | ||
| ref: ${{ inputs.ref }} | ||
| submodules: ${{ inputs.submodules }} | ||
| - name: Checkout latest tag | ||
| if: inputs.checkout-latest-tag | ||
| run: | | ||
| git fetch origin --tags --force | ||
| LATEST_TAG=$(git tag --sort=-v:refname | head -n 1) | ||
| if [[ -z "${LATEST_TAG}" ]]; then | ||
| echo "::error::no tags present in repo" | ||
| exit 1 | ||
| fi | ||
| echo "Checking out latest tag: ${LATEST_TAG}" | ||
| git checkout "${LATEST_TAG}" | ||
| - name: Set up Go | ||
| uses: actions/setup-go@v6 | ||
| with: | ||
| go-version: ${{ inputs.go-version }} | ||
| go-version-file: ${{ inputs.go-version-file }} | ||
| - name: Run prebuild script | ||
| if: inputs.prebuild-script != '' | ||
| working-directory: ${{ inputs.working-directory }} | ||
| run: ${{ inputs.prebuild-script }} | ||
| - name: Run GoReleaser | ||
| uses: goreleaser/goreleaser-action@v6 | ||
| with: | ||
| distribution: goreleaser | ||
| version: ${{ inputs.goreleaser-version }} | ||
| args: ${{ inputs.args }} | ||
| workdir: ${{ inputs.working-directory }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN || github.token }} | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setup-goignoresworking-directoryfor Go version auto-detectionLow Severity
When a caller sets
working-directoryto a subdirectory (e.g. for a monorepo) but omits bothgo-versionandgo-version-file, thesetup-gostep will look forgo.modin the repository root — not in theworking-directory. The prebuild script and GoReleaser steps both honourworking-directory, butsetup-godoes not, so Go version auto-detection silently fails to find the module file in the subdirectory.Additional Locations (1)
.github/workflows/goreleaser-release.yml#L25-L30Reviewed by Cursor Bugbot for commit 2a19a88. Configure here.