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
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ go.work.sum


releaseo

# GoReleaser
dist/
62 changes: 62 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
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
- -X main.version={{.Version}}
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}

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}}"
46 changes: 45 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,50 @@ outputs:
runs:
using: 'composite'
steps:
- name: Download releaseo binary
id: download
shell: bash
run: |
VERSION="${{ github.action_ref }}"

# Validate version is specified and is a tag (not a branch)
if [ -z "$VERSION" ]; then
echo "::error::No version specified. Please reference this action with a version tag (e.g., @v1.0.0)"
exit 1
fi

if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "::error::Invalid version '$VERSION'. Please use a semantic version tag (e.g., @v1.0.0). Using @main or @branch-name is not supported."
exit 1
fi

# 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}..."
echo "URL: ${ASSET_URL}"

if ! curl -sSL --fail -o releaseo.tar.gz "$ASSET_URL"; then
echo "::error::Failed to download releaseo ${VERSION}. Make sure the release exists at: 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
Expand All @@ -76,4 +120,4 @@ runs:
ARGS+=(--version-files="$VERSION_FILES_JSON")
fi

go run github.com/stacklok/releaseo@v1.0.11 "${ARGS[@]}"
./releaseo "${ARGS[@]}"