fork/helix
git clone https://git.julia.blue/fork/helix
9f05144a
master
1name : Release 2on : 3push : 4tags : 5- '[0-9]+.[0-9]+' 6- '[0-9]+.[0-9]+.[0-9]+' 7branches : 8- 'patch/ci-release-*' 9pull_request : 10paths : 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. 18preview : ${{ !startsWith(github.ref, 'refs/tags/') || github.repository != 'helix-editor/helix' }} 19 20jobs : 21fetch-grammars : 22name : Fetch Grammars 23runs-on : ubuntu-latest 24steps : 25- name : Checkout sources 26uses : actions/checkout@v6 27 28- name : Install stable toolchain 29uses : dtolnay/rust-toolchain@stable 30 31- uses : Swatinem/rust-cache@v2 32 33- name : Fetch tree-sitter grammars 34run : cargo run --package=helix-loader --bin=hx-loader 35 36- name : Bundle grammars 37run : tar cJf grammars.tar.xz -C runtime/grammars/sources . 38 39- uses : actions/upload-artifact@v6 40with : 41name : grammars 42path : grammars.tar.xz 43 44dist : 45name : Dist 46needs : [ fetch-grammars ] 47env : 48# For some builds, we use cross to test on 32-bit and big-endian 49# systems. 50CARGO : cargo 51# When CARGO is set to CROSS, this is set to `--target matrix.target`. 52TARGET_FLAGS : 53# When CARGO is set to CROSS, TARGET_DIR includes matrix.target. 54TARGET_DIR : ./target 55# Emit backtraces on panics. 56RUST_BACKTRACE : 1 57runs-on : ${{ matrix.os }} 58strategy : 59fail-fast : false # don't fail other jobs if one fails 60matrix : 61build : [ x86_64-linux , aarch64-linux , x86_64-macos , x86_64-windows , aarch64-macos ] #, x86_64-win-gnu, win32-msvc 62include : 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. 66os : ubuntu-22.04 67rust : stable 68target : x86_64-unknown-linux-gnu 69cross : false 70- build : aarch64-linux 71# Version should be kept in lockstep with the x86_64 version 72os : ubuntu-22.04-arm 73rust : stable 74target : aarch64-unknown-linux-gnu 75cross : false 76- build : x86_64-macos 77os : macos-latest 78rust : stable 79target : x86_64-apple-darwin 80cross : false 81- build : x86_64-windows 82os : windows-latest 83rust : stable 84target : x86_64-pc-windows-msvc 85cross : false 86- build : aarch64-macos 87os : macos-latest 88rust : stable 89target : aarch64-apple-darwin 90cross : 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 105steps : 106- name : Checkout sources 107uses : actions/checkout@v6 108 109- name : Download grammars 110uses : actions/download-artifact@v7 111 112- name : Move grammars under runtime 113if : "!startsWith(matrix.os, 'windows')" 114run : | 115mkdir -p runtime/grammars/sources 116tar 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 122run : rm rust-toolchain.toml 123 124- name : Install ${{ matrix.rust }} toolchain 125uses : dtolnay/rust-toolchain@master 126with : 127toolchain : ${{ matrix.rust }} 128target : ${{ 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 135if : "matrix.cross" 136run : | 137cargo install cross --git https://github.com/cross-rs/cross.git --rev 47df5c76e7cba682823a0b6aa6d95c17b31ba63a 138echo "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 143run : | 144echo "cargo command is: ${{ env.CARGO }}" 145echo "target flag is: ${{ env.TARGET_FLAGS }}" 146 147- name : Run cargo test 148if : "!matrix.skip_tests" 149run : ${{ env.CARGO }} test --release --locked --target ${{ matrix.target }} --workspace 150 151- name : Build release binary 152run : ${{ env.CARGO }} build --profile opt --locked --target ${{ matrix.target }} 153 154- name : Build AppImage 155shell : bash 156if : matrix.build == 'x86_64-linux' 157run : | 158# Required as of 22.x https://github.com/AppImage/AppImageKit/wiki/FUSE 159sudo add-apt-repository universe 160sudo apt install libfuse2 161 162mkdir dist 163 164name=dev 165if [[ $GITHUB_REF == refs/tags/* ]]; then 166name=${GITHUB_REF:10} 167fi 168 169build="${{ matrix.build }}" 170 171export VERSION="$name" 172export ARCH=${build%-linux} 173export APP=helix 174export OUTPUT="helix-$VERSION-$ARCH.AppImage" 175export UPDATE_INFORMATION="gh-releases-zsync|$GITHUB_REPOSITORY_OWNER|helix|latest|$APP-*-$ARCH.AppImage.zsync" 176 177mkdir -p "$APP.AppDir"/usr/{bin,lib/helix} 178 179cp "target/${{ matrix.target }}/opt/hx" "$APP.AppDir/usr/bin/hx" 180rm -rf runtime/grammars/sources 181cp -r runtime "$APP.AppDir/usr/lib/helix/runtime" 182 183cat << 'EOF' > "$APP.AppDir/AppRun" 184#!/bin/sh 185 186APPDIR="$(dirname "$(readlink -f "${0}")")" 187HELIX_RUNTIME="$APPDIR/usr/lib/helix/runtime" exec "$APPDIR/usr/bin/hx" "$@" 188EOF 189chmod 755 "$APP.AppDir/AppRun" 190 191curl -Lo linuxdeploy-x86_64.AppImage \ 192https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage 193chmod +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 199mv "$APP-$VERSION-$ARCH.AppImage" \ 200"$APP-$VERSION-$ARCH.AppImage.zsync" dist 201 202- name : Build Deb 203shell : bash 204if : matrix.build == 'x86_64-linux' 205run : | 206cargo install cargo-deb 207mkdir -p target/release 208cp target/${{ matrix.target }}/opt/hx target/release/ 209cargo deb --no-build 210mkdir -p dist 211mv target/debian/*.deb dist/ 212 213- name : Build archive 214shell : bash 215run : | 216mkdir -p dist 217if [ "${{ matrix.os }}" = "windows-latest" ]; then 218cp "target/${{ matrix.target }}/opt/hx.exe" "dist/" 219else 220cp "target/${{ matrix.target }}/opt/hx" "dist/" 221fi 222if [ -d runtime/grammars/sources ]; then 223rm -rf runtime/grammars/sources 224fi 225cp -r runtime dist 226 227- uses : actions/upload-artifact@v6 228with : 229name : bins-${{ matrix.build }} 230path : dist 231 232publish : 233name : Publish 234needs : [ dist ] 235runs-on : ubuntu-latest 236steps : 237- name : Checkout sources 238uses : actions/checkout@v6 239 240- uses : actions/download-artifact@v7 241 242- name : Build archive 243shell : bash 244run : | 245set -ex 246 247source="$(pwd)" 248tag=${GITHUB_REF_NAME//\//} 249mkdir -p runtime/grammars/sources 250tar xJf grammars/grammars.tar.xz -C runtime/grammars/sources 251rm -rf grammars 252 253cd "$(mktemp -d)" 254mv $source/bins-* . 255mkdir dist 256 257for dir in bins-* ; do 258platform=${dir#"bins-"} 259if [[ $platform =~ "windows" ]]; then 260exe=".exe" 261fi 262pkgname=helix-$tag-$platform 263mkdir -p $pkgname 264cp $source/LICENSE $source/README.md $pkgname 265mkdir $pkgname/contrib 266cp -r $source/contrib/completion $pkgname/contrib 267mv bins-$platform/runtime $pkgname/ 268mv bins-$platform/hx$exe $pkgname 269chmod +x $pkgname/hx$exe 270 271if [[ "$platform" = "x86_64-linux" ]]; then 272mv bins-$platform/helix-*.AppImage* dist/ 273mv bins-$platform/*.deb dist/ 274fi 275 276if [ "$exe" = "" ]; then 277tar cJf dist/$pkgname.tar.xz $pkgname 278else 2797z a -r dist/$pkgname.zip $pkgname 280fi 281done 282 283tar cJf dist/helix-$tag-source.tar.xz -C $source . 284mv dist $source/ 285 286- name : Upload binaries to release 287uses : svenstaro/upload-release-action@v2 288if : env.preview == 'false' 289with : 290repo_token : ${{ secrets.GITHUB_TOKEN }} 291file : dist/* 292file_glob : true 293tag : ${{ github.ref_name }} 294overwrite : true 295 296- name : Upload binaries as artifact 297uses : actions/upload-artifact@v6 298if : env.preview == 'true' 299with : 300name : release 301path : dist/*