Skip to content

Commit f73ddb7

Browse files
committed
perf: change build action
1 parent 86e93f9 commit f73ddb7

2 files changed

Lines changed: 48 additions & 36 deletions

File tree

.github/workflows/build.yml

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ env:
2727
jobs:
2828
pre-build:
2929
name: pre-build go client
30-
runs-on: ubuntu-latest
30+
runs-on: ubuntu-22.04
3131
outputs:
3232
go-client-artifacts: ${{ steps.upload-go-client.outputs.artifact-name }}
3333

@@ -61,16 +61,16 @@ jobs:
6161
fail-fast: false
6262
matrix:
6363
include:
64-
- platform: "macos-latest" # for Arm based macs (M1 and above).
64+
- os: "macos-latest" # for Arm based macs (M1 and above).
6565
args: "--target aarch64-apple-darwin"
66-
- platform: "macos-latest" # for Intel based macs.
66+
- os: "macos-latest" # for Intel based macs.
6767
args: "--target x86_64-apple-darwin"
68-
- platform: "ubuntu-22.04" # for Tauri v1 you could replace this with ubuntu-20.04.
68+
- os: "ubuntu-22.04" # for Tauri v1 you could replace this with ubuntu-20.04.
6969
args: ""
70-
- platform: "windows-latest"
70+
- os: "windows-latest"
7171
args: ""
7272

73-
runs-on: ${{ matrix.platform }}
73+
runs-on: ${{ matrix.os }}
7474
steps:
7575
- name: Check out git repository
7676
uses: actions/checkout@v4
@@ -87,8 +87,6 @@ jobs:
8787

8888
- uses: pnpm/action-setup@v4
8989
name: Install pnpm
90-
with:
91-
run_install: false
9290

