on 376c19e help sign in
helix/.github/workflows/release.yml
284 lines 9.0 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: dtolnay/rust-toolchain@stable
31 - uses: Swatinem/rust-cache@v2
33 - name: Fetch tree-sitter grammars
34 run: cargo run --package=helix-loader --bin=hx-loader
36 - name: Bundle grammars
37 run: tar cJf grammars.tar.xz -C runtime/grammars/sources .
39 - uses: actions/upload-artifact@v3
40 with:
41 name: grammars
42 path: grammars.tar.xz
44 dist:
45 name: Dist
46 needs: [fetch-grammars]
47 env:
48 # For some builds, we use cross to test on 32-bit and big-endian
49 # systems.
50 CARGO: cargo
51 # When CARGO is set to CROSS, this is set to `--target matrix.target`.
52 TARGET_FLAGS:
53 # When CARGO is set to CROSS, TARGET_DIR includes matrix.target.
54 TARGET_DIR: ./target
55 # Emit backtraces on panics.
56 RUST_BACKTRACE: 1
57 runs-on: ${{ matrix.os }}
58 strategy:
59 fail-fast: false # don't fail other jobs if one fails
60 matrix:
61 build: [x86_64-linux, x86_64-macos, x86_64-windows] #, x86_64-win-gnu, win32-msvc
62 include:
63 - build: x86_64-linux
64 os: ubuntu-latest
65 rust: stable
66 target: x86_64-unknown-linux-gnu
67 cross: false
68 - build: aarch64-linux
69 os: ubuntu-latest
70 rust: stable
71 target: aarch64-unknown-linux-gnu
72 cross: true
73 - build: riscv64-linux
74 os: ubuntu-latest
75 rust: stable
76 target: riscv64gc-unknown-linux-gnu
77 cross: true
78 - build: x86_64-macos
79 os: macos-latest
80 rust: stable
81 target: x86_64-apple-darwin
82 cross: false
83 - build: x86_64-windows
84 os: windows-latest
85 rust: stable
86 target: x86_64-pc-windows-msvc
87 cross: false
88 - build: aarch64-macos
89 os: macos-latest
90 rust: stable
91 target: aarch64-apple-darwin
92 cross: false
93 skip_tests: true # x86_64 host can't run aarch64 code
94 # - build: x86_64-win-gnu
95 # os: windows-2019
96 # rust: stable-x86_64-gnu
97 # target: x86_64-pc-windows-gnu
98 # - build: win32-msvc
99 # os: windows-2019
100 # rust: stable
101 # target: i686-pc-windows-msvc
103 steps:
104 - name: Checkout sources
105 uses: actions/checkout@v3
107 - name: Download grammars
108 uses: actions/download-artifact@v3
110 - name: Move grammars under runtime
111 if: "!startsWith(matrix.os, 'windows')"
112 run: |
113 mkdir -p runtime/grammars/sources
114 tar xJf grammars/grammars.tar.xz -C runtime/grammars/sources
116 - name: Install ${{ matrix.rust }} toolchain
117 uses: dtolnay/rust-toolchain@master
118 with:
119 toolchain: ${{ matrix.rust }}
120 target: ${{ matrix.target }}
122 # Install a pre-release version of Cross
123 # TODO: We need to pre-install Cross because we need cross-rs/cross#591 to
124 # get a newer C++ compiler toolchain. Remove this step when Cross
125 # 0.3.0, which includes cross-rs/cross#591, is released.
126 - name: Install Cross
127 if: "matrix.cross"
128 run: |
129 cargo install cross --git https://github.com/cross-rs/cross.git --rev 47df5c76e7cba682823a0b6aa6d95c17b31ba63a
130 echo "CARGO=cross" >> $GITHUB_ENV
131 # echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV
132 # echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
134 - name: Show command used for Cargo
135 run: |
136 echo "cargo command is: ${{ env.CARGO }}"
137 echo "target flag is: ${{ env.TARGET_FLAGS }}"
139 - name: Run cargo test
140 if: "!matrix.skip_tests"
141 run: ${{ env.CARGO }} test --release --locked --target ${{ matrix.target }} --workspace
143 - name: Set profile.release.strip = true
144 shell: bash
145 run: |
146 cat >> .cargo/config.toml <<EOF
147 [profile.release]
148 strip = true
149 EOF
151 - name: Build release binary
152 run: ${{ env.CARGO }} build --release --locked --target ${{ matrix.target }}
154 - name: Build AppImage
155 shell: bash
156 if: matrix.build == 'aarch64-linux' || matrix.build == 'x86_64-linux'
157 run: |
158 mkdir dist
160 name=dev
161 if [[ $GITHUB_REF == refs/tags/* ]]; then
162 name=${GITHUB_REF:10}
163 fi
165 build="${{ matrix.build }}"
167 export VERSION="$name"
168 export ARCH=${build%-linux}
169 export APP=helix
170 export OUTPUT="helix-$VERSION-$ARCH.AppImage"
171 export UPDATE_INFORMATION="gh-releases-zsync|$GITHUB_REPOSITORY_OWNER|helix|latest|$APP-*-$ARCH.AppImage.zsync"
173 mkdir -p "$APP.AppDir"/usr/{bin,lib/helix}
175 cp "target/${{ matrix.target }}/release/hx" "$APP.AppDir/usr/bin/hx"
176 rm -rf runtime/grammars/sources
177 cp -r runtime "$APP.AppDir/usr/lib/helix/runtime"
179 cat << 'EOF' > "$APP.AppDir/AppRun"
180 #!/bin/sh
182 APPDIR="$(dirname "$(readlink -f "${0}")")"
183 HELIX_RUNTIME="$APPDIR/usr/lib/helix/runtime" exec "$APPDIR/usr/bin/hx" "$@"
184 EOF
185 chmod 755 "$APP.AppDir/AppRun"
187 curl -Lo linuxdeploy-x86_64.AppImage \
188 https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
189 chmod +x linuxdeploy-x86_64.AppImage
191 ./linuxdeploy-x86_64.AppImage \
192 --appdir "$APP.AppDir" -d contrib/Helix.desktop \
193 -i contrib/helix.png --output appimage
195 mv "$APP-$VERSION-$ARCH.AppImage" \
196 "$APP-$VERSION-$ARCH.AppImage.zsync" dist
198 - name: Build archive
199 shell: bash
200 run: |
201 mkdir -p dist
202 if [ "${{ matrix.os }}" = "windows-2019" ]; then
203 cp "target/${{ matrix.target }}/release/hx.exe" "dist/"
204 else
205 cp "target/${{ matrix.target }}/release/hx" "dist/"
206 fi
207 if [ -d runtime/grammars/sources ]; then
208 rm -rf runtime/grammars/sources
209 fi
210 cp -r runtime dist
212 - uses: actions/upload-artifact@v3
213 with:
214 name: bins-${{ matrix.build }}
215 path: dist
217 publish:
218 name: Publish
219 needs: [dist]
220 runs-on: ubuntu-latest
221 steps:
222 - name: Checkout sources
223 uses: actions/checkout@v3
225 - uses: actions/download-artifact@v3
227 - name: Build archive
228 shell: bash
229 run: |
230 set -ex
232 source="$(pwd)"
233 mkdir -p runtime/grammars/sources
234 tar xJf grammars/grammars.tar.xz -C runtime/grammars/sources
235 rm -rf grammars
237 cd "$(mktemp -d)"
238 mv $source/bins-* .
239 mkdir dist
241 for dir in bins-* ; do
242 platform=${dir#"bins-"}
243 if [[ $platform =~ "windows" ]]; then
244 exe=".exe"
245 fi
246 pkgname=helix-$GITHUB_REF_NAME-$platform
247 mkdir $pkgname
248 cp $source/LICENSE $source/README.md $pkgname
249 mkdir $pkgname/contrib
250 cp -r $source/contrib/completion $pkgname/contrib
251 mv bins-$platform/runtime $pkgname/
252 mv bins-$platform/hx$exe $pkgname
253 chmod +x $pkgname/hx$exe
255 if [[ "$platform" = "aarch64-linux" || "$platform" = "x86_64-linux" ]]; then
256 mv bins-$platform/helix-*.AppImage* dist/
257 fi
259 if [ "$exe" = "" ]; then
260 tar cJf dist/$pkgname.tar.xz $pkgname
261 else
262 7z a -r dist/$pkgname.zip $pkgname
263 fi
264 done
266 tar cJf dist/helix-$GITHUB_REF_NAME-source.tar.xz -C $source .
267 mv dist $source/
269 - name: Upload binaries to release
270 uses: svenstaro/upload-release-action@v2
271 if: env.preview == 'false'
272 with:
273 repo_token: ${{ secrets.GITHUB_TOKEN }}
274 file: dist/*
275 file_glob: true
276 tag: ${{ github.ref_name }}
277 overwrite: true
279 - name: Upload binaries as artifact
280 uses: actions/upload-artifact@v3
281 if: env.preview == 'true'
282 with:
283 name: release
284 path: dist/*