Skip to content

Commit e0c690c

Browse files
committed
feat(release): add GoReleaser with homebrew and scoop distribution
1 parent 6560cdc commit e0c690c

2 files changed

Lines changed: 141 additions & 136 deletions

File tree

.github/workflows/release.yml

Lines changed: 12 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -9,152 +9,28 @@ permissions:
99
contents: write
1010

1111
jobs:
12-
build:
12+
release:
1313
runs-on: ubuntu-latest
14-
strategy:
15-
fail-fast: false
16-
matrix:
17-
include:
18-
- os: darwin
19-
arch: arm64
20-
- os: darwin
21-
arch: amd64
22-
- os: linux
23-
arch: amd64
24-
- os: linux
25-
arch: arm64
26-
- os: windows
27-
arch: amd64
2814
steps:
29-
- name: Checkout code
30-
uses: actions/checkout@v4
15+
- uses: actions/checkout@v6
3116
with:
3217
fetch-depth: 0
3318

34-
- name: Checkout cimis-tsdb
35-
uses: actions/checkout@v4
36-
with:
37-
repository: dl-alexandre/cimis-tsdb
38-
token: ${{ secrets.GH_PAT }}
39-
path: _deps/cimis-tsdb
40-
4119
- name: Set up Go
42-
uses: actions/setup-go@v5
20+
uses: actions/setup-go@v6
4321
with:
4422
go-version-file: 'go.mod'
45-
cache: true
46-
47-
- name: Build binaries
48-
env:
49-
GOOS: ${{ matrix.os }}
50-
GOARCH: ${{ matrix.arch }}
51-
run: |
52-
mkdir -p dist
53-
LDFLAGS="-s -w -X main.Version=${GITHUB_REF#refs/tags/}"
54-
if [ "${{ matrix.os }}" = "windows" ]; then
55-
CGO_ENABLED=0 go build -ldflags="${LDFLAGS}" -o dist/cimis-${{ matrix.os }}-${{ matrix.arch }}.exe ./cmd/cimis
56-
else
57-
CGO_ENABLED=0 go build -ldflags="${LDFLAGS}" -o dist/cimis-${{ matrix.os }}-${{ matrix.arch }} ./cmd/cimis
58-
fi
59-
60-
- name: Package
61-
run: |
62-
cd dist
63-
if [ "${{ matrix.os }}" = "windows" ]; then
64-
mv cimis-${{ matrix.os }}-${{ matrix.arch }}.exe cimis.exe
65-
zip cimis-${{ matrix.os }}-${{ matrix.arch }}.zip cimis.exe
66-
rm cimis.exe
67-
else
68-
mv cimis-${{ matrix.os }}-${{ matrix.arch }} cimis
69-
tar -czf cimis-${{ matrix.os }}-${{ matrix.arch }}.tar.gz cimis
70-
rm cimis
71-
fi
72-
73-
- name: Upload artifact
74-
uses: actions/upload-artifact@v4
75-
with:
76-
name: cimis-${{ matrix.os }}-${{ matrix.arch }}
77-
path: dist/*
78-
retention-days: 1
79-
80-
release:
81-
needs: build
82-
runs-on: ubuntu-latest
83-
steps:
84-
- name: Download all artifacts
85-
uses: actions/download-artifact@v4
86-
with:
87-
path: dist
88-
pattern: cimis-*
89-
merge-multiple: true
9023

91-
- name: Generate checksums
92-
run: |
93-
cd dist
94-
sha256sum cimis-* > checksums.txt
24+
- name: Run tests
25+
run: go test ./...
9526

96-
- name: Create GitHub Release
97-
uses: softprops/action-gh-release@v2
27+
- name: Run GoReleaser
28+
uses: goreleaser/goreleaser-action@v7
9829
with:
99-
files: dist/*
100-
generate_release_notes: true
30+
distribution: goreleaser
31+
version: '~> v2'
32+
args: release --clean
10133
env:
10234
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103-
104-
- name: Update Homebrew Tap
105-
env:
106-
TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}
107-
run: |
108-
VERSION=${GITHUB_REF#refs/tags/}
109-
SHA256_ARM64=$(sha256sum dist/cimis-darwin-arm64.tar.gz | awk '{print $1}')
110-
SHA256_AMD64=$(sha256sum dist/cimis-darwin-amd64.tar.gz | awk '{print $1}')
111-
SHA256_LINUX_ARM64=$(sha256sum dist/cimis-linux-arm64.tar.gz | awk '{print $1}')
112-
SHA256_LINUX_AMD64=$(sha256sum dist/cimis-linux-amd64.tar.gz | awk '{print $1}')
113-
114-
git clone https://x-access-token:${TAP_GITHUB_TOKEN}@github.com/dl-alexandre/homebrew-tap.git tap-repo
115-
cd tap-repo
116-
117-
cat > Formula/cimis.rb << EOF
118-
class Cimis < Formula
119-
desc "CIMIS time-series database CLI tool with streaming and querying support"
120-
homepage "https://github.com/dl-alexandre/cimis-cli"
121-
version "${VERSION}"
122-
license "MIT"
123-
124-
on_macos do
125-
if Hardware::CPU.arm?
126-
url "https://github.com/dl-alexandre/cimis-cli/releases/download/${VERSION}/cimis-darwin-arm64.tar.gz"
127-
sha256 "${SHA256_ARM64}"
128-
end
129-
if Hardware::CPU.intel?
130-
url "https://github.com/dl-alexandre/cimis-cli/releases/download/${VERSION}/cimis-darwin-amd64.tar.gz"
131-
sha256 "${SHA256_AMD64}"
132-
end
133-
end
134-
135-
on_linux do
136-
if Hardware::CPU.arm?
137-
url "https://github.com/dl-alexandre/cimis-cli/releases/download/${VERSION}/cimis-linux-arm64.tar.gz"
138-
sha256 "${SHA256_LINUX_ARM64}"
139-
end
140-
if Hardware::CPU.intel?
141-
url "https://github.com/dl-alexandre/cimis-cli/releases/download/${VERSION}/cimis-linux-amd64.tar.gz"
142-
sha256 "${SHA256_LINUX_AMD64}"
143-
end
144-
end
145-
146-
def install
147-
bin.install "cimis"
148-
end
149-
150-
test do
151-
system "#{bin}/cimis", "version"
152-
end
153-
end
154-
EOF
155-
156-
git config user.name "github-actions[bot]"
157-
git config user.email "github-actions[bot]@users.noreply.github.com"
158-
git add Formula/cimis.rb
159-
git commit -m "Update cimis to ${VERSION}"
160-
git push
35+
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
36+
SCOOP_BUCKET_TOKEN: ${{ secrets.SCOOP_BUCKET_TOKEN }}

.goreleaser.yml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# GoReleaser configuration
2+
# Documentation: https://goreleaser.com
3+
4+
version: 2
5+
6+
project_name: cimis
7+
8+
before:
9+
hooks:
10+
- go mod tidy
11+
- go mod verify
12+
- go test ./...
13+
14+
builds:
15+
- id: cimis
16+
main: ./cmd/cimis
17+
binary: cimis
18+
env:
19+
- CGO_ENABLED=0
20+
goos:
21+
- linux
22+
- darwin
23+
- windows
24+
goarch:
25+
- amd64
26+
- arm64
27+
ldflags:
28+
- -s -w
29+
- -X main.version={{.Version}}
30+
- -X main.gitCommit={{.Commit}}
31+
- -X main.buildTime={{.Date}}
32+
flags:
33+
- -trimpath
34+
35+
archives:
36+
- id: cimis
37+
name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"
38+
format: tar.gz
39+
format_overrides:
40+
- goos: windows
41+
format: zip
42+
files:
43+
- LICENSE
44+
- README.md
45+
- CHANGELOG.md
46+
47+
checksum:
48+
name_template: "checksums.txt"
49+
algorithm: sha256
50+
51+
changelog:
52+
sort: asc
53+
use: github
54+
filters:
55+
exclude:
56+
- "^docs:"
57+
- "^test:"
58+
- "^chore:"
59+
- "^ci:"
60+
- Merge pull request
61+
- Merge branch
62+
63+
release:
64+
github:
65+
owner: dl-alexandre
66+
name: cimis-cli
67+
draft: false
68+
prerelease: auto
69+
name_template: "v{{.Version}}"
70+
header: |
71+
## CIMIS CLI v{{.Version}}
72+
73+
Full Changelog: https://github.com/dl-alexandre/cimis-cli/compare/{{.PreviousTag}}...v{{.Version}}
74+
footer: |
75+
## Installation
76+
77+
### Binary Download
78+
Download the appropriate binary for your platform from the assets below.
79+
80+
### Verification
81+
Verify checksums:
82+
```bash
83+
sha256sum -c checksums.txt
84+
```
85+
86+
# Homebrew tap configuration
87+
brews:
88+
- name: cimis
89+
repository:
90+
owner: dl-alexandre
91+
name: homebrew-tap
92+
token: "{{ .Env.HOMEBREW_TAP_TOKEN }}"
93+
branch: master
94+
pull_request:
95+
enabled: false
96+
commit_author:
97+
name: goreleaserbot
98+
email: goreleaser@carlosbecker.com
99+
commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}"
100+
directory: Formula
101+
description: "CLI for California Irrigation Management Information System (CIMIS) weather data"
102+
homepage: "https://github.com/dl-alexandre/cimis-cli"
103+
license: "MIT"
104+
skip_upload: "{{ if index .Env \"HOMEBREW_TAP_TOKEN\" }}false{{ else }}true{{ end }}"
105+
test: |
106+
system "#{bin}/cimis", "version"
107+
install: |
108+
bin.install "cimis"
109+
110+
# Scoop configuration for Windows
111+
scoops:
112+
- repository:
113+
owner: dl-alexandre
114+
name: scoop-bucket
115+
token: "{{ .Env.SCOOP_BUCKET_TOKEN }}"
116+
branch: main
117+
pull_request:
118+
enabled: false
119+
commit_author:
120+
name: goreleaserbot
121+
email: goreleaser@carlosbecker.com
122+
commit_msg_template: "Scoop update for {{ .ProjectName }} version {{ .Tag }}"
123+
directory: bucket
124+
description: "CLI for California Irrigation Management Information System (CIMIS) weather data"
125+
homepage: "https://github.com/dl-alexandre/cimis-cli"
126+
license: MIT
127+
skip_upload: "{{ if index .Env \"SCOOP_BUCKET_TOKEN\" }}false{{ else }}true{{ end }}"
128+
persist:
129+
- "config.yaml"

0 commit comments

Comments
 (0)