9391
- name: Setup Node.js
9492
uses: actions/setup-node@v4
@@ -100,42 +98,36 @@ jobs:
10098
uses: dtolnay/rust-toolchain@stable
10199
with:
102100
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
103-
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
101+
targets: ${{ matrix.os == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
104102

105103
- name: Install system dependencies (Ubuntu)
106-
if: matrix.platform == 'ubuntu-22.04'
104+
if: matrix.os == 'ubuntu-22.04'
107105
run: |
108106
sudo apt-get update
109-
sudo apt-get install -y libwebkit2gtk-4.1-dev libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf
107+
sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
110108
111109
- name: Install frontend dependencies
112110
run: pnpm install
113111

114112
- name: Build Tauri app
115113
uses: tauri-apps/tauri-action@v0
116114
env:
117-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
118-
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
119-
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
120-
XCODE_APP_TEAM_ID: ${{ secrets.XCODE_APP_TEAM_ID }}
121-
XCODE_APP_LOADER_EMAIL: ${{ secrets.XCODE_APP_LOADER_EMAIL }}
122-
XCODE_APP_LOADER_PASSWORD: ${{ secrets.XCODE_APP_LOADER_PASSWORD }}
123-
BUILD_CERTIFICATE_BASE64: ${{ secrets.CSC_LINK }}
124-
P12_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
125-
CSC_LINK: ${{ secrets.CSC_LINK }}
126-
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
115+
GITHUB_TOKEN: ${{ secrets.PRIVATE_TOKEN }}
127116
with:
117+
args: ${{ matrix.args }}
128118
tagName: ${{ github.ref_name }}
129119
releaseName: "JumpServer Client v__VERSION__"
130120
releaseBody: "See the assets to download this version and install."
131121
releaseDraft: true
132-
prerelease: false
122+
prerelease: ${{ contains(github.ref_name, 'rc') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'alpha') }}
133123

134124
release:
135125
name: create latest.json
136-
runs-on: ubuntu-latest
126+
runs-on: ubuntu-22.04
137127
needs: [pre-build, build]
138128
if: startsWith(github.ref, 'refs/tags/')
129+
permissions:
130+
contents: write
139131

140132
steps:
141133
- name: Check out git repository
@@ -172,4 +164,4 @@ jobs:
172164
with:
173165
files: latest.json
174166
env:
175-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
167+
GITHUB_TOKEN: ${{ secrets.PRIVATE_TOKEN }}

go-client/Makefile

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ LDFLAGS=-w -s
99

1010
CLIENTBUILD=CGO_ENABLED=0 go build -trimpath
1111

12-
# 自动检测当前平台
13-
CURRENT_OS := $(shell go env GOOS)
14-
CURRENT_ARCH := $(shell go env GOARCH)
12+
# 自动检测当前平台 - 使用 shell 命令,不依赖 Go 环境
13+
CURRENT_OS := $(shell uname -s 2>/dev/null | tr '[:upper:]' '[:lower:]' | sed 's/.*mingw.*/windows/; s/.*cygwin.*/windows/; s/.*msys.*/windows/' || echo "unknown")
14+
CURRENT_ARCH := $(shell uname -m 2>/dev/null | sed 's/x86_64/amd64/; s/aarch64/arm64/; s/arm64/arm64/; s/i686/386/' || echo "amd64")
15+
16+
# Windows 环境变量检测(当 uname 不可用时)
17+
ifeq ($(OS),Windows_NT)
18+
CURRENT_OS := windows
19+
CURRENT_ARCH := amd64
20+
endif
1521

1622
# 默认目标:构建并安装当前平台
1723
.PHONY: default
@@ -83,20 +89,34 @@ build-all:
8389
install:
8490
@echo "Installing Go client for current platform: $(CURRENT_OS)/$(CURRENT_ARCH)"
8591
@mkdir -p $(BASEPATH)/../src-tauri/resources/bin/
86-
@if [ -d "$(BUILDDIR)/$(CURRENT_OS)-$(CURRENT_ARCH)" ]; then \
87-
echo "Copying $(CURRENT_OS)-$(CURRENT_ARCH) files..."; \
88-
cp -R $(BUILDDIR)/$(CURRENT_OS)-$(CURRENT_ARCH) $(BASEPATH)/../src-tauri/resources/bin/; \
89-
elif [ "$(CURRENT_OS)" = "windows" ] && [ -d "$(BUILDDIR)/windows" ]; then \
90-
echo "Copying Windows files..."; \
91-
cp -R $(BUILDDIR)/windows $(BASEPATH)/../src-tauri/resources/bin/; \
92+
@PLATFORM_DIR=""; \
93+
if [ "$(CURRENT_OS)" = "darwin" ]; then \
94+
if [ "$(CURRENT_ARCH)" = "arm64" ]; then \
95+
PLATFORM_DIR="darwin-arm64"; \
96+
else \
97+
PLATFORM_DIR="darwin-amd64"; \
98+
fi; \
99+
elif [ "$(CURRENT_OS)" = "linux" ]; then \
100+
if [ "$(CURRENT_ARCH)" = "arm64" ]; then \
101+
PLATFORM_DIR="linux-arm64"; \
102+
else \
103+
PLATFORM_DIR="linux-amd64"; \
104+
fi; \
105+
elif [ "$(CURRENT_OS)" = "windows" ]; then \
106+
PLATFORM_DIR="windows"; \
107+
fi; \
108+
echo "Looking for platform directory: $$PLATFORM_DIR"; \
109+
if [ -d "$(BUILDDIR)/$$PLATFORM_DIR" ]; then \
110+
echo "Copying $$PLATFORM_DIR files..."; \
111+
cp -R $(BUILDDIR)/$$PLATFORM_DIR $(BASEPATH)/../src-tauri/resources/bin/; \
112+
cp $(BASEPATH)/config.json $(BASEPATH)/../src-tauri/resources/bin/; \
113+
echo "Install completed for $$PLATFORM_DIR!"; \
92114
else \
93-
echo "Error: No build files found for $(CURRENT_OS)/$(CURRENT_ARCH)"; \
115+
echo "Error: No build files found for platform $$PLATFORM_DIR"; \
94116
echo "Available platforms:"; \
95117
ls -la $(BUILDDIR)/ 2>/dev/null || echo "No build directory found"; \
96118
exit 1; \
97119
fi
98-
@cp $(BASEPATH)/config.json $(BASEPATH)/../src-tauri/resources/bin/
99-
@echo "Install completed!"
100120

101121
# 帮助信息
102122
.PHONY: help

0 commit comments

Comments
 (0)