fork/helix

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

RoloEditsci: add arm64 runner (#13273)34aa4d41

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