fork/helix

git clone https://git.julia.blue/fork/helix

RoloEditsbuild: lower ubuntu version from `24.04` to `22.04`3c230c9b

25.07.1
9.7 KiB303 linesraw
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'
12
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' }}
19
20jobs:
21  fetch-grammars:
22    name: Fetch Grammars
23    runs-on: ubuntu-latest
24    steps:
25      - name: Checkout sources
26        uses: actions/checkout@v4
27
28      - name: Install stable toolchain
29        uses: dtolnay/rust-toolchain@stable
30
31      - uses: Swatinem/rust-cache@v2
32
33      - name: Fetch tree-sitter grammars
34        run: cargo run --package=helix-loader --bin=hx-loader
35
36      - name: Bundle grammars
37        run: tar cJf grammars.tar.xz -C runtime/grammars/sources .
38
39      - uses: actions/upload-artifact@v4
40        with:
41          name: grammars
42          path: grammars.tar.xz
43
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, aarch64-linux, x86_64-macos, x86_64-windows] #, x86_64-win-gnu, win32-msvc
62        include:
63        - build: x86_64-linux
64          # WARN: When changing this to a newer version, make sure that the GLIBC isnt too new, as this can cause issues
65          # with portablity on older systems that dont follow ubuntus more rapid release cadence.
66          os: ubuntu-22.04
67          rust: stable
68          target: x86_64-unknown-linux-gnu
69          cross: false
70        - build: aarch64-linux
71          # Version should be kept in lockstep with the x86_64 version
72          os: ubuntu-22.04-arm
73          rust: stable
74          target: aarch64-unknown-linux-gnu
75          cross: false
76        # - build: riscv64-linux
77        #   os: ubuntu-22.04
78        #   rust: stable
79        #   target: riscv64gc-unknown-linux-gnu
80        #   cross: true
81        - build: x86_64-macos
82          os: macos-latest
83          rust: stable
84          target: x86_64-apple-darwin
85          cross: false
86        - build: x86_64-windows
87          os: windows-latest
88          rust: stable
89          target: x86_64-pc-windows-msvc
90          cross: false
91        # 23.03: build issues
92        - build: aarch64-macos
93          os: macos-latest
94          rust: stable
95          target: aarch64-apple-darwin
96          cross: false
97          skip_tests: true  # x86_64 host can't run aarch64 code
98        # - build: x86_64-win-gnu
99        #   os: windows-2019
100        #   rust: stable-x86_64-gnu
101        #   target: x86_64-pc-windows-gnu
102        # - build: win32-msvc
103        #   os: windows-2019
104        #   rust: stable
105        #   target: i686-pc-windows-msvc
106
107    steps:
108      - name: Checkout sources
109        uses: actions/checkout@v4
110
111      - name: Download grammars
112        uses: actions/download-artifact@v4
113
114      - name: Move grammars under runtime
115        if: "!startsWith(matrix.os, 'windows')"
116        run: |
117          mkdir -p runtime/grammars/sources
118          tar xJf grammars/grammars.tar.xz -C runtime/grammars/sources
119
120      # The rust-toolchain action ignores rust-toolchain.toml files.
121      # Removing this before building with cargo ensures that the rust-toolchain
122      # is considered the same between installation and usage.
123      - name: Remove the rust-toolchain.toml file
124        run: rm rust-toolchain.toml
125
126      - name: Install ${{ matrix.rust }} toolchain
127        uses: dtolnay/rust-toolchain@master
128        with:
129          toolchain: ${{ matrix.rust }}
130          target: ${{ matrix.target }}
131
132      # Install a pre-release version of Cross
133      # TODO: We need to pre-install Cross because we need cross-rs/cross#591 to
134      #       get a newer C++ compiler toolchain. Remove this step when Cross
135      #       0.3.0, which includes cross-rs/cross#591, is released.
136      - name: Install Cross
137        if: "matrix.cross"
138        run: |
139          cargo install cross --git https://github.com/cross-rs/cross.git --rev 47df5c76e7cba682823a0b6aa6d95c17b31ba63a
140          echo "CARGO=cross" >> $GITHUB_ENV
141        # echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV
142        # echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
143
144      - name: Show command used for Cargo
145        run: |
146          echo "cargo command is: ${{ env.CARGO }}"
147          echo "target flag is: ${{ env.TARGET_FLAGS }}"
148
149      - name: Run cargo test
150        if: "!matrix.skip_tests"
151        run: ${{ env.CARGO }} test --release --locked --target ${{ matrix.target }} --workspace
152
153      - name: Build release binary
154        run: ${{ env.CARGO }} build --profile opt --locked --target ${{ matrix.target }}
155
156      - name: Build AppImage
157        shell: bash
158        if: matrix.build == 'x86_64-linux'
159        run: |
160          # Required as of 22.x https://github.com/AppImage/AppImageKit/wiki/FUSE
161          sudo add-apt-repository universe
162          sudo apt install libfuse2
163
164          mkdir dist
165
166          name=dev
167          if [[ $GITHUB_REF == refs/tags/* ]]; then
168            name=${GITHUB_REF:10}
169          fi
170
171          build="${{ matrix.build }}"
172
173          export VERSION="$name"
174          export ARCH=${build%-linux}
175          export APP=helix
176          export OUTPUT="helix-$VERSION-$ARCH.AppImage"
177          export UPDATE_INFORMATION="gh-releases-zsync|$GITHUB_REPOSITORY_OWNER|helix|latest|$APP-*-$ARCH.AppImage.zsync"
178
179          mkdir -p "$APP.AppDir"/usr/{bin,lib/helix}
180
181          cp "target/${{ matrix.target }}/opt/hx" "$APP.AppDir/usr/bin/hx"
182          rm -rf runtime/grammars/sources
183          cp -r runtime "$APP.AppDir/usr/lib/helix/runtime"
184
185          cat << 'EOF' > "$APP.AppDir/AppRun"
186          #!/bin/sh
187
188          APPDIR="$(dirname "$(readlink -f "${0}")")"
189          HELIX_RUNTIME="$APPDIR/usr/lib/helix/runtime" exec "$APPDIR/usr/bin/hx" "$@"
190          EOF
191          chmod 755 "$APP.AppDir/AppRun"
192
193          curl -Lo linuxdeploy-x86_64.AppImage \
194              https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
195          chmod +x linuxdeploy-x86_64.AppImage
196
197          ./linuxdeploy-x86_64.AppImage \
198              --appdir "$APP.AppDir" -d contrib/Helix.desktop \
199              -i contrib/helix.png --output appimage
200
201          mv "$APP-$VERSION-$ARCH.AppImage" \
202              "$APP-$VERSION-$ARCH.AppImage.zsync" dist
203
204      - name: Build Deb
205        shell: bash
206        if: matrix.build == 'x86_64-linux'
207        run: |
208          cargo install cargo-deb
209          mkdir -p target/release
210          cp target/${{ matrix.target }}/opt/hx target/release/
211          cargo deb --no-build
212          mkdir -p dist
213          mv target/debian/*.deb dist/
214
215      - name: Build archive
216        shell: bash
217        run: |
218          mkdir -p dist
219          if [ "${{ matrix.os }}" = "windows-2019" ]; then
220            cp "target/${{ matrix.target }}/opt/hx.exe" "dist/"
221          else
222            cp "target/${{ matrix.target }}/opt/hx" "dist/"
223          fi
224          if [ -d runtime/grammars/sources ]; then
225            rm -rf runtime/grammars/sources
226          fi
227          cp -r runtime dist
228
229      - uses: actions/upload-artifact@v4
230        with:
231          name: bins-${{ matrix.build }}
232          path: dist
233
234  publish:
235    name: Publish
236    needs: [dist]
237    runs-on: ubuntu-latest
238    steps:
239      - name: Checkout sources
240        uses: actions/checkout@v4
241
242      - uses: actions/download-artifact@v4
243
244      - name: Build archive
245        shell: bash
246        run: |
247          set -ex
248
249          source="$(pwd)"
250          tag=${GITHUB_REF_NAME//\//}
251          mkdir -p runtime/grammars/sources
252          tar xJf grammars/grammars.tar.xz -C runtime/grammars/sources
253          rm -rf grammars
254
255          cd "$(mktemp -d)"
256          mv $source/bins-* .
257          mkdir dist
258
259          for dir in bins-* ; do
260              platform=${dir#"bins-"}
261              if [[ $platform =~ "windows" ]]; then
262                  exe=".exe"
263              fi
264              pkgname=helix-$tag-$platform
265              mkdir -p $pkgname
266              cp $source/LICENSE $source/README.md $pkgname
267              mkdir $pkgname/contrib
268              cp -r $source/contrib/completion $pkgname/contrib
269              mv bins-$platform/runtime $pkgname/
270              mv bins-$platform/hx$exe $pkgname
271              chmod +x $pkgname/hx$exe
272
273              if [[ "$platform" = "x86_64-linux" ]]; then
274                  mv bins-$platform/helix-*.AppImage* dist/
275                  mv bins-$platform/*.deb dist/
276              fi
277
278              if [ "$exe" = "" ]; then
279                  tar cJf dist/$pkgname.tar.xz $pkgname
280              else
281                  7z a -r dist/$pkgname.zip $pkgname
282              fi
283          done
284
285          tar cJf dist/helix-$tag-source.tar.xz -C $source .
286          mv dist $source/
287
288      - name: Upload binaries to release
289        uses: svenstaro/upload-release-action@v2
290        if: env.preview == 'false'
291        with:
292          repo_token: ${{ secrets.GITHUB_TOKEN }}
293          file: dist/*
294          file_glob: true
295          tag: ${{ github.ref_name }}
296          overwrite: true
297
298      - name: Upload binaries as artifact
299        uses: actions/upload-artifact@v4
300        if: env.preview == 'true'
301        with:
302          name: release
303          path: dist/*