From 3144b5a5d6a30334d405491d226e13bcd64ae1e4 Mon Sep 17 00:00:00 2001 From: Chris Burns <29541485+ChrisJBurns@users.noreply.github.com> Date: Thu, 15 Jan 2026 23:59:53 +0000 Subject: [PATCH] Add binary distribution via GoReleaser Replace go run compilation with pre-built binary downloads for faster action execution. Users now specify `releaseo_version` input to select which release to use. Changes: - Add .goreleaser.yml for multi-platform binary builds - Add release workflow triggered by version tags - Update action.yml to download and run pre-built binary - Add releaseo_version input with validation - Update README examples and inputs table Co-Authored-By: Claude Opus 4.5 --- .github/workflows/release.yml | 37 ++++++++++++++++++++++ .gitignore | 3 ++ .goreleaser.yml | 58 +++++++++++++++++++++++++++++++++++ README.md | 5 +++ action.yml | 49 ++++++++++++++++++++++++++++- 5 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1b2a7f2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,37 @@ +name: Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + + - name: Run tests + run: go test -v -race ./... + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 8a75912..be9d7e1 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,6 @@ go.work.sum releaseo + +# GoReleaser +dist/ diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..c86244d --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,58 @@ +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +version: 2 + +project_name: releaseo + +before: + hooks: + - go mod tidy + +builds: + - id: releaseo + binary: releaseo + main: . + env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + goarch: + - amd64 + - arm64 + ldflags: + - -s -w + +archives: + - id: releaseo + format: tar.gz + name_template: >- + {{ .ProjectName }}_ + {{- .Version }}_ + {{- .Os }}_ + {{- .Arch }} + files: + - LICENSE + - README.md + +checksum: + name_template: 'checksums.txt' + algorithm: sha256 + +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + - '^ci:' + - '^chore:' + - Merge pull request + - Merge branch + +release: + github: + owner: stacklok + name: releaseo + draft: false + prerelease: auto + name_template: "{{.Tag}}" diff --git a/README.md b/README.md index d095fa7..82572cf 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ jobs: - name: Create Release PR uses: stacklok/releaseo@v1 with: + releaseo_version: v1.0.0 bump_type: ${{ inputs.bump_type }} token: ${{ secrets.GITHUB_TOKEN }} ``` @@ -81,6 +82,7 @@ jobs: - name: Create Release PR uses: stacklok/releaseo@v1 with: + releaseo_version: v1.0.0 bump_type: ${{ inputs.bump_type }} token: ${{ secrets.GITHUB_TOKEN }} version_files: | @@ -107,6 +109,7 @@ jobs: - name: Create Release PR uses: stacklok/releaseo@v1 with: + releaseo_version: v1.0.0 bump_type: ${{ inputs.bump_type }} token: ${{ secrets.GITHUB_TOKEN }} version_files: | @@ -124,6 +127,7 @@ jobs: id: release uses: stacklok/releaseo@v1 with: + releaseo_version: v1.0.0 bump_type: ${{ inputs.bump_type }} token: ${{ secrets.GITHUB_TOKEN }} @@ -138,6 +142,7 @@ jobs: | Input | Description | Required | Default | |-------|-------------|----------|---------| +| `releaseo_version` | Version of releaseo to use (e.g., `v1.0.0`) | Yes | - | | `bump_type` | Version bump type (`major`, `minor`, `patch`) | Yes | - | | `version_file` | Path to VERSION file | No | `VERSION` | | `version_files` | YAML list of files with paths to update (see below) | No | - | diff --git a/action.yml b/action.yml index 0317fcf..0f24bc5 100644 --- a/action.yml +++ b/action.yml @@ -7,6 +7,9 @@ branding: color: 'blue' inputs: + releaseo_version: + description: 'Version of releaseo to use (e.g., v1.0.0). Must match a GitHub release.' + required: true bump_type: description: 'Version bump type (major, minor, patch)' required: true @@ -54,6 +57,50 @@ outputs: runs: using: 'composite' steps: + - name: Validate version input + shell: bash + run: | + VERSION="${{ inputs.releaseo_version }}" + if [ -z "$VERSION" ]; then + echo "::error::The 'releaseo_version' input is required. Please specify the releaseo version (e.g., v1.0.0)" + exit 1 + fi + if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "::error::Invalid version format '$VERSION'. Please use semantic versioning (e.g., v1.0.0)" + exit 1 + fi + + - name: Download releaseo binary + shell: bash + run: | + VERSION="${{ inputs.releaseo_version }}" + + # Determine OS and architecture + OS=$(uname -s | tr '[:upper:]' '[:lower:]') + ARCH=$(uname -m) + case "$ARCH" in + x86_64) ARCH="amd64" ;; + aarch64|arm64) ARCH="arm64" ;; + *) echo "::error::Unsupported architecture: $ARCH"; exit 1 ;; + esac + + # Download the binary + ASSET_NAME="releaseo_${VERSION#v}_${OS}_${ARCH}.tar.gz" + ASSET_URL="https://github.com/stacklok/releaseo/releases/download/${VERSION}/${ASSET_NAME}" + + echo "Downloading releaseo ${VERSION} for ${OS}/${ARCH}..." + + if ! curl -sSL --fail -o releaseo.tar.gz "$ASSET_URL"; then + echo "::error::Failed to download releaseo ${VERSION}. Ensure the release exists: https://github.com/stacklok/releaseo/releases/tag/${VERSION}" + exit 1 + fi + + tar xzf releaseo.tar.gz + chmod +x releaseo + rm releaseo.tar.gz + + echo "Successfully downloaded releaseo ${VERSION}" + - name: Run releaseo id: releaseo shell: bash @@ -76,4 +123,4 @@ runs: ARGS+=(--version-files="$VERSION_FILES_JSON") fi - go run github.com/stacklok/releaseo@v1.0.11 "${ARGS[@]}" + ./releaseo "${ARGS[@]}"