Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion .github/workflows/go-build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
description: 'Container registry name (e.g., ghcr.io/openchami/project-name) to Generate build provenance for container'
required: true
type: string
snapshot:
description: 'Snapshot mode: auto (default - snapshot if not a tag), true (force snapshot), false (force regular release)'
required: false
type: string
default: 'auto'

permissions: write-all # Necessary for the generate-build-provenance action with containers

Expand Down Expand Up @@ -81,7 +86,7 @@
fetch-depth: ${{ inputs.fetch-depth }}

- name: Set build environment variables
run: |

Check failure on line 89 in .github/workflows/go-build-release.yml

View workflow job for this annotation

GitHub Actions / lint

shellcheck reported issue in this script: SC2086:info:4:32: Double quote to prevent globbing and word splitting

Check failure on line 89 in .github/workflows/go-build-release.yml

View workflow job for this annotation

GitHub Actions / lint

shellcheck reported issue in this script: SC2086:info:3:55: Double quote to prevent globbing and word splitting

Check failure on line 89 in .github/workflows/go-build-release.yml

View workflow job for this annotation

GitHub Actions / lint

shellcheck reported issue in this script: SC2086:info:2:34: Double quote to prevent globbing and word splitting

Check failure on line 89 in .github/workflows/go-build-release.yml

View workflow job for this annotation

GitHub Actions / lint

shellcheck reported issue in this script: SC2086:info:1:100: Double quote to prevent globbing and word splitting

Check failure on line 89 in .github/workflows/go-build-release.yml

View workflow job for this annotation

GitHub Actions / lint

shellcheck reported issue in this script: SC2129:style:1:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects
echo "GIT_STATE=$(if git diff-index --quiet HEAD --; then echo 'clean'; else echo 'dirty'; fi)" >> $GITHUB_ENV
echo "BUILD_HOST=$(hostname)" >> $GITHUB_ENV
echo "GO_VERSION=$(go version | awk '{print $3}')" >> $GITHUB_ENV
Expand All @@ -89,7 +94,7 @@

- name: Set CGO_ENABLED if specified
if: ${{ inputs.cgo-enabled != '' }}
run: echo "CGO_ENABLED=${{ inputs.cgo-enabled }}" >> $GITHUB_ENV

Check failure on line 97 in .github/workflows/go-build-release.yml

View workflow job for this annotation

GitHub Actions / lint

shellcheck reported issue in this script: SC2086:info:1:49: Double quote to prevent globbing and word splitting

- name: Set additional environment variables
if: ${{ inputs.additional-env-vars != '' }}
Expand All @@ -105,13 +110,29 @@
if: ${{ inputs.pre-build-commands != '' }}
run: ${{ inputs.pre-build-commands }}

- name: Determine snapshot flags
id: snapshot_flags
run: |
if [[ "${{ inputs.snapshot }}" == "true" ]]; then
echo "flags=--snapshot" >> $GITHUB_OUTPUT
elif [[ "${{ inputs.snapshot }}" == "false" ]]; then
echo "flags=" >> $GITHUB_OUTPUT
else
# auto mode - snapshot if not a tag
if [[ "${{ github.ref }}" != refs/tags/v* ]]; then
echo "flags=--snapshot" >> $GITHUB_OUTPUT
else
echo "flags=" >> $GITHUB_OUTPUT
fi
fi

- name: Release with GoReleaser
uses: goreleaser/goreleaser-action@v6
env:
GITHUB_TOKEN: ${{ github.token }}
with:
version: ${{ inputs.goreleaser-version }}
args: ${{ inputs.goreleaser-args }}
args: ${{ inputs.goreleaser-args }} ${{ steps.snapshot_flags.outputs.flags }}
id: goreleaser

- name: Process GoReleaser output
Expand Down
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Use major version tags for stability:
# For reusable workflows
jobs:
release:
uses: OpenCHAMI/github-actions/.github/workflows/go-build-release.yml@v2
uses: OpenCHAMI/github-actions/.github/workflows/go-build-release.yml@v3.1
```

Pin a commit SHA internally for maximum supply‑chain safety if desired.
Expand All @@ -34,12 +34,22 @@ Standardized GoReleaser workflow for building and releasing Go applications with
- Wraps `goreleaser-action` action with all .gorelease.yaml configurations
- Container image builds and publishing
- Binary and container attestation/signing
- Snapshot builds on pull requests

**Usage:**
```yaml
name: Release with goreleaser

on:
workflow_dispatch:
pull_request:
push:
tags:
- v*

jobs:
release:
uses: OpenCHAMI/github-actions/.github/workflows/go-build-release.yml@v2
uses: OpenCHAMI/github-actions/.github/workflows/go-build-release.yml@v3.1
with:
pre-build-commands: |
go install github.com/swaggo/swag/cmd/swag@latest
Expand All @@ -48,11 +58,7 @@ jobs:

```

<<<<<<< HEAD
See the [workflow](workflows/go-build-release.yml) for additional input parameters.
=======
**Documentation:** [docs/go-build-release.md](docs/go-build-release.md)
**Examples:** [examples/](examples/)
See the [workflow](.github/workflows/go-build-release.yml) for additional input parameters.

### gpg-ephemeral-key
Generates a short‑lived RSA key (default 3072‑bit, 1 day) using an isolated `GNUPGHOME`, signs it with a repo‑scoped subkey you provide, and outputs:
Expand Down
Loading