This commit is contained in:
parent
4d7db55dd9
commit
74c911c873
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -61,7 +61,7 @@ jobs:
|
||||
if [ "$platform" = "darwin" ]; then platform="mac"; fi
|
||||
suffix="${platform}_${{ matrix.goarch }}${extension}"
|
||||
cd backend
|
||||
BUILD_FLAGS="-s -w -X 'git.pcux.cn/xuans/Smail/internal/buildinfo.Version=${{ env.VERSION }}' -X 'git.pcux.cn/xuans/Smail/internal/buildinfo.GoVersion=$(go version)' -X 'git.pcux.cn/xuans/Smail/internal/buildinfo.GitHash=$(git show -s --format=%H)' -X 'git.pcux.cn/xuans/Smail/internal/buildinfo.BuildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
|
||||
BUILD_FLAGS="-s -w -X 'git.pcux.cn/xuans/Smail/internal/buildinfo.Version=${{ env.VERSION }}' -X 'git.pcux.cn/xuans/Smail/internal/buildinfo.GoVersion=$(go env GOVERSION)' -X 'git.pcux.cn/xuans/Smail/internal/buildinfo.GitHash=$(git show -s --format=%H)' -X 'git.pcux.cn/xuans/Smail/internal/buildinfo.BuildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
|
||||
go build -tags bundled -trimpath -ldflags "$BUILD_FLAGS" -o ../out/backend/smail_$suffix ./cmd/smail
|
||||
go build -trimpath -ldflags "$BUILD_FLAGS" -o ../out/backend/smail-admin_$suffix ./cmd/smail-admin
|
||||
go build -trimpath -ldflags "$BUILD_FLAGS" -o ../out/backend/smail-config_$suffix ./cmd/smail-config
|
||||
|
||||
2
Makefile
2
Makefile
@ -1,7 +1,7 @@
|
||||
SMAIL_VERSION ?= $(shell git describe --tags --always --dirty)
|
||||
GIT_HASH ?= $(shell git show -s --format=%H)
|
||||
BUILD_TIME ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||
GO_VERSION ?= $(shell cd backend && go version)
|
||||
GO_VERSION ?= $(shell cd backend && go env GOVERSION)
|
||||
BUILD_LDFLAGS = -s -w -X 'git.pcux.cn/xuans/Smail/internal/buildinfo.Version=$(SMAIL_VERSION)' -X 'git.pcux.cn/xuans/Smail/internal/buildinfo.GitHash=$(GIT_HASH)' -X 'git.pcux.cn/xuans/Smail/internal/buildinfo.BuildTime=$(BUILD_TIME)' -X 'git.pcux.cn/xuans/Smail/internal/buildinfo.GoVersion=$(GO_VERSION)'
|
||||
|
||||
.PHONY: build clean clean_codex_test_artifacts build_fe build_server wechat_push spam_block telegram_push plugin package test test_mysql test_postgres
|
||||
|
||||
@ -51,7 +51,7 @@ try {
|
||||
$gitHash = (& git rev-parse HEAD).Trim()
|
||||
if ($LASTEXITCODE -ne 0) { throw '无法读取构建提交信息' }
|
||||
$buildTime = [DateTime]::UtcNow.ToString('yyyy-MM-ddTHH:mm:ssZ')
|
||||
$goVersion = (& go version).Trim()
|
||||
$goVersion = (& go env GOVERSION).Trim()
|
||||
$flags = "-s -w -X 'git.pcux.cn/xuans/Smail/internal/buildinfo.Version=dev-$($fingerprint.Substring(0, 12))' -X 'git.pcux.cn/xuans/Smail/internal/buildinfo.GitHash=$gitHash' -X 'git.pcux.cn/xuans/Smail/internal/buildinfo.BuildTime=$buildTime' -X 'git.pcux.cn/xuans/Smail/internal/buildinfo.GoVersion=$goVersion'"
|
||||
& go build -tags bundled -trimpath -ldflags $flags -o (Join-Path $output 'smail.exe') ./cmd/smail
|
||||
if ($LASTEXITCODE -ne 0) { throw '开发后端构建失败' }
|
||||
|
||||
@ -11,7 +11,7 @@ const read = relative => readFile(path.join(root, relative), 'utf8')
|
||||
|
||||
test('跨平台构建输出不得越过项目 out 目录', async () => {
|
||||
const content = await read('Makefile')
|
||||
assert.match(content, /GO_VERSION \?= \$\(shell cd backend && go version\)/)
|
||||
assert.match(content, /GO_VERSION \?= \$\(shell cd backend && go env GOVERSION\)/)
|
||||
const commands = [...content.matchAll(/cd ([^\s]+) && [^\n]*go build [^\n]* -o ([^\s]+) /g)]
|
||||
assert.equal(commands.length, 18)
|
||||
for (const [, directory, output] of commands) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user