on aa00a47 help sign in
helix/.github/workflows/release.yml
291 lines 8.9 kB history raw
1name: Release
2on:
3 push:
4 tags:
5 - '[0-9]+.[0-9]+'
6 - '[0-9]+.[0-9]+.[0-9]+'
7 branches:
8 - 'patch/ci-release-*'
9 pull_request:
10 paths:
11 - '.github/workflows/release.yml'
13env:
14 # Preview mode: Publishes the build output as a CI artifact instead of creating
15 # a release, allowing for manual inspection of the output. This mode is
16 # activated if the CI run was triggered by events other than pushed tags, or
17 # if the repository is a fork.
18 preview: ${{ !startsWith(github.ref, 'refs/tags/') || github.repository != 'helix-editor/helix' }}
20jobs:
21 fetch-grammars:
22 name: Fetch Grammars
23 runs-on: ubuntu-latest
24 steps:
25 - name: Checkout sources
26 uses: actions/checkout@v3
28 - name: Install stable toolchain
29 uses: helix-editor/rust-toolchain@v1
30 with:
31 profile: minimal
32 override: true
34 - uses: Swatinem/rust-cache@v1
36 - name: Fetch tree-sitter grammars
37 uses: actions-rs/cargo@v1
38 with:
39 command: run
40 args: --package=helix-loader --bin=hx-loader
42 - name: Bundle grammars
43 run: tar cJf grammars.tar.xz -C runtime/grammars/sources .
45 - uses: actions/upload-artifact@v3
46 with:
47 name: grammars
48 path: grammars.tar.xz
50 dist:
51 name: Dist
52 needs: [fetch-grammars]
53 runs-on: ${{ matrix.os }}
54 strategy:
55 fail-fast: false # don't fail other jobs if one fails
56 matrix:
57 build: [x86_64-linux, x86_64-macos, x86_64-windows] #, x86_64-win-gnu, win32-msvc
58 include:
59 - build: x86_64-linux
60 os: ubuntu-20.04
61 rust: stable
62 target: x86_64-unknown-linux-gnu
63 cross: false
64 - build: aarch64-linux
65 os: ubuntu-20.04
66 rust: stable
67 target: aarch64-unknown-linux-gnu
68 cross: true
69 - build: riscv64-linux
70 os: ubuntu-20.04
71 rust: stable
72 target: riscv64gc-unknown-linux-gnu
73 cross: true
74 - build: x86_64-macos
75 os: macos-latest
76 rust: stable
77 target: x86_64-apple-darwin
78 cross: false
79 - build: x86_64-windows
80 os: windows-2019
81 rust: stable
82 target: x86_64-pc-windows-msvc
83 cross: false
84 - build: aarch64-macos
85 os: macos-latest
86 rust: stable
87 target: aarch64-apple-darwin
88 cross: false
89 skip_tests: true # x86_64 host can't run aarch64 code
90 # - build: x86_64-win-gnu
91 # os: windows-2019
92 # rust: stable-x86_64-gnu
93 # target: x86_64-pc-windows-gnu
94 # - build: win32-msvc
95 # os: windows-2019
96 # rust: stable
97 # target: i686-pc-windows-msvc
99 steps:
100 - name: Checkout sources
101 uses: actions/checkout@v3
103 - name: Download grammars
104 uses: actions/download-artifact@v3
106 - name: Move grammars under runtime
107 if: "!startsWith(matrix.os, 'windows')"
108 run: |
109 mkdir -p runtime/grammars/sources
110 tar xJf grammars/grammars.tar.xz -C runtime/grammars/sources
112 - name: Install ${{ matrix.rust }} toolchain
113 uses: actions-rs/toolchain@v1
114 with:
115 profile: minimal
116 toolchain: ${{ matrix.rust }}
117 target: ${{ matrix.target }}
118 override: true
120 # Install a pre-release version of Cross
121 # TODO: We need to pre-install Cross because we need cross-rs/cross#591 to
122 # get a newer C++ compiler toolchain. Remove this step when Cross
123 # 0.3.0, which includes cross-rs/cross#591, is released.
124 - name: Install Cross
125 if: "matrix.cross"
126 run: cargo install cross --git https://github.com/cross-rs/cross.git --rev 47df5c76e7cba682823a0b6aa6d95c17b31ba63a
128 - name: Run cargo test
129 uses: actions-rs/cargo@v1
130 if: "!matrix.skip_tests"
131 with:
132 use-cross: ${{ matrix.cross }}
133 command: test
134 args: --release --locked --target ${{ matrix.target }} --workspace
136 - name: Set profile.release.strip = true
137 shell: bash
138 run: |
139 cat >> .cargo/config.toml <<EOF
140 [profile.release]
141 strip = true
142 EOF
144 - name: Build release binary
145 uses: actions-rs/cargo@v1
146 with:
147 use-cross: ${{ matrix.cross }}
148 command: build
149 args: --release --locked --target ${{ matrix.target }}
151 - name: Build AppImage
152 shell: bash
153 if: matrix.build == 'aarch64-linux' || matrix.build == 'x86_64-linux'
154 run: |
155 mkdir dist
157 name=dev
158 if [[ $GITHUB_REF == refs/tags/* ]]; then
159 name=${GITHUB_REF:10}
160 fi
162 build="${{ matrix.build }}"
164 export VERSION="$name"
165 export ARCH=${build%-linux}
166 export APP=helix
167 export OUTPUT="helix-$VERSION-$ARCH.AppImage"
168 export UPDATE_INFORMATION="gh-releases-zsync|$GITHUB_REPOSITORY_OWNER|helix|latest|$APP-*-$ARCH.AppImage.zsync"
170 mkdir -p "$APP.AppDir"/usr/{bin,lib/helix}
172 cp "target/${{ matrix.target }}/release/hx" "$APP.AppDir/usr/bin/hx"
173 rm -rf runtime/grammars/sources
174 cp -r runtime "$APP.AppDir/usr/lib/helix/runtime"
176 cat << 'EOF' > "$APP.AppDir/AppRun"
177 #!/bin/sh
179 APPDIR="$(dirname "$(readlink -f "${0}")")"
180 HELIX_RUNTIME="$APPDIR/usr/lib/helix/runtime" exec "$APPDIR/usr/bin/hx" "$@"
181 EOF
182 chmod 755 "$APP.AppDir/AppRun"
184 curl -Lo linuxdeploy-x86_64.AppImage \
185 https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
186 chmod +x linuxdeploy-x86_64.AppImage
188 ./linuxdeploy-x86_64.AppImage \
189 --appdir "$APP.AppDir" -d contrib/Helix.desktop \
190 -i contrib/helix.png --output appimage
192 mv "$APP-$VERSION-$ARCH.AppImage" \
193 "$APP-$VERSION-$ARCH.AppImage.zsync" dist
195 - name: Build archive
196 shell: bash
197 run: |
198 mkdir -p dist
199 if [ "${{ matrix.os }}" = "windows-2019" ]; then
200 cp "target/${{ matrix.target }}/release/hx.exe" "dist/"
201 else
202 cp "target/${{ matrix.target }}/release/hx" "dist/"
203 fi
204 if [ -d runtime/grammars/sources ]; then
205 rm -rf runtime/grammars/sources
206 fi
207 cp -r runtime dist
209 - uses: actions/upload-artifact@v3
210 with:
211 name: bins-${{ matrix.build }}
212 path: dist
214 publish:
215 name: Publish
216 needs: [dist]
217 runs-on: ubuntu-latest
218 steps:
219 - name: Checkout sources
220 uses: actions/checkout@v3
222 - uses: actions/download-artifact@v3
224 - name: Calculate tag name
225 run: |
226 name=dev
227 if [[ $GITHUB_REF == refs/tags/* ]]; then
228 name=${GITHUB_REF:10}
229 fi
230 echo ::set-output name=val::$name
231 echo TAG=$name >> $GITHUB_ENV
232 id: tagname
234 - name: Build archive
235 shell: bash
236 run: |
237 set -ex
239 source="$(pwd)"
240 mkdir -p runtime/grammars/sources
241 tar xJf grammars/grammars.tar.xz -C runtime/grammars/sources
242 rm -rf grammars
244 cd "$(mktemp -d)"
245 mv $source/bins-* .
246 mkdir dist
248 for dir in bins-* ; do
249 platform=${dir#"bins-"}
250 if [[ $platform =~ "windows" ]]; then
251 exe=".exe"
252 fi
253 pkgname=helix-$TAG-$platform
254 mkdir $pkgname
255 cp $source/LICENSE $source/README.md $pkgname
256 mkdir $pkgname/contrib
257 cp -r $source/contrib/completion $pkgname/contrib
258 mv bins-$platform/runtime $pkgname/
259 mv bins-$platform/hx$exe $pkgname
260 chmod +x $pkgname/hx$exe
262 if [[ "$platform" = "aarch64-linux" || "$platform" = "x86_64-linux" ]]; then
263 mv bins-$platform/helix-*.AppImage* dist/
264 fi
266 if [ "$exe" = "" ]; then
267 tar cJf dist/$pkgname.tar.xz $pkgname
268 else
269 7z a -r dist/$pkgname.zip $pkgname
270 fi
271 done
273 tar cJf dist/helix-$TAG-source.tar.xz -C $source .
274 mv dist $source/
276 - name: Upload binaries to release
277 uses: svenstaro/upload-release-action@v2
278 if: env.preview == 'false'
279 with:
280 repo_token: ${{ secrets.GITHUB_TOKEN }}
281 file: dist/*
282 file_glob: true
283 tag: ${{ steps.tagname.outputs.val }}
284 overwrite: true
286 - name: Upload binaries as artifact
287 uses: actions/upload-artifact@v3
288 if: env.preview == 'true'
289 with:
290 name: release
291 path: dist/*