Skip to content

Commit

Permalink
goreleaser experiment
Browse files Browse the repository at this point in the history
Signed-off-by: Kent Rancourt <[email protected]>
  • Loading branch information
krancour committed Dec 13, 2024
1 parent d77a544 commit 3f9b868
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 33 deletions.
48 changes: 15 additions & 33 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Release

on:
release:
types:
types:
- created
schedule:
- cron: '0 1 * * 1-5' # 1 AM UTC is 5 PM PST/ 6 PM PDT
Expand Down Expand Up @@ -178,26 +178,21 @@ jobs:
runs-on: ubuntu-latest
container:
image: golang:1.23.4-bookworm
strategy:
matrix:
os: [linux, darwin, windows]
arch: [amd64, arm64]
outputs:
hash-linux-amd64: ${{ steps.hash.outputs.hash-linux-amd64 }}
hash-linux-arm64: ${{ steps.hash.outputs.hash-linux-arm64 }}
hash-darwin-amd64: ${{ steps.hash.outputs.hash-darwin-amd64 }}
hash-darwin-arm64: ${{ steps.hash.outputs.hash-darwin-arm64 }}
hash-windows-amd64: ${{ steps.hash.outputs.hash-windows-amd64 }}
hash-windows-arm64: ${{ steps.hash.outputs.hash-windows-arm64 }}
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: /go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Set safe directory for Git
run: |
echo $GITHUB_WORKSPACE
git config --global --add safe.directory $GITHUB_WORKSPACE
- name: Install pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
Expand All @@ -215,27 +210,15 @@ jobs:
run: |
pnpm install
NODE_ENV=production pnpm run build
rm -rf ../internal/api/ui
mv build ../internal/api/ui
- name: Build CLI
mv build/* ../internal/api/ui
- name: Build and Publish CLI
uses: goreleaser/goreleaser-action@v6
with:
version: v2.4.8
args: release --clean
env:
GOFLAGS: -buildvcs=false
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
VERSION: ${{ github.ref_name }}
GIT_COMMIT: ${{ github.sha }}
GIT_TREE_STATE: clean
run: make build-cli
- name: Publish CLI
uses: svenstaro/upload-release-action@v2
with:
file: bin/*
file_glob: true
repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: Generate subject
id: hash
run: |
echo "hash-${{ matrix.os }}-${{ matrix.arch }}=$(sha256sum bin/kargo* | awk -F 'bin/' '{print $1 $2}'| base64 -w0)" >> "$GITHUB_OUTPUT"
GITHUB_TOKEN: ${{ secrets.TAP_PAT }}

publish-unstable-cli:
needs: publish-image
Expand Down Expand Up @@ -276,8 +259,7 @@ jobs:
run: |
pnpm install
NODE_ENV=production pnpm run build
rm -rf ../internal/api/ui
mv build ../internal/api/ui
mv build/* ../internal/api/ui
- name: Build CLI
env:
GOFLAGS: -buildvcs=false
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ bin/
build/
charts/kargo/*.tgz
coverage.txt
dist/
hack/include/
pkg/api/v1alpha1/
vendor/
Expand Down
47 changes: 47 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: 2
project_name: kargo
builds:
- id: kargo
main: ./cmd/cli
goos:
- darwin
- linux
- windows
goarch:
- amd64
- arm64
ignore:
- goos: windows
goarch: arm64
env:
- CGO_ENABLED=0
- VERSION_PACKAGE=github.com/akuity/kargo/internal/version
ldflags:
- "-s -w -X {{ .Env.VERSION_PACKAGE }}.version=v{{ .Version }} -X {{ .Env.VERSION_PACKAGE }}.gitCommit={{ .Commit }} -X {{ .Env.VERSION_PACKAGE }}.buildDate={{ .Date }} -X {{ .Env.VERSION_PACKAGE }}.gitTreeState={{ .Env.GIT_TREE_STATE }}"
no_unique_dist_dir: true
binary: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"
archives:
- format: binary
name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"
release:
github:
owner: krancour
name: "{{ .ProjectName }}"
brews:
- directory: Formula
name: "{{ .ProjectName }}"
description: CLI for Kargo
homepage: https://kargo.io
license: Apache-2.0
install: |
bin.install "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}" => "{{ .ProjectName }}"
test: |
assert_match "Client Version: v#{version}", shell_output("#{bin}/{{ .ProjectName }} version --client")
repository:
owner: krancour
name: homebrew-tap
branch: "{{.ProjectName}}-{{.Version}}"
pull_request:
enabled: true
base:
branch: main

0 comments on commit 3f9b868

Please sign in to comment.