ci: produce zip for windows build

main
鲁树人 1 month ago
parent b0998d8c8a
commit 57c1aa3e54

@ -17,21 +17,30 @@ local CreateRelease() = {
local StepGoBuild(GOOS, GOARCH) = {
local filepath = 'dist/um-%s-%s.tar.gz' % [GOOS, GOARCH],
local windows = GOOS == 'windows',
local archiveExt = if windows then 'zip' else 'tar.gz',
local filepath = 'dist/um-%s-%s.%s' % [GOOS, GOARCH, archiveExt],
local archive = if windows then [
// Ensure zip is installed
'command -v zip >/dev/null || (apt update && apt install -y zip)',
'zip -9 -j -r "%s" $DIST_DIR' % filepath,
] else [
'tar -zc -C $DIST_DIR um | gzip -9 > "%s"' % filepath,
],
name: 'go build %s/%s' % [GOOS, GOARCH],
image: 'golang:1.22',
environment: {
GOOS: GOOS,
GOARCH: GOARCH,
GOPROXY: "https://goproxy.io,direct",
GOPROXY: 'https://goproxy.io,direct',
},
commands: [
'DIST_DIR=$(mktemp -d)',
'go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags --always)" -o $DIST_DIR ./cmd/um',
'mkdir -p dist',
'tar cz -f %s -C $DIST_DIR .' % filepath,
],
] + archive,
};
local StepUploadArtifact(GOOS, GOARCH) = {
@ -71,7 +80,7 @@ local PipelineBuild(GOOS, GOARCH, RUN_TEST) = {
name: 'go test',
image: 'golang:1.22',
environment: {
GOPROXY: "https://goproxy.io,direct",
GOPROXY: 'https://goproxy.io,direct',
},
commands: ['go test -v ./...'],
}] else []
@ -100,7 +109,7 @@ local PipelineRelease() = {
name: 'go test',
image: 'golang:1.22',
environment: {
GOPROXY: "https://goproxy.io,direct",
GOPROXY: 'https://goproxy.io,direct',
},
commands: ['go test -v ./...'],
},

@ -17,7 +17,7 @@ steps:
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
--always)" -o $DIST_DIR ./cmd/um
- mkdir -p dist
- tar cz -f dist/um-linux-amd64.tar.gz -C $DIST_DIR .
- tar -zc -C $DIST_DIR um | gzip -9 > "dist/um-linux-amd64.tar.gz"
environment:
GOARCH: amd64
GOOS: linux
@ -53,7 +53,8 @@ steps:
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
--always)" -o $DIST_DIR ./cmd/um
- mkdir -p dist
- tar cz -f dist/um-windows-amd64.tar.gz -C $DIST_DIR .
- command -v zip >/dev/null || (apt update && apt install -y zip)
- zip -9 -j -r "dist/um-windows-amd64.zip" $DIST_DIR
environment:
GOARCH: amd64
GOOS: windows
@ -89,7 +90,7 @@ steps:
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
--always)" -o $DIST_DIR ./cmd/um
- mkdir -p dist
- tar cz -f dist/um-darwin-amd64.tar.gz -C $DIST_DIR .
- tar -zc -C $DIST_DIR um | gzip -9 > "dist/um-darwin-amd64.tar.gz"
environment:
GOARCH: amd64
GOOS: darwin
@ -131,7 +132,7 @@ steps:
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
--always)" -o $DIST_DIR ./cmd/um
- mkdir -p dist
- tar cz -f dist/um-linux-amd64.tar.gz -C $DIST_DIR .
- tar -zc -C $DIST_DIR um | gzip -9 > "dist/um-linux-amd64.tar.gz"
environment:
GOARCH: amd64
GOOS: linux
@ -143,7 +144,7 @@ steps:
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
--always)" -o $DIST_DIR ./cmd/um
- mkdir -p dist
- tar cz -f dist/um-linux-arm64.tar.gz -C $DIST_DIR .
- tar -zc -C $DIST_DIR um | gzip -9 > "dist/um-linux-arm64.tar.gz"
environment:
GOARCH: arm64
GOOS: linux
@ -155,7 +156,7 @@ steps:
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
--always)" -o $DIST_DIR ./cmd/um
- mkdir -p dist
- tar cz -f dist/um-linux-386.tar.gz -C $DIST_DIR .
- tar -zc -C $DIST_DIR um | gzip -9 > "dist/um-linux-386.tar.gz"
environment:
GOARCH: "386"
GOOS: linux
@ -167,7 +168,8 @@ steps:
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
--always)" -o $DIST_DIR ./cmd/um
- mkdir -p dist
- tar cz -f dist/um-windows-amd64.tar.gz -C $DIST_DIR .
- command -v zip >/dev/null || (apt update && apt install -y zip)
- zip -9 -j -r "dist/um-windows-amd64.zip" $DIST_DIR
environment:
GOARCH: amd64
GOOS: windows
@ -179,7 +181,8 @@ steps:
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
--always)" -o $DIST_DIR ./cmd/um
- mkdir -p dist
- tar cz -f dist/um-windows-386.tar.gz -C $DIST_DIR .
- command -v zip >/dev/null || (apt update && apt install -y zip)
- zip -9 -j -r "dist/um-windows-386.zip" $DIST_DIR
environment:
GOARCH: "386"
GOOS: windows
@ -191,7 +194,7 @@ steps:
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
--always)" -o $DIST_DIR ./cmd/um
- mkdir -p dist
- tar cz -f dist/um-darwin-amd64.tar.gz -C $DIST_DIR .
- tar -zc -C $DIST_DIR um | gzip -9 > "dist/um-darwin-amd64.tar.gz"
environment:
GOARCH: amd64
GOOS: darwin
@ -203,7 +206,7 @@ steps:
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
--always)" -o $DIST_DIR ./cmd/um
- mkdir -p dist
- tar cz -f dist/um-darwin-arm64.tar.gz -C $DIST_DIR .
- tar -zc -C $DIST_DIR um | gzip -9 > "dist/um-darwin-arm64.tar.gz"
environment:
GOARCH: arm64
GOOS: darwin

Loading…
Cancel
Save