ci: produce zip for windows build
Some checks reported errors
continuous-integration/drone/push Build encountered an error

This commit is contained in:
鲁树人 2024-10-21 05:46:52 +09:00
parent ec24497a1c
commit ce9379d166
2 changed files with 235 additions and 232 deletions

View File

@ -17,21 +17,28 @@ local CreateRelease() = {
local StepGoBuild(GOOS, GOARCH) = {
local filepath = 'dist/um-%s-%s.tar.gz' % [GOOS, GOARCH],
local archiveExt = if GOOS == 'windows' then 'zip' else 'tar.gz',
local filepath = 'dist/um-%s-%s.%s' % [GOOS, GOARCH, archiveExt],
// run zip or tar command depending on GOOS been windows or other
local archive = if GOOS == 'windows' then [
'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 +78,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 +107,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 ./...'],
},

View File

@ -1,32 +1,31 @@
---
kind: pipeline
name: build linux/amd64
steps:
- commands:
- kind: pipeline
name: build linux/amd64
steps:
- commands:
- git fetch --tags
image: alpine/git
name: fetch tags
- commands:
- commands:
- go test -v ./...
environment:
GOPROXY: https://goproxy.io,direct
image: golang:1.22
name: go test
- commands:
- commands:
- DIST_DIR=$(mktemp -d)
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
--always)" -o $DIST_DIR ./cmd/um
- 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
GOPROXY: https://goproxy.io,direct
image: golang:1.22
name: go build linux/amd64
- commands:
- curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file "dist/um-linux-amd64.tar.gz"
"$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}/um-linux-amd64.tar.gz"
- commands:
- curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file
"dist/um-linux-amd64.tar.gz" "$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}/um-linux-amd64.tar.gz"
- sha256sum dist/um-linux-amd64.tar.gz
- echo $DRONE_GITEA_SERVER/${DRONE_REPO_NAMESPACE}/-/packages/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}
environment:
@ -35,34 +34,33 @@ steps:
from_secret: GITEA_API_KEY
image: golang:1.22
name: upload artifact
trigger:
trigger:
event:
- push
- pull_request
type: docker
---
kind: pipeline
name: build windows/amd64
steps:
- commands:
type: docker
- kind: pipeline
name: build windows/amd64
steps:
- commands:
- git fetch --tags
image: alpine/git
name: fetch tags
- commands:
- commands:
- DIST_DIR=$(mktemp -d)
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
--always)" -o $DIST_DIR ./cmd/um
- 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 .
- zip -9 -j -r "dist/um-windows-amd64.zip" $DIST_DIR
environment:
GOARCH: amd64
GOOS: windows
GOPROXY: https://goproxy.io,direct
image: golang:1.22
name: go build windows/amd64
- commands:
- curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file "dist/um-windows-amd64.tar.gz"
"$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}/um-windows-amd64.tar.gz"
- commands:
- curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file
"dist/um-windows-amd64.tar.gz" "$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}/um-windows-amd64.tar.gz"
- sha256sum dist/um-windows-amd64.tar.gz
- echo $DRONE_GITEA_SERVER/${DRONE_REPO_NAMESPACE}/-/packages/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}
environment:
@ -71,34 +69,33 @@ steps:
from_secret: GITEA_API_KEY
image: golang:1.22
name: upload artifact
trigger:
trigger:
event:
- push
- pull_request
type: docker
---
kind: pipeline
name: build darwin/amd64
steps:
- commands:
type: docker
- kind: pipeline
name: build darwin/amd64
steps:
- commands:
- git fetch --tags
image: alpine/git
name: fetch tags
- commands:
- commands:
- DIST_DIR=$(mktemp -d)
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
--always)" -o $DIST_DIR ./cmd/um
- 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
GOPROXY: https://goproxy.io,direct
image: golang:1.22
name: go build darwin/amd64
- commands:
- curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file "dist/um-darwin-amd64.tar.gz"
"$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}/um-darwin-amd64.tar.gz"
- commands:
- curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file
"dist/um-darwin-amd64.tar.gz" "$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}/um-darwin-amd64.tar.gz"
- sha256sum dist/um-darwin-amd64.tar.gz
- echo $DRONE_GITEA_SERVER/${DRONE_REPO_NAMESPACE}/-/packages/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}
environment:
@ -107,110 +104,109 @@ steps:
from_secret: GITEA_API_KEY
image: golang:1.22
name: upload artifact
trigger:
trigger:
event:
- push
- pull_request
type: docker
---
kind: pipeline
name: release
steps:
- commands:
type: docker
- kind: pipeline
name: release
steps:
- commands:
- git fetch --tags
image: alpine/git
name: fetch tags
- commands:
- commands:
- go test -v ./...
environment:
GOPROXY: https://goproxy.io,direct
image: golang:1.22
name: go test
- commands:
- commands:
- DIST_DIR=$(mktemp -d)
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
--always)" -o $DIST_DIR ./cmd/um
- 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
GOPROXY: https://goproxy.io,direct
image: golang:1.22
name: go build linux/amd64
- commands:
- commands:
- DIST_DIR=$(mktemp -d)
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
--always)" -o $DIST_DIR ./cmd/um
- 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
GOPROXY: https://goproxy.io,direct
image: golang:1.22
name: go build linux/arm64
- commands:
- commands:
- DIST_DIR=$(mktemp -d)
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
--always)" -o $DIST_DIR ./cmd/um
- 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"
GOARCH: '386'
GOOS: linux
GOPROXY: https://goproxy.io,direct
image: golang:1.22
name: go build linux/386
- commands:
- commands:
- DIST_DIR=$(mktemp -d)
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
--always)" -o $DIST_DIR ./cmd/um
- 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 .
- zip -9 -j -r "dist/um-windows-amd64.zip" $DIST_DIR
environment:
GOARCH: amd64
GOOS: windows
GOPROXY: https://goproxy.io,direct
image: golang:1.22
name: go build windows/amd64
- commands:
- commands:
- DIST_DIR=$(mktemp -d)
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
--always)" -o $DIST_DIR ./cmd/um
- 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 .
- zip -9 -j -r "dist/um-windows-386.zip" $DIST_DIR
environment:
GOARCH: "386"
GOARCH: '386'
GOOS: windows
GOPROXY: https://goproxy.io,direct
image: golang:1.22
name: go build windows/386
- commands:
- commands:
- DIST_DIR=$(mktemp -d)
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
--always)" -o $DIST_DIR ./cmd/um
- 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
GOPROXY: https://goproxy.io,direct
image: golang:1.22
name: go build darwin/amd64
- commands:
- commands:
- DIST_DIR=$(mktemp -d)
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
--always)" -o $DIST_DIR ./cmd/um
- 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
GOPROXY: https://goproxy.io,direct
image: golang:1.22
name: go build darwin/arm64
- image: plugins/gitea-release
- image: plugins/gitea-release
name: create release
settings:
api_key:
@ -220,7 +216,7 @@ steps:
draft: true
files: dist/*
title: ${DRONE_TAG}
trigger:
trigger:
event:
- tag
type: docker
type: docker