forked from lapce/lapce
-
Notifications
You must be signed in to change notification settings - Fork 0
282 lines (241 loc) · 8.98 KB
/
release.yml
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
name: Release
on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name for release'
required: false
default: nightly
push:
tags: ["v[0-9]+.[0-9]+.[0-9]+*"]
pull_request:
paths:
# trigger release workflow only if this file changed
- .github/workflows/release.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_TERM_COLOR: always
jobs:
tagname:
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.tag.outputs.tag }}
steps:
- if: github.event_name == 'workflow_dispatch'
run: echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
- if: github.event_name == 'schedule'
run: echo 'TAG_NAME=nightly' >> $GITHUB_ENV
- if: github.event_name == 'push'
run: |
TAG_NAME=${{ github.ref }}
echo "TAG_NAME=${TAG_NAME#refs/tags/}" >> $GITHUB_ENV
- if: github.event_name == 'pull_request'
run: echo 'TAG_NAME=debug' >> $GITHUB_ENV
- id: vars
shell: bash
run: echo "sha_short=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
- if: env.TAG_NAME == 'nightly'
run: echo 'TAG_NAME=nightly-${{ steps.vars.outputs.sha_short }}' >> $GITHUB_ENV
- id: tag
run: echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT
windows:
runs-on: windows-latest
needs: tagname
env:
RELEASE_TAG_NAME: ${{ needs.tagname.outputs.tag_name }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v3
- name: Update rust
run: rustup update
- name: Fetch dependencies
run: cargo fetch --locked
- name: Build
run: cargo build --frozen --profile release-lto
- name: Install WiX
run: nuget install WiX
- name: Crate msi installer
run: |
./WiX.*/tools/candle.exe -arch "x64" -ext WixUIExtension -ext WixUtilExtension \
-out "./lapce.wixobj" "extra/windows/wix/lapce.wxs"
./WiX.*/tools/light.exe -ext WixUIExtension -ext WixUtilExtension \
-out "./Lapce-windows.msi" -sice:ICE61 -sice:ICE91 \
"./lapce.wixobj"
- name: Create portable
shell: pwsh
run: |
cargo build --profile release-lto --features lapce-ui/portable
Compress-Archive ./target/release-lto/lapce.exe ./Lapce-windows-portable.zip
- name: Create lapce-proxy archive
shell: pwsh
run: |
$file = [System.IO.File]::Open((Join-Path $PWD '.\target\release-lto\lapce-proxy.exe'), [System.IO.FileMode]::Open)
$archive = [System.IO.File]::Create((Join-Path $PWD '.\lapce-proxy-windows-x86_64.gz'))
$compressor = [System.IO.Compression.GZipStream]::new($archive, [System.IO.Compression.CompressionMode]::Compress)
$file.CopyTo($compressor)
Start-Sleep -Seconds 10
$compressor.close()
- uses: actions/upload-artifact@v3
with:
name: lapce-windows
path: |
./lapce-proxy-windows-*.gz
./Lapce-windows-portable.zip
./Lapce-windows.msi
retention-days: 1
linux:
runs-on: ubuntu-latest
container: ubuntu:18.04
needs: tagname
env:
RELEASE_TAG_NAME: ${{ needs.tagname.outputs.tag_name }}
DEBIAN_FRONTEND: noninteractive
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
apt-get -y update
apt-get -y install cmake pkg-config libfontconfig-dev libgtk-3-dev
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-unknown-linux-gnu
profile: minimal
- name: Fetch dependencies
run: cargo fetch --locked
- name: Build
run: cargo build --frozen --profile release-lto --bin lapce
- name: Gzip
run: |
mkdir Lapce
cp ./target/release-lto/lapce Lapce/
tar -zcvf ./Lapce-linux.tar.gz Lapce
- uses: actions/upload-artifact@v3
with:
name: lapce-linux
path: |
./Lapce-linux.tar.gz
retention-days: 1
linux-musl:
name: Build lapce-proxy for ${{ matrix.platform }}
runs-on: ubuntu-latest
needs: tagname
env:
RELEASE_TAG_NAME: ${{ needs.tagname.outputs.tag_name }}
CROSS_SYSROOT: /mnt/alpine-${{ matrix.platform }}
PACKAGES: >
zlib-static freetype-static fontconfig-static
libgit2-static libssh2-static openssl-libs-static
libssl3 gtk+3.0-dev http-parser-dev rustup
build-base openssl-dev git lld clang
strategy:
fail-fast: false
matrix:
include:
- triple: x86_64-unknown-linux-musl
platform: x86_64
- triple: aarch64-unknown-linux-musl
platform: aarch64
steps:
- uses: actions/checkout@v3
- name: Set up Alpine Linux for ${{ matrix.platform }} (target arch)
id: alpine-target
uses: jirutka/setup-alpine@v1
with:
arch: ${{ matrix.platform }}
branch: edge
packages: ${{ env.PACKAGES }}
shell-name: alpine-target.sh
- name: Set up Alpine Linux for x86_64 (build arch)
uses: jirutka/setup-alpine@v1
with:
arch: x86_64
branch: edge
packages: ${{ env.PACKAGES }}
volumes: ${{ steps.alpine-target.outputs.root-path }}:${{ env.CROSS_SYSROOT }}
shell-name: alpine.sh
- name: Install Rust stable toolchain via rustup
run: rustup-init --target ${{ matrix.triple }} --default-toolchain stable --profile minimal -y
shell: alpine.sh {0}
- name: Build ${{ matrix.triple }}
shell: alpine.sh {0}
env:
LIBZ_SYS_STATIC: 1
LIBSSH2_STATIC: 1
LIBGIT2_STATIC: 1
OPENSSL_STATIC: 1
OPENSSL_DIR: ${{ env.CROSS_SYSROOT }}/usr # static/dynamic lib workaround <3
OPENSSL_NO_VENDOR: 1 # don't even try to build without it on musl
PKG_CONFIG_ALL_STATIC: 1
PKG_CONFIG_LIBDIR: ${{ env.CROSS_SYSROOT }}/usr/lib/pkgconfig
RUSTFLAGS: -C target-feature=+crt-static -C linker=/usr/bin/ld.lld # link runtime static, use universal linker
CARGO_BUILD_TARGET: ${{ matrix.triple }}
CARGO_PROFILE_RELEASE_LTO: 'true'
CARGO_PROFILE_RELEASE_STRIP: symbols # remove unneeded debug stuff
CARGO_PROFILE_RELEASE_OPT_LEVEL: 's' # optimise for size
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: '1' # optimise each crate
SYSROOT: /dummy # workaround for https://github.com/rust-lang/pkg-config-rs/issues/102
CC: clang
run: |
# Workaround for https://github.com/rust-lang/pkg-config-rs/issues/102
echo -e '#!/bin/sh\nPKG_CONFIG_SYSROOT_DIR=${{ env.CROSS_SYSROOT }} exec pkgconf "$@"' \
| install -m755 /dev/stdin pkg-config
export PKG_CONFIG="$(pwd)/pkg-config"
cargo fetch --locked
cargo build \
--frozen \
--verbose \
--release \
--bin lapce-proxy \
--manifest-path lapce-proxy/Cargo.toml
- name: Gzip
run: |
gzip -c ./target/${{ matrix.triple }}/release/lapce-proxy > ./lapce-proxy-linux-${{ matrix.platform }}.gz
- uses: actions/upload-artifact@v3
with:
name: lapce-proxy-linux-${{ matrix.platform }}
path: |
./lapce-proxy-linux-*.gz
retention-days: 1
publish:
if: github.event_name != 'pull_request'
needs: [linux, linux-musl, windows]
runs-on: ubuntu-latest
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
# Must perform checkout first, since it deletes the target directory
# before running, and would therefore delete the downloaded artifacts
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- if: github.event_name == 'workflow_dispatch'
run: echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
- if: github.event_name == 'schedule'
run: echo 'TAG_NAME=nightly' >> $GITHUB_ENV
- if: github.event_name == 'push'
run: |
TAG_NAME=${{ github.ref }}
echo "TAG_NAME=${TAG_NAME#refs/tags/}" >> $GITHUB_ENV
- if: env.TAG_NAME == 'nightly'
run: |
(echo 'SUBJECT=Lapce development build';
echo 'PRERELEASE=--prerelease') >> $GITHUB_ENV
gh release delete nightly --yes || true
git push origin :nightly || true
- if: env.TAG_NAME != 'nightly'
run: |
(echo 'SUBJECT=Lapce release build';
echo 'PRERELEASE=') >> $GITHUB_ENV
- name: Publish release
env:
DEBUG: api
run: |
gh release create $TAG_NAME $PRERELEASE --title "$TAG_NAME" --target $GITHUB_SHA lapce-linux/* lapce-proxy-linux-*/* lapce-windows/*