on aef00a3 help sign in
helix/.github/workflows/release.yml
261 lines 7.8 kB history raw
1name: Release
2on:
3 push:
4 tags:
5 - '[0-9]+.[0-9]+'
6 - '[0-9]+.[0-9]+.[0-9]+'
8jobs:
9 fetch-grammars:
10 name: Fetch Grammars
11 runs-on: ubuntu-latest
12 steps:
13 - name: Checkout sources
14 uses: actions/checkout@v3
16 - name: Install stable toolchain
17 uses: helix-editor/rust-toolchain@v1
18 with:
19 profile: minimal
20 override: true
22 - uses: Swatinem/rust-cache@v1
24 - name: Fetch tree-sitter grammars
25 uses: actions-rs/cargo@v1
26 with:
27 command: run
28 args: --package=helix-loader --bin=hx-loader
30 - name: Bundle grammars
31 run: tar cJf grammars.tar.xz -C runtime/grammars/sources .
33 - uses: actions/upload-artifact@v3
34 with:
35 name: grammars
36 path: grammars.tar.xz
38 dist:
39 name: Dist
40 needs: [fetch-grammars]
41 runs-on: ${{ matrix.os }}
42 strategy:
43 fail-fast: false # don't fail other jobs if one fails
44 matrix:
45 build: [x86_64-linux, x86_64-macos, x86_64-windows] #, x86_64-win-gnu, win32-msvc
46 include:
47 - build: x86_64-linux
48 os: ubuntu-20.04
49 rust: stable
50 target: x86_64-unknown-linux-gnu
51 cross: false
52 # - build: aarch64-linux
53 # os: ubuntu-20.04
54 # rust: stable
55 # target: aarch64-unknown-linux-gnu
56 # cross: true
57 - build: x86_64-macos
58 os: macos-latest
59 rust: stable
60 target: x86_64-apple-darwin
61 cross: false
62 - build: x86_64-windows
63 os: windows-2019
64 rust: stable
65 target: x86_64-pc-windows-msvc
66 cross: false
67 - build: aarch64-macos
68 os: macos-latest
69 rust: stable
70 target: aarch64-apple-darwin
71 cross: false
72 skip_tests: true # x86_64 host can't run aarch64 code
73 # - build: x86_64-win-gnu
74 # os: windows-2019
75 # rust: stable-x86_64-gnu
76 # target: x86_64-pc-windows-gnu
77 # - build: win32-msvc
78 # os: windows-2019
79 # rust: stable
80 # target: i686-pc-windows-msvc
82 steps:
83 - name: Checkout sources
84 uses: actions/checkout@v3
86 - name: Download grammars
87 uses: actions/download-artifact@v3
89 - name: Move grammars under runtime
90 if: "!startsWith(matrix.os, 'windows')"
91 run: |
92 mkdir -p runtime/grammars/sources
93 tar xJf grammars/grammars.tar.xz -C runtime/grammars/sources
95 - name: Install ${{ matrix.rust }} toolchain
96 uses: actions-rs/toolchain@v1
97 with:
98 profile: minimal
99 toolchain: ${{ matrix.rust }}
100 target: ${{ matrix.target }}
101 override: true
103 - name: Run cargo test
104 uses: actions-rs/cargo@v1
105 if: "!matrix.skip_tests"
106 with:
107 use-cross: ${{ matrix.cross }}
108 command: test
109 args: --release --locked --target ${{ matrix.target }} --workspace
111 - name: Build release binary
112 uses: actions-rs/cargo@v1
113 with:
114 use-cross: ${{ matrix.cross }}
115 command: build
116 args: --release --locked --target ${{ matrix.target }}
118 - name: Strip release binary (linux and macos)
119 if: matrix.build == 'x86_64-linux' || endsWith(matrix.build, 'macos')
120 run: strip "target/${{ matrix.target }}/release/hx"
122 - name: Strip release binary (arm)
123 if: matrix.build == 'aarch64-linux'
124 run: |
125 docker run --rm -v \
126 "$PWD/target:/target:Z" \
127 rustembedded/cross:${{ matrix.target }} \
128 aarch64-linux-gnu-strip \
129 /target/${{ matrix.target }}/release/hx
131 - name: Build AppImage
132 shell: bash
133 if: matrix.build == 'x86_64-linux'
134 run: |
135 mkdir dist
137 name=dev
138 if [[ $GITHUB_REF == refs/tags/* ]]; then
139 name=${GITHUB_REF:10}
140 fi
142 export VERSION="$name"
143 export ARCH=x86_64
144 export APP=helix
145 export OUTPUT="helix-$VERSION-$ARCH.AppImage"
146 export UPDATE_INFORMATION="gh-releases-zsync|$GITHUB_REPOSITORY_OWNER|helix|latest|$APP-*-$ARCH.AppImage.zsync"
148 mkdir -p "$APP.AppDir"/usr/{bin,lib/helix}
150 cp "target/${{ matrix.target }}/release/hx" "$APP.AppDir/usr/bin/hx"
151 rm -rf runtime/grammars/sources
152 cp -r runtime "$APP.AppDir/usr/lib/helix/runtime"
154 cat << 'EOF' > "$APP.AppDir/AppRun"
155 #!/bin/sh
157 APPDIR="$(dirname "$(readlink -f "${0}")")"
158 HELIX_RUNTIME="$APPDIR/usr/lib/helix/runtime" exec "$APPDIR/usr/bin/hx" "$@"
159 EOF
160 chmod 755 "$APP.AppDir/AppRun"
162 curl -Lo linuxdeploy-x86_64.AppImage \
163 https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
164 chmod +x linuxdeploy-x86_64.AppImage
166 ./linuxdeploy-x86_64.AppImage \
167 --appdir "$APP.AppDir" -d contrib/Helix.desktop \
168 -i contrib/helix.png --output appimage
170 mv "$APP-$VERSION-$ARCH.AppImage" \
171 "$APP-$VERSION-$ARCH.AppImage.zsync" dist
173 - name: Build archive
174 shell: bash
175 run: |
176 mkdir -p dist
177 if [ "${{ matrix.os }}" = "windows-2019" ]; then
178 cp "target/${{ matrix.target }}/release/hx.exe" "dist/"
179 else
180 cp "target/${{ matrix.target }}/release/hx" "dist/"
181 fi
182 if [ -d runtime/grammars/sources ]; then
183 rm -rf runtime/grammars/sources
184 fi
185 cp -r runtime dist
187 - uses: actions/upload-artifact@v3
188 with:
189 name: bins-${{ matrix.build }}
190 path: dist
192 publish:
193 name: Publish
194 needs: [dist]
195 runs-on: ubuntu-latest
196 steps:
197 - name: Checkout sources
198 uses: actions/checkout@v3
200 - uses: actions/download-artifact@v3
202 - name: Calculate tag name
203 run: |
204 name=dev
205 if [[ $GITHUB_REF == refs/tags/* ]]; then
206 name=${GITHUB_REF:10}
207 fi
208 echo ::set-output name=val::$name
209 echo TAG=$name >> $GITHUB_ENV
210 id: tagname
212 - name: Build archive
213 shell: bash
214 run: |
215 set -ex
217 source="$(pwd)"
218 mkdir -p runtime/grammars/sources
219 tar xJf grammars/grammars.tar.xz -C runtime/grammars/sources
220 rm -rf grammars
222 cd "$(mktemp -d)"
223 mv $source/bins-* .
224 mkdir dist
226 for dir in bins-* ; do
227 platform=${dir#"bins-"}
228 if [[ $platform =~ "windows" ]]; then
229 exe=".exe"
230 fi
231 pkgname=helix-$TAG-$platform
232 mkdir $pkgname
233 cp $source/LICENSE $source/README.md $pkgname
234 mkdir $pkgname/contrib
235 cp -r $source/contrib/completion $pkgname/contrib
236 mv bins-$platform/runtime $pkgname/
237 mv bins-$platform/hx$exe $pkgname
238 chmod +x $pkgname/hx$exe
240 if [[ "$platform" = "x86_64-linux" ]]; then
241 mv bins-$platform/helix-*.AppImage* dist/
242 fi
244 if [ "$exe" = "" ]; then
245 tar cJf dist/$pkgname.tar.xz $pkgname
246 else
247 7z a -r dist/$pkgname.zip $pkgname
248 fi
249 done
251 tar cJf dist/helix-$TAG-source.tar.xz -C $source .
252 mv dist $source/
254 - name: Upload binaries to release
255 uses: svenstaro/upload-release-action@v2
256 with:
257 repo_token: ${{ secrets.GITHUB_TOKEN }}
258 file: dist/*
259 file_glob: true
260 tag: ${{ steps.tagname.outputs.val }}
261 overwrite: true