fix(ci): add go mod download + use make cross in release workflow to fix missing go.sum errors during cross-platform builds
This commit is contained in:
parent
1d2dfc1c8d
commit
b483eab827
@ -23,22 +23,26 @@ jobs:
|
||||
with:
|
||||
go-version: '1.24'
|
||||
|
||||
- name: Cache Go modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
|
||||
- name: Download Go modules
|
||||
run: go mod download
|
||||
|
||||
- name: Build for multiple platforms
|
||||
run: |
|
||||
VERSION=${GITHUB_REF#refs/tags/}
|
||||
COMMIT=$(git rev-parse --short HEAD)
|
||||
DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||
mkdir -p build
|
||||
for plat in 'linux/amd64' 'linux/arm64' 'darwin/amd64' 'darwin/arm64' 'windows/amd64'; do
|
||||
IFS='/' read -r OS ARCH <<< "$plat"
|
||||
BIN="gostations-${OS}-${ARCH}"
|
||||
if [ "$OS" = "windows" ]; then BIN="${BIN}.exe"; fi
|
||||
GOOS="$OS" GOARCH="$ARCH" go build -trimpath -ldflags "-s -w \
|
||||
-X 'github.com/gmgauthier/gostations/internal/version.Version=${VERSION}' \
|
||||
-X 'github.com/gmgauthier/gostations/internal/version.Commit=${COMMIT}' \
|
||||
-X 'github.com/gmgauthier/gostations/internal/version.BuildDate=${DATE}' \
|
||||
-X 'main.version=${VERSION}'" -o "build/${BIN}" .
|
||||
done
|
||||
make cross VERSION="$VERSION" COMMIT="$COMMIT" DATE="$DATE"
|
||||
# make cross (with deps) handles the loop + ldflags
|
||||
|
||||
|
||||
|
||||
- name: Prepare assets
|
||||
run: |
|
||||
|
||||
7
Makefile
7
Makefile
@ -28,7 +28,10 @@ lint:
|
||||
@which golangci-lint > /dev/null || (echo "❌ golangci-lint not found. Install with:" && echo " go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest" && exit 1)
|
||||
golangci-lint run
|
||||
|
||||
build:
|
||||
deps:
|
||||
go mod download
|
||||
|
||||
build: deps
|
||||
@mkdir -p build
|
||||
go build -trimpath -ldflags "$(LDFLAGS)" -o build/gostations .
|
||||
@echo "✅ Dev build: VERSION=$(VERSION) COMMIT=$(COMMIT) DATE=$(DATE)"
|
||||
@ -44,7 +47,7 @@ clean:
|
||||
rm -rf build/
|
||||
|
||||
# Cross compile (used by release workflow)
|
||||
cross:
|
||||
cross: deps
|
||||
@mkdir -p build
|
||||
@for plat in 'linux/amd64' 'linux/arm64' 'darwin/amd64' 'darwin/arm64' 'windows/amd64'; do \
|
||||
IFS='/' read -r OS ARCH <<< "$$plat"; \
|
||||
|
||||
Loading…
Reference in New Issue
Block a user