1
+
2
+ name : " 交叉编译JIM-DOCS"
3
+
4
+ on :
5
+ repository_dispatch :
6
+ workflow_dispatch :
7
+ inputs :
8
+ version :
9
+ description : ' 输入需要编译的版本:以字母"v"开头'
10
+ required : true
11
+ default : ' '
12
+
13
+ jobs :
14
+ buile_openwrt :
15
+ runs-on : Ubuntu-20.04
16
+ if : github.event.repository.owner.id == github.event.sender.id
17
+ name : 构建项目
18
+ steps :
19
+ - name : 检查
20
+ uses : actions/checkout@main
21
+
22
+ - name : 初始化环境
23
+ env :
24
+ DEBIAN_FRONTEND : noninteractive
25
+ run : |
26
+ sudo -E apt-get -qq update
27
+ sudo -E apt-get -qq install zip unzip
28
+ sudo snap refresh
29
+ sudo snap install go --classic
30
+ git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
31
+ git config --global user.name "github-actions[bot]"
32
+
33
+ - name : 下载依赖
34
+ run : |
35
+ go mod tidy
36
+
37
+ - name : 开始编译
38
+ id : compile
39
+ working-directory : ./
40
+ run : |
41
+ function build_func {
42
+ suffix=""
43
+ if [ "$1" = "windows" ] ; then
44
+ suffix=".exe"
45
+ fi
46
+ echo "编译OS:$1 ARCH:$2 ..."
47
+ echo "CGO_ENABLED=0 GOOS=$1 GOARCH=$2 go build -o ./bin/jim-docs-$1-$2${suffix} ./*.go"
48
+ CGO_ENABLED=0 GOOS=$1 GOARCH=$2 go build -o ./bin/jim-docs-$1-$2${suffix} ./*.go
49
+ }
50
+
51
+ echo "开始编译[darwin]环境执行文件"
52
+ darwin_arch=("amd64" "arm64")
53
+ for ((i=0; i<${#darwin_arch[@]}; i++)); do
54
+ build_func darwin ${darwin_arch[$i]}
55
+ done
56
+
57
+ echo "开始编译[freebsd]环境执行文件"
58
+ freebsd_arch=("386" "amd64" "arm" "arm64")
59
+ for ((i=0; i<${#freebsd_arch[@]}; i++)); do
60
+ build_func freebsd ${freebsd_arch[$i]}
61
+ done
62
+
63
+ echo "开始编译[linux]环境执行文件"
64
+ linux_arch=("386" "amd64" "arm" "arm64" "mips" "mips64")
65
+ for ((i=0; i<${#linux_arch[@]}; i++)); do
66
+ build_func linux ${linux_arch[$i]}
67
+ done
68
+
69
+ echo "开始编译[windows]环境执行文件"
70
+ windows_arch=("386" "amd64" "arm" "arm64")
71
+ for ((i=0; i<${#windows_arch[@]}; i++)); do
72
+ build_func windows ${windows_arch[$i]}
73
+ done
74
+
75
+ echo "status=success" >> $GITHUB_OUTPUT
76
+
77
+ - name : 整理文件
78
+ id : organize
79
+ if : steps.compile.outputs.status == 'success' && !cancelled()
80
+ working-directory : ./bin
81
+ run : |
82
+ cp ../docs/*.json ./
83
+ cp ../docs/*.yaml ./
84
+
85
+ bin_arrays=($(ls jim-docs-*))
86
+ for ((i=0; i<${#bin_arrays[@]}; i++)); do
87
+ zip_name=$(echo ${bin_arrays[$i]}|awk -F '-' '{print $3"-"$4}'|awk -F'.' '{print $1}')
88
+ zip -r ${zip_name}-${{ github.event.inputs.version}}.zip ./*
89
+ done
90
+ echo "status=success" >> $GITHUB_OUTPUT
91
+
92
+ - name : 发布到release
93
+ uses : ncipollo/release-action@main
94
+ if : ${{ steps.organize.outputs.status }} == 'success' && !cancelled()
95
+ with :
96
+ tag : ${{ github.event.inputs.version}}
97
+ name : ${{ github.event.inputs.version}}
98
+ artifacts : ./bin/*.zip
99
+ allowUpdates : true
100
+ body : |
101
+ ### JIM-DOC
102
+ JIM的文档系统
0 commit comments