Skip to content

Commit 8871c2f

Browse files
修复 release
1 parent 47f1d03 commit 8871c2f

File tree

3 files changed

+42
-25
lines changed

3 files changed

+42
-25
lines changed

.github/workflows/go-release.yml

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,7 @@ jobs:
1717
with:
1818
go-version: '1.25'
1919
- name: Build releases
20-
run: |
21-
APP_NAME="gitea-pages"
22-
mkdir -p dist
23-
GOOS=linux GOARCH=amd64 go build -o "dist/${APP_NAME}-linux-amd64" ./
24-
GOOS=linux GOARCH=386 go build -o "dist/${APP_NAME}-linux-i386" ./
25-
GOOS=linux GOARCH=arm64 go build -o "dist/${APP_NAME}-linux-arm64" ./
26-
GOOS=linux GOARCH=loongarch64 go build -o "dist/${APP_NAME}-linux-loongarch64" ./
27-
28-
GOOS=darwin GOARCH=amd64 go build -o "dist/${APP_NAME}-darwin-amd64" ./
29-
GOOS=darwin GOARCH=arm64 go build -o "dist/${APP_NAME}-darwin-arm64" ./
30-
31-
GOOS=windows GOARCH=amd64 go build -o "dist/${APP_NAME}-windows-amd64.exe" ./
32-
cp LICENSE dist/license.txt
33-
cd dist
34-
for file in "${APP_NAME}-"*; do
35-
zip "${file}.zip" "$file" "license.txt"
36-
done
37-
ls *.zip > assets.txt
38-
cd ..
39-
20+
run: make releases
4021
- name: Create GitHub Release
4122
id: create_release
4223
uses: softprops/action-gh-release@v2
@@ -46,4 +27,4 @@ jobs:
4627
draft: false
4728
prerelease: false
4829
files: |
49-
dist/*.zip
30+
dist/*.tar.gz

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,6 @@ fabric.properties
6161
*.vsix
6262

6363
config-local.yaml
64-
gitea-pages
64+
gitea-pages
65+
*.zip
66+
dist/

Makefile

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,51 @@
11
GOPATH := $(shell go env GOPATH)
2+
GOARCH ?= $(shell go env GOARCH)
3+
GOOS ?= $(shell go env GOOS)
4+
5+
6+
ifeq ($(GOOS),windows)
7+
GO_DIST_NAME := gitea-pages.exe
8+
else
9+
GO_DIST_NAME := gitea-pages
10+
endif
211

312
fmt:
413
@(test -f "$(GOPATH)/bin/gofumpt" || go install mvdan.cc/gofumpt@latest) && \
514
"$(GOPATH)/bin/gofumpt" -l -w .
615

16+
17+
.PHONY: release
18+
release: dist/gitea-pages-$(GOOS)-$(GOARCH).tar.gz
19+
20+
dist/gitea-pages-$(GOOS)-$(GOARCH).tar.gz: $(shell find . -type f -name "*.go" ) go.mod go.sum
21+
@echo Compile $@ via $(GO_DIST_NAME) && \
22+
mkdir -p dist && \
23+
rm -f dist/$(GO_DIST_NAME) && \
24+
GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o dist/$(GO_DIST_NAME) . && \
25+
cd dist && \
26+
tar zcf gitea-pages-$(GOOS)-$(GOARCH).tar.gz $(GO_DIST_NAME) ../LICENSE ../config.yaml ../errors.html.tmpl ../README.md ../README_*.md && \
27+
rm -f $(GO_DIST_NAME)
28+
729
gitea-pages: $(shell find . -type f -name "*.go" ) go.mod go.sum
8-
@CGO_ENABLED=0 go build -ldflags="-s -w" -o $@ .
30+
@CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o $@ .
931

1032
.PHONY: debug
11-
1233
debug: gitea-pages
1334
@./gitea-pages -conf config-local.yaml -debug
1435

1536
.PHONY: test
1637
test:
17-
@go test -v ./...
38+
@go test -v ./...
39+
40+
41+
.PHONY: releases
42+
releases:
43+
@make release GOOS=linux GOARCH=amd64 && \
44+
make release GOOS=linux GOARCH=386 && \
45+
make release GOOS=linux GOARCH=arm64 && \
46+
make release GOOS=linux GOARCH=loong64 && \
47+
make release GOOS=darwin GOARCH=amd64 && \
48+
make release GOOS=darwin GOARCH=arm64 && \
49+
make release GOOS=windows GOARCH=amd64
50+
51+

0 commit comments

Comments
 (0)