Skip to content

Commit 3f19f18

Browse files
authored
Merge pull request #2278 from seefs001/fix/release-version
fix: release workflow show version
2 parents a465597 + f47d473 commit 3f19f18

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

.github/workflows/release.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ jobs:
2222
uses: actions/checkout@v3
2323
with:
2424
fetch-depth: 0
25+
- name: Determine Version
26+
run: |
27+
VERSION=$(git describe --tags)
28+
echo "VERSION=$VERSION" >> $GITHUB_ENV
2529
- uses: oven-sh/setup-bun@v2
2630
with:
2731
bun-version: latest
@@ -31,7 +35,7 @@ jobs:
3135
run: |
3236
cd web
3337
bun install
34-
DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(git describe --tags) bun run build
38+
DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$VERSION bun run build
3539
cd ..
3640
- name: Set up Go
3741
uses: actions/setup-go@v3
@@ -40,13 +44,11 @@ jobs:
4044
- name: Build Backend (amd64)
4145
run: |
4246
go mod download
43-
VERSION=$(git describe --tags)
4447
go build -ldflags "-s -w -X 'new-api/common.Version=$VERSION' -extldflags '-static'" -o new-api-$VERSION
4548
- name: Build Backend (arm64)
4649
run: |
4750
sudo apt-get update
4851
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y gcc-aarch64-linux-gnu
49-
VERSION=$(git describe --tags)
5052
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X 'new-api/common.Version=$VERSION' -extldflags '-static'" -o new-api-arm64-$VERSION
5153
- name: Release
5254
uses: softprops/action-gh-release@v2
@@ -65,6 +67,10 @@ jobs:
6567
uses: actions/checkout@v3
6668
with:
6769
fetch-depth: 0
70+
- name: Determine Version
71+
run: |
72+
VERSION=$(git describe --tags)
73+
echo "VERSION=$VERSION" >> $GITHUB_ENV
6874
- uses: oven-sh/setup-bun@v2
6975
with:
7076
bun-version: latest
@@ -75,7 +81,7 @@ jobs:
7581
run: |
7682
cd web
7783
bun install
78-
DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(git describe --tags) bun run build
84+
DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$VERSION bun run build
7985
cd ..
8086
- name: Set up Go
8187
uses: actions/setup-go@v3
@@ -84,7 +90,6 @@ jobs:
8490
- name: Build Backend
8591
run: |
8692
go mod download
87-
VERSION=$(git describe --tags)
8893
go build -ldflags "-X 'new-api/common.Version=$VERSION'" -o new-api-macos-$VERSION
8994
- name: Release
9095
uses: softprops/action-gh-release@v2
@@ -105,6 +110,10 @@ jobs:
105110
uses: actions/checkout@v3
106111
with:
107112
fetch-depth: 0
113+
- name: Determine Version
114+
run: |
115+
VERSION=$(git describe --tags)
116+
echo "VERSION=$VERSION" >> $GITHUB_ENV
108117
- uses: oven-sh/setup-bun@v2
109118
with:
110119
bun-version: latest
@@ -114,7 +123,7 @@ jobs:
114123
run: |
115124
cd web
116125
bun install
117-
DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(git describe --tags) bun run build
126+
DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$VERSION bun run build
118127
cd ..
119128
- name: Set up Go
120129
uses: actions/setup-go@v3
@@ -123,7 +132,6 @@ jobs:
123132
- name: Build Backend
124133
run: |
125134
go mod download
126-
VERSION=$(git describe --tags)
127135
go build -ldflags "-s -w -X 'new-api/common.Version=$VERSION'" -o new-api-$VERSION.exe
128136
- name: Release
129137
uses: softprops/action-gh-release@v2
@@ -132,5 +140,3 @@ jobs:
132140
files: new-api-*.exe
133141
env:
134142
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135-
136-

common/init.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ func printHelp() {
3030
func InitEnv() {
3131
flag.Parse()
3232

33+
envVersion := os.Getenv("VERSION")
34+
if envVersion != "" {
35+
Version = envVersion
36+
}
37+
3338
if *PrintVersion {
3439
fmt.Println(Version)
3540
os.Exit(0)

0 commit comments

Comments
 (0)