Skip to content

Commit

Permalink
ci: use zig for cross compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 committed Sep 18, 2023
1 parent 48fa7c7 commit 8c026df
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
tags:
- '**'
workflow_dispatch:

permissions:
contents: write
Expand All @@ -22,6 +23,10 @@ jobs:
with:
go-version: '1.21.x'
cache: true
- uses: goto-bus-stop/setup-zig@v2
with:
zig-version: '0.11.0'
cache: true
- uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
Expand Down
8 changes: 5 additions & 3 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ before:
- go mod tidy
- ./scripts/completions.sh
builds:
- env:
- CGO_ENABLED=0
goos:
- goos:
- linux
- windows
- darwin
Expand All @@ -21,6 +19,10 @@ builds:
- -X github.com/j178/leetgo/constants.Version={{.Version}}
- -X github.com/j178/leetgo/constants.Commit={{.Commit}}
- -X github.com/j178/leetgo/constants.BuildDate={{.Date}}
env:
- CGO_ENABLED=1
- 'CC=zig cc -target {{ if eq .Arch "amd64" }}x86_64{{ else if eq .Arch "arm64" }}aarch64{{ else }}{{ .Arch }}{{ end }}-{{ if eq .Os "darwin" }}macos{{ else }}{{ .Os }}{{ end }}'
- 'CXX=zig c++ -target {{ if eq .Arch "amd64" }}x86_64{{ else if eq .Arch "arm64" }}aarch64{{ else }}{{ .Arch }}{{ end }}-{{ if eq .Os "darwin" }}macos{{ else }}{{ .Os }}{{ end }}'

archives:
- format: tar.gz
Expand Down
2 changes: 1 addition & 1 deletion leetcode/cache_sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (c *sqliteCache) load() {
var err error
c.db, err = sql.Open("sqlite3", c.path)
if err != nil {
log.Error("failed to load cache, try updating with `leetgo cache update`")
log.Error("failed to load cache, try updating with `leetgo cache update`", "err", err)
return
}
if c.Outdated() {
Expand Down

0 comments on commit 8c026df

Please sign in to comment.