fork/helix

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

dependabot[bot]build(deps): bump actions/download-artifact from 6 to 7 (#14974)9f05144a

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