forked from lutrinos/ConnectionInternat
-
Notifications
You must be signed in to change notification settings - Fork 0
248 lines (216 loc) · 9.54 KB
/
release.yml
File metadata and controls
248 lines (216 loc) · 9.54 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
run-name: Release ${{ inputs.tag_name }}
on:
workflow_dispatch:
inputs:
tag_name:
description: "Version name; e.g. 1.0.0; DON'T PUT A V IN FRONT OF IT"
required: true
release:
description: "Whether to create a GitHub Release"
type: boolean
default: true
env:
BINARY_NAME: ConnectionInternat
VERSION_TAG: ${{ inputs.tag_name }}
BUNDLED_ALACRITTY_VERSION: "0.14.0"
jobs:
# This is roughly copied from bat's CICD and release script
build:
name: ${{ matrix.job.target }} (${{ matrix.job.os }})
runs-on: ${{ matrix.job.os }}
permissions:
contents: write
packages: write
strategy:
fail-fast: false
matrix:
job:
- {
target: aarch64-unknown-linux-musl,
os: ubuntu-24.04,
dpkg_arch: arm64,
use-cross: true,
backend: "back-linux-arm64",
}
- {
target: aarch64-unknown-linux-gnu,
os: ubuntu-24.04,
dpkg_arch: arm64,
use-cross: true,
backend: "back-linux-arm64",
}
- {
target: x86_64-apple-darwin,
os: macos-15-intel,
backend: "back-darwin-amd64",
}
- {
target: aarch64-apple-darwin,
os: macos-15,
backend: "back-darwin-amd64",
}
- {
target: x86_64-pc-windows-msvc,
os: windows-2025,
backend: "back-windows-amd64.exe",
}
- {
target: x86_64-unknown-linux-gnu,
os: ubuntu-24.04,
dpkg_arch: amd64,
use-cross: true,
backend: back-linux-amd64,
}
- {
target: x86_64-unknown-linux-musl,
os: ubuntu-24.04,
dpkg_arch: musl-linux-amd64,
use-cross: true,
backend: back-linux-amd64,
}
env:
BUILD_CMD: cargo
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Install prerequisites
shell: bash
run: |
case ${{ matrix.job.target }} in
arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
esac
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.job.target }}
- name: Install cross
if: matrix.job.use-cross
uses: taiki-e/install-action@v2
with:
tool: cross
- name: Overwrite build command env variable
if: matrix.job.use-cross
shell: bash
run: echo "BUILD_CMD=cross" >> $GITHUB_ENV
- name: Show version information (Rust, cargo, GCC)
shell: bash
run: |
gcc --version || true
rustup -V
rustup toolchain list
rustup default
cargo -V
rustc -V
- name: Build
shell: bash
run: $BUILD_CMD build --release --target=${{ matrix.job.target }}
# Removed the --locked
- name: Set binary name & path
id: bin
shell: bash
run: |
# Figure out suffix of binary
EXE_suffix=""
case ${{ matrix.job.target }} in
*-pc-windows-*) EXE_suffix=".exe" ;;
esac;
# Setup paths
BIN_NAME="${{ env.BINARY_NAME }}${EXE_suffix}"
BIN_PATH="target/${{ matrix.job.target }}/release/${BIN_NAME}"
# Let subsequent steps know where to find the binary
echo "BIN_PATH=${BIN_PATH}" >> $GITHUB_OUTPUT
echo "BIN_NAME=${BIN_NAME}" >> $GITHUB_OUTPUT
- name: Create tarball
id: package
shell: bash
run: |
PKG_suffix=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_suffix=".zip" ;; esac;
PKG_BASENAME=${{ env.BINARY_NAME }}-v${{ env.VERSION_TAG }}-${{ matrix.job.target }}
PKG_NAME=${PKG_BASENAME}${PKG_suffix}
echo "PKG_NAME=${PKG_NAME}" >> $GITHUB_OUTPUT
PKG_STAGING="intermediate_dir/package"
ARCHIVE_DIR="${PKG_STAGING}/${PKG_BASENAME}"
mkdir -p "${ARCHIVE_DIR}/"
if [[ "${{ matrix.job.target }}" =~ -pc-windows-.* ]]; then
# curl -Lo "$ARCHIVE_DIR/alacritty-portable.exe" https://github.com/alacritty/alacritty/releases/download/v${{ env.BUNDLED_ALACRITTY_VERSION }}/Alacritty-v${{ env.BUNDLED_ALACRITTY_VERSION }}-portable.exe
cp "./run.bat" "$ARCHIVE_DIR/${{ env.BINARY_NAME }}.bat"
sed -i "s/\$EXE_NAME/${{ steps.bin.outputs.BIN_NAME }}/g" "$ARCHIVE_DIR/${{ env.BINARY_NAME }}.bat"
fi
# Binary
cp "${{ steps.bin.outputs.BIN_PATH }}" "$ARCHIVE_DIR/"
# Backend
cp "go-backend/binaries/${{ matrix.job.backend }}" "$ARCHIVE_DIR/${{ env.BINARY_NAME }}-backend.exe"
# base compressed package
pushd "${PKG_STAGING}/" >/dev/null
case ${{ matrix.job.target }} in
*-pc-windows-*) 7z -y a "${PKG_NAME}" "${PKG_BASENAME}"/* | tail -2 ;;
*) tar czf "${PKG_NAME}" "${PKG_BASENAME}"/* ;;
esac;
popd >/dev/null
# Let subsequent steps know where to find the compressed package
echo "PKG_PATH=${PKG_STAGING}/${PKG_NAME}" >> $GITHUB_OUTPUT
- name: "Artifact upload: tarball"
uses: actions/upload-artifact@master
with:
name: ${{ steps.package.outputs.PKG_NAME }}
path: ${{ steps.package.outputs.PKG_PATH }}
- name: Publish archives and packages
uses: softprops/action-gh-release@v2
if: inputs.release
with:
name: v${{ env.VERSION_TAG }} Release
tag_name: v${{ env.VERSION_TAG }}
draft: true
generate_release_notes: true
target_commitish: ${{ github.sha }}
files: |
${{ steps.package.outputs.PKG_PATH }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release_installers:
name: Build Installers
needs: build
runs-on: ubuntu-24.04
continue-on-error: false
permissions:
contents: write
packages: write
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.23.2
- name: Build installer
id: build
shell: bash
run: |
cd ./installer
rm -rf ./binaries
mkdir -p ./binaries
export INSTALLER_PREFIX="installer-${{ env.BINARY_NAME }}"
echo "Building amd64-linux"
GOOS=linux GOARCH=amd64 go build -o ./binaries/$INSTALLER_PREFIX-linux-amd64
echo "Building arm64-linux"
GOOS=linux GOARCH=arm64 go build -o ./binaries/$INSTALLER_PREFIX-linux-arm64
echo "Building amd64-darwin"
GOOS=darwin GOARCH=amd64 go build -o ./binaries/$INSTALLER_PREFIX-darwin-amd64
# echo "Building arm64-darwin"
# GOOS=darwin GOARCH=arm64 go build -o ./binaries/$INSTALLER_PREFIX-darwin-arm64
echo "Building amd64-windows"
GOOS=windows GOARCH=amd64 go build -o ./binaries/$INSTALLER_PREFIX-windows.exe
- name: Publish installer binaries
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.VERSION_TAG }}
draft: true
target_commitish: ${{ github.sha }}
files: |
./installer/binaries/installer-${{ env.BINARY_NAME }}-linux-amd64
./installer/binaries/installer-${{ env.BINARY_NAME }}-linux-arm64
./installer/binaries/installer-${{ env.BINARY_NAME }}-darwin-amd64
./installer/binaries/installer-${{ env.BINARY_NAME }}-windows.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}