forked from mpiorowski/late-sh
-
Notifications
You must be signed in to change notification settings - Fork 0
244 lines (216 loc) · 8.89 KB
/
deploy_cli.yml
File metadata and controls
244 lines (216 loc) · 8.89 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
name: deploy_cli
on:
release:
types: [published]
concurrency:
group: ${{ endsWith(github.ref, '-cli') && format('deploy-cli-{0}', github.event.release.prerelease && 'staging' || 'production') || format('{0}-{1}', github.workflow, github.run_id) }}
cancel-in-progress: true
permissions:
contents: read
jobs:
ci:
name: ci
if: endsWith(github.ref, '-cli')
uses: ./.github/workflows/ci.yml
with:
package: late-cli
build_cli:
name: build_late_cli_${{ matrix.target }}
if: endsWith(github.ref, '-cli')
needs: ci
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
binary_name: late
- runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
binary_name: late
- runner: ubuntu-latest
target: x86_64-linux-android
binary_name: late
android: true
- runner: ubuntu-latest
target: aarch64-linux-android
binary_name: late
android: true
- runner: macos-15-intel
target: x86_64-apple-darwin
binary_name: late
- runner: macos-14
target: aarch64-apple-darwin
binary_name: late
- runner: windows-latest
target: x86_64-pc-windows-msvc
binary_name: late.exe
steps:
- name: checkout
uses: actions/checkout@v5
- name: restore_rust_cache
uses: Swatinem/rust-cache@v2
with:
shared-key: cli-release-${{ matrix.target }}
- name: install_linux_build_dependencies
if: runner.os == 'Linux' && matrix.android != true
run: |
sudo apt-get update
sudo apt-get install -y libasound2-dev pkg-config mold
- name: set_up_android_sdk
if: matrix.android == true
uses: android-actions/setup-android@v3
- name: install_android_ndk
if: matrix.android == true
env:
ANDROID_NDK_VERSION: 27.2.12479018
run: sdkmanager --install "ndk;${ANDROID_NDK_VERSION}"
- name: configure_android_toolchain
if: matrix.android == true
env:
ANDROID_NDK_VERSION: 27.2.12479018
run: |
NDK_HOME="$ANDROID_HOME/ndk/${ANDROID_NDK_VERSION}"
TOOLCHAIN="$NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64"
case "${{ matrix.target }}" in
aarch64-linux-android)
linker="$TOOLCHAIN/bin/aarch64-linux-android26-clang"
echo "CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$linker" >> "$GITHUB_ENV"
echo "CC_aarch64_linux_android=$linker" >> "$GITHUB_ENV"
echo "AR_aarch64_linux_android=$TOOLCHAIN/bin/llvm-ar" >> "$GITHUB_ENV"
echo "RANLIB_aarch64_linux_android=$TOOLCHAIN/bin/llvm-ranlib" >> "$GITHUB_ENV"
ln -sf "$TOOLCHAIN/bin/llvm-ranlib" "$TOOLCHAIN/bin/aarch64-linux-android-ranlib"
ln -sf "$TOOLCHAIN/bin/llvm-ar" "$TOOLCHAIN/bin/aarch64-linux-android-ar"
;;
x86_64-linux-android)
linker="$TOOLCHAIN/bin/x86_64-linux-android26-clang"
echo "CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=$linker" >> "$GITHUB_ENV"
echo "CC_x86_64_linux_android=$linker" >> "$GITHUB_ENV"
echo "AR_x86_64_linux_android=$TOOLCHAIN/bin/llvm-ar" >> "$GITHUB_ENV"
echo "RANLIB_x86_64_linux_android=$TOOLCHAIN/bin/llvm-ranlib" >> "$GITHUB_ENV"
ln -sf "$TOOLCHAIN/bin/llvm-ranlib" "$TOOLCHAIN/bin/x86_64-linux-android-ranlib"
ln -sf "$TOOLCHAIN/bin/llvm-ar" "$TOOLCHAIN/bin/x86_64-linux-android-ar"
;;
esac
echo "$TOOLCHAIN/bin" >> "$GITHUB_PATH"
- name: install_rust_target
run: rustup target add ${{ matrix.target }}
- name: cargo_build_cli
if: matrix.android != true
run: cargo build --locked --release -p late-cli --bin late --target ${{ matrix.target }}
- name: cargo_build_cli_android
if: matrix.android == true
run: cargo build --locked --release -p late-cli --bin late --target ${{ matrix.target }}
- name: stage_cli_artifact
shell: bash
run: |
mkdir -p dist/${{ matrix.target }}
cp "target/${{ matrix.target }}/release/${{ matrix.binary_name }}" "dist/${{ matrix.target }}/${{ matrix.binary_name }}"
- name: upload_cli_artifact
uses: actions/upload-artifact@v6
with:
name: late-${{ matrix.target }}
path: dist/${{ matrix.target }}/${{ matrix.binary_name }}
if-no-files-found: error
publish_cli:
name: publish_late_cli
if: endsWith(github.ref, '-cli')
needs: build_cli
runs-on: ubuntu-latest
environment: ${{ github.event.release.prerelease == true && 'staging' || 'production' }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: auto
DIST_BUCKET: ${{ vars.BUCKET || 'late-sh-r' }}
S3_ENDPOINT: ${{ vars.S3_ENDPOINT }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
IS_PRERELEASE: ${{ github.event.release.prerelease }}
steps:
- name: checkout
uses: actions/checkout@v5
- name: download_cli_artifacts
uses: actions/download-artifact@v8
with:
pattern: late-*
path: dist
- name: validate_publish_configuration
run: |
test -n "$AWS_ACCESS_KEY_ID"
test -n "$AWS_SECRET_ACCESS_KEY"
test -n "$DIST_BUCKET"
test -n "$S3_ENDPOINT"
- name: prepare_distribution_layout
run: |
chmod 755 scripts/install.sh
mkdir -p "publish/releases/${RELEASE_TAG}"
for artifact_dir in dist/late-*; do
target="${artifact_dir#dist/late-}"
source_file="$(find "${artifact_dir}" -maxdepth 1 -type f \( -name 'late' -o -name 'late.exe' \) -print -quit)"
test -n "$source_file"
binary_name="$(basename "$source_file")"
mkdir -p "publish/releases/${RELEASE_TAG}/${target}"
cp "$source_file" "publish/releases/${RELEASE_TAG}/${target}/${binary_name}"
done
cp scripts/install.sh "publish/releases/${RELEASE_TAG}/install.sh"
cp scripts/install.ps1 "publish/releases/${RELEASE_TAG}/install.ps1"
printf '%s\n' "${RELEASE_TAG}" > "publish/releases/${RELEASE_TAG}/VERSION"
(
cd "publish/releases/${RELEASE_TAG}"
files=()
while IFS= read -r -d '' file; do
files+=("${file#./}")
done < <(find . -mindepth 2 -maxdepth 2 -type f \( -name 'late' -o -name 'late.exe' \) -print0 | LC_ALL=C sort -z)
sha256sum "${files[@]}" > sha256sums.txt
)
if [[ "${IS_PRERELEASE}" != "true" ]]; then
mkdir -p publish/latest
for target_dir in "publish/releases/${RELEASE_TAG}"/*; do
[[ -d "$target_dir" ]] || continue
cp -R "$target_dir" publish/latest/
done
cp scripts/install.sh publish/latest/install.sh
cp scripts/install.ps1 publish/latest/install.ps1
cp scripts/install.sh publish/install.sh
cp scripts/install.ps1 publish/install.ps1
cp scripts/install.sh publish/index.html
printf '%s\n' "${RELEASE_TAG}" > publish/latest/VERSION
printf '%s\n' "${RELEASE_TAG}" > publish/VERSION
cp "publish/releases/${RELEASE_TAG}/sha256sums.txt" publish/latest/sha256sums.txt
fi
- name: upload_release_distribution
run: |
aws s3 cp \
"publish/releases/${RELEASE_TAG}/" \
"s3://${DIST_BUCKET}/releases/${RELEASE_TAG}/" \
--recursive \
--endpoint-url "${S3_ENDPOINT}"
- name: upload_latest_distribution
if: github.event.release.prerelease == false
run: |
aws s3 cp \
publish/latest/ \
"s3://${DIST_BUCKET}/latest/" \
--recursive \
--endpoint-url "${S3_ENDPOINT}"
aws s3 cp \
publish/install.sh \
"s3://${DIST_BUCKET}/install.sh" \
--endpoint-url "${S3_ENDPOINT}" \
--content-type "text/x-shellscript"
aws s3 cp \
publish/install.ps1 \
"s3://${DIST_BUCKET}/install.ps1" \
--endpoint-url "${S3_ENDPOINT}" \
--content-type "text/plain"
aws s3 cp \
publish/index.html \
"s3://${DIST_BUCKET}/index.html" \
--endpoint-url "${S3_ENDPOINT}" \
--content-type "text/x-shellscript"
aws s3 cp \
publish/VERSION \
"s3://${DIST_BUCKET}/VERSION" \
--endpoint-url "${S3_ENDPOINT}" \
--content-type "text/plain"