mirror of
https://github.com/acepanel/panel.git
synced 2026-02-07 05:47:21 +08:00
67 lines
1.3 KiB
YAML
67 lines
1.3 KiB
YAML
image: golang:bookworm
|
|
|
|
# 在每个任务执行前运行
|
|
before_script:
|
|
- mkdir -p .go
|
|
- go version
|
|
- go env -w GO111MODULE=on
|
|
- go env -w GOPROXY=https://goproxy.cn,direct
|
|
|
|
.go_cache:
|
|
variables:
|
|
GOPATH: $CI_PROJECT_DIR/.go
|
|
cache:
|
|
paths:
|
|
- .go/pkg/mod/
|
|
|
|
# 全局变量
|
|
variables:
|
|
OUTPUT_NAME: "panel"
|
|
GO111MODULE: "on"
|
|
GOPROXY: "https://goproxy.cn,direct"
|
|
|
|
stages:
|
|
- prepare
|
|
- build
|
|
|
|
golangci_lint:
|
|
stage: prepare
|
|
image: golangci/golangci-lint:latest-alpine
|
|
extends: .go_cache
|
|
allow_failure: true
|
|
script:
|
|
- golangci-lint run --timeout 30m
|
|
|
|
unit_test:
|
|
stage: prepare
|
|
extends: .go_cache
|
|
allow_failure: true
|
|
script:
|
|
- go test -v -coverprofile=coverage.txt -covermode=atomic ./...
|
|
|
|
build:
|
|
stage: build
|
|
extends: .go_cache
|
|
script:
|
|
- go mod download
|
|
- CGO_ENABLED=0 go build -ldflags '-s -w --extldflags "-static -fpic"' -o $OUTPUT_NAME
|
|
artifacts:
|
|
name: "$OUTPUT_NAME"
|
|
paths:
|
|
- $OUTPUT_NAME
|
|
expire_in: 3 days
|
|
|
|
release:
|
|
stage: release
|
|
image:
|
|
name: goreleaser/goreleaser
|
|
entrypoint: ['']
|
|
only:
|
|
- tags
|
|
variables:
|
|
# Disable shallow cloning so that goreleaser can diff between tags to
|
|
# generate a changelog.
|
|
GIT_DEPTH: 0
|
|
script:
|
|
- goreleaser release --clean
|