-
Notifications
You must be signed in to change notification settings - Fork 28
138 lines (123 loc) · 4.19 KB
/
release.yml
File metadata and controls
138 lines (123 loc) · 4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: goreleaser
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
jobs:
goreleaser:
runs-on: ubuntu-22.04
environment: release
env:
EDITION: ${{ vars.EDITION || 'community' }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
submodules: recursive
- name: Install dependencies
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y \
gcc-multilib \
g++-multilib \
libc6-dev-i386 \
upx \
zip \
mingw-w64 \
gcc-mingw-w64-i686 \
gcc-mingw-w64-x86-64
- name: Set up GCC
uses: egor-tensin/setup-gcc@v1
with:
version: latest
platform: x64
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.22"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOPATH: "/home/runner/go"
- name: Build Libraries
run: |
mkdir -p dist/lib
# Windows DLL (64-bit)
echo "Building Windows x64 DLL..."
CGO_ENABLED=1 \
GOOS=windows \
GOARCH=amd64 \
CC=x86_64-w64-mingw32-gcc \
go build -buildmode=c-shared \
-o dist/lib/rem_${EDITION}_windows_amd64.dll \
-ldflags "-s -w -X 'github.com/chainreactors/rem/cmd/cmd.ver=${{ github.ref_name }}'" \
-buildvcs=false ./cmd/export/
# Windows DLL (32-bit)
echo "Building Windows x86 DLL..."
CGO_ENABLED=1 \
GOOS=windows \
GOARCH=386 \
CC=i686-w64-mingw32-gcc \
go build -buildmode=c-shared \
-o dist/lib/rem_${EDITION}_windows_386.dll \
-ldflags "-s -w -X 'github.com/chainreactors/rem/cmd/cmd.ver=${{ github.ref_name }}'" \
-buildvcs=false ./cmd/export/
# Linux .so (64-bit)
echo "Building Linux x64 SO..."
CGO_ENABLED=1 \
GOOS=linux \
GOARCH=amd64 \
go build -buildmode=c-shared \
-o dist/lib/rem_${EDITION}_linux_amd64.so \
-ldflags "-s -w -X 'github.com/chainreactors/rem/cmd/cmd.ver=${{ github.ref_name }}'" \
-buildvcs=false ./cmd/export/
# Linux .so (32-bit)
echo "Building Linux x86 SO..."
CGO_ENABLED=1 \
GOOS=linux \
GOARCH=386 \
PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig \
go build -buildmode=c-shared \
-o dist/lib/rem_${EDITION}_linux_386.so \
-ldflags "-s -w -X 'github.com/chainreactors/rem/cmd/cmd.ver=${{ github.ref_name }}'" \
-buildvcs=false ./cmd/export/
# Static Libraries (.a)
echo "Building Linux x64 Static Library..."
CGO_ENABLED=1 \
GOOS=linux \
GOARCH=amd64 \
go build -buildmode=c-archive \
-o dist/lib/librem_${EDITION}_linux_amd64.a \
-ldflags "-s -w -X 'github.com/chainreactors/rem/cmd/cmd.ver=${{ github.ref_name }}'" \
-buildvcs=false ./cmd/export/
echo "Building Windows x64 Static Library..."
CGO_ENABLED=1 \
GOOS=windows \
GOARCH=amd64 \
CC=x86_64-w64-mingw32-gcc \
go build -buildmode=c-archive \
-o dist/lib/librem_${EDITION}_windows_amd64.a \
-ldflags "-s -w -X 'github.com/chainreactors/rem/cmd/cmd.ver=${{ github.ref_name }}'" \
-buildvcs=false ./cmd/export/
- name: Zip files
run: |
zip -r -j dist/rem_archive.zip dist/rem*
zip -r dist/rem_lib.zip dist/lib/ -x "*.h"
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/rem*
tag: ${{ github.ref }}
overwrite: true
file_glob: true
draft: true