Skip to content

Commit

Permalink
chore: add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyasbhat0 committed Jul 27, 2023
1 parent ecb8e96 commit c226f24
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 18 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: goreleaser

on:
push:
# Sequence of patterns matched against refs/heads
branches-ignore:
- main

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Fetch all tags
run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
tag: ${{ env.GITHUB_REF_NAME }}
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}
53 changes: 35 additions & 18 deletions cli/.goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,32 @@ before:
- go generate ./...
- go build
builds:
- binary: "dive"
- id: cli
binary: "dive"
env:
- CGO_ENABLED=0
- CGO_ENABLED={{ if eq .Os "windows" }}0{{ else }}1{{ end }}
# Only override compilers if we are on CI, otherwise use the locally available C/C++ toolchain
- >-
{{- if index .Env "CI" }}
{{- if eq .Os "darwin" }}CC=o64h-clang{{- end }}
{{- if eq .Os "linux" }}
{{- if eq .Arch "amd64"}}CC=x86_64-linux-musl-gcc{{- end }}
{{- if eq .Arch "arm64"}}CC=aarch64-linux-musl-gcc{{- end }}
{{- end }}
{{- end }}
- >-
{{- if index .Env "CI" }}
{{- if eq .Os "darwin" }}CXX=o64h-clang++{{- end }}
{{- if eq .Os "linux" }}
{{- if eq .Arch "amd64"}}CXX=x86_64-linux-musl-g++{{- end }}
{{- if eq .Arch "arm64"}}CXX=aarch64-linux-musl-g++{{- end }}
{{- end }}
{{- end }}
ldflags:
- >-
{{- if eq .Os "linux" }}-linkmode external -extldflags "-static"{{- end }}
tags:
- osusergo
goos:
- linux
- windows
Expand All @@ -20,23 +43,15 @@ builds:
- arm64

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of uname.
name_template: >-
{{ tolower .ProjectName }}_
{{- tolower .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}_{{ .Tag }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip

- id: cli
builds:
- cli
name_template: dive-cli_{{ .Tag }}_{{ tolower .Os }}_{{ .Arch }}
brews:
# creates a brew formula representing the latest version
- name: dive-cli
ids:
- cli
tap:
owner: hugobyte
name: homebrew-tap
Expand All @@ -54,14 +69,16 @@ brews:
# creates a versioned brew formula, enabling installation of specific versions of kurtosis cli
- name: dive-cli@{{ .Tag }}
ids:
- cli
tap:
owner: hugobyte
name: homebrew-tap
commit_author:
name: shreyasbhat0
commit_msg_template: "Automated formula created for the CLI, version {{ .Tag }}"
homepage: "https://www.kurtosistech.com"
description: "CLI for managing Kurtosis environments."
homepage: "https://hugobyte.com"
description: "CLI for Dive Package"
license: "Apache 2.0"
# NOTE: Goreleaser *should* automatically detect the binaries packaged inside the archives being installed by the Homebrew formula, but it doesn't due to:
# https://github.com/goreleaser/goreleaser/issues/2488
Expand Down

0 comments on commit c226f24

Please sign in to comment.