fork/helix
git clone https://git.julia.blue/fork/helix
34aa4d41
25.07
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@v4 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@v4 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 ] #, x86_64-win-gnu, win32-msvc 62include : 63- build : x86_64-linux 64os : ubuntu-24.04 65rust : stable 66target : x86_64-unknown-linux-gnu 67cross : false 68- build : aarch64-linux 69os : ubuntu-24.04-arm 70rust : stable 71target : aarch64-unknown-linux-gnu 72cross : 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 79os : macos-latest 80rust : stable 81target : x86_64-apple-darwin 82cross : false 83- build : x86_64-windows 84os : windows-latest 85rust : stable 86target : x86_64-pc-windows-msvc 87cross : false 88# 23.03: build issues 89- build : aarch64-macos 90os : macos-latest 91rust : stable 92target : aarch64-apple-darwin 93cross : false 94skip_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 104steps : 105- name : Checkout sources 106uses : actions/checkout@v4 107 108- name : Download grammars 109uses : actions/download-artifact@v4 110 111- name : Move grammars under runtime 112if : "!startsWith(matrix.os, 'windows')" 113run : | 114mkdir -p runtime/grammars/sources 115tar 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 121run : rm rust-toolchain.toml 122 123- name : Install ${{ matrix.rust }} toolchain 124uses : dtolnay/rust-toolchain@master 125with : 126toolchain : ${{ matrix.rust }} 127target : ${{ 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 134if : "matrix.cross" 135run : | 136cargo install cross --git https://github.com/cross-rs/cross.git --rev 47df5c76e7cba682823a0b6aa6d95c17b31ba63a 137echo "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 142run : | 143echo "cargo command is: ${{ env.CARGO }}" 144echo "target flag is: ${{ env.TARGET_FLAGS }}" 145 146- name : Run cargo test 147if : "!matrix.skip_tests" 148run : ${{ env.CARGO }} test --release --locked --target ${{ matrix.target }} --workspace 149 150- name : Build release binary 151run : ${{ env.CARGO }} build --profile opt --locked --target ${{ matrix.target }} 152 153- name : Build AppImage 154shell : bash 155if : matrix.build == 'x86_64-linux' 156run : | 157# Required as of 22.x https://github.com/AppImage/AppImageKit/wiki/FUSE 158sudo add-apt-repository universe 159sudo apt install libfuse2 160 161mkdir dist 162 163name=dev 164if [[ $GITHUB_REF == refs/tags/* ]]; then 165name=${GITHUB_REF:10} 166fi 167 168build="${{ matrix.build }}" 169 170export VERSION="$name" 171export ARCH=${build%-linux} 172export APP=helix 173export OUTPUT="helix-$VERSION-$ARCH.AppImage" 174export UPDATE_INFORMATION="gh-releases-zsync|$GITHUB_REPOSITORY_OWNER|helix|latest|$APP-*-$ARCH.AppImage.zsync" 175 176mkdir -p "$APP.AppDir"/usr/{bin,lib/helix} 177 178cp "target/${{ matrix.target }}/opt/hx" "$APP.AppDir/usr/bin/hx" 179rm -rf runtime/grammars/sources 180cp -r runtime "$APP.AppDir/usr/lib/helix/runtime" 181 182cat << 'EOF' > "$APP.AppDir/AppRun" 183#!/bin/sh 184 185APPDIR="$(dirname "$(readlink -f "${0}")")" 186HELIX_RUNTIME="$APPDIR/usr/lib/helix/runtime" exec "$APPDIR/usr/bin/hx" "$@" 187EOF 188chmod 755 "$APP.AppDir/AppRun" 189 190curl -Lo linuxdeploy-x86_64.AppImage \ 191https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage 192chmod +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 198mv "$APP-$VERSION-$ARCH.AppImage" \ 199"$APP-$VERSION-$ARCH.AppImage.zsync" dist 200 201- name : Build Deb 202shell : bash 203if : matrix.build == 'x86_64-linux' 204run : | 205cargo install cargo-deb 206mkdir -p target/release 207cp target/${{ matrix.target }}/opt/hx target/release/ 208cargo deb --no-build 209mkdir -p dist 210mv target/debian/*.deb dist/ 211 212- name : Build archive 213shell : bash 214run : | 215mkdir -p dist 216if [ "${{ matrix.os }}" = "windows-2019" ]; then 217cp "target/${{ matrix.target }}/opt/hx.exe" "dist/" 218else 219cp "target/${{ matrix.target }}/opt/hx" "dist/" 220fi 221if [ -d runtime/grammars/sources ]; then 222rm -rf runtime/grammars/sources 223fi 224cp -r runtime dist 225 226- uses : actions/upload-artifact@v4 227with : 228name : bins-${{ matrix.build }} 229path : dist 230 231publish : 232name : Publish 233needs : [ dist ] 234runs-on : ubuntu-latest 235steps : 236- name : Checkout sources 237uses : actions/checkout@v4 238 239- uses : actions/download-artifact@v4 240 241- name : Build archive 242shell : bash 243run : | 244set -ex 245 246source="$(pwd)" 247tag=${GITHUB_REF_NAME//\//} 248mkdir -p runtime/grammars/sources 249tar xJf grammars/grammars.tar.xz -C runtime/grammars/sources 250rm -rf grammars 251 252cd "$(mktemp -d)" 253mv $source/bins-* . 254mkdir dist 255 256for dir in bins-* ; do 257platform=${dir#"bins-"} 258if [[ $platform =~ "windows" ]]; then 259exe=".exe" 260fi 261pkgname=helix-$tag-$platform 262mkdir -p $pkgname 263cp $source/LICENSE $source/README.md $pkgname 264mkdir $pkgname/contrib 265cp -r $source/contrib/completion $pkgname/contrib 266mv bins-$platform/runtime $pkgname/ 267mv bins-$platform/hx$exe $pkgname 268chmod +x $pkgname/hx$exe 269 270if [[ "$platform" = "x86_64-linux" ]]; then 271mv bins-$platform/helix-*.AppImage* dist/ 272mv bins-$platform/*.deb dist/ 273fi 274 275if [ "$exe" = "" ]; then 276tar cJf dist/$pkgname.tar.xz $pkgname 277else 2787z a -r dist/$pkgname.zip $pkgname 279fi 280done 281 282tar cJf dist/helix-$tag-source.tar.xz -C $source . 283mv dist $source/ 284 285- name : Upload binaries to release 286uses : svenstaro/upload-release-action@v2 287if : env.preview == 'false' 288with : 289repo_token : ${{ secrets.GITHUB_TOKEN }} 290file : dist/* 291file_glob : true 292tag : ${{ github.ref_name }} 293overwrite : true 294 295- name : Upload binaries as artifact 296uses : actions/upload-artifact@v4 297if : env.preview == 'true' 298with : 299name : release 300path : dist/*