fork/helix
git clone https://git.julia.blue/fork/helix
f6021dd0
23.10
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@v3 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 , x86_64-macos , x86_64-windows ] #, x86_64-win-gnu, win32-msvc 62include : 63- build : x86_64-linux 64os : ubuntu-latest 65rust : stable 66target : x86_64-unknown-linux-gnu 67cross : false 68- build : aarch64-linux 69os : ubuntu-latest 70rust : stable 71target : aarch64-unknown-linux-gnu 72cross : true 73# - build: riscv64-linux 74# os: ubuntu-latest 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@v3 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 : Set profile.release.strip = true 151shell : bash 152run : | 153cat >> .cargo/config.toml <<EOF 154[profile.release] 155strip = true 156EOF 157 158- name : Build release binary 159run : ${{ env.CARGO }} build --release --locked --target ${{ matrix.target }} 160 161- name : Build AppImage 162shell : bash 163if : matrix.build == 'x86_64-linux' 164run : | 165# Required as of 22.x https://github.com/AppImage/AppImageKit/wiki/FUSE 166sudo add-apt-repository universe 167sudo apt install libfuse2 168 169mkdir dist 170 171name=dev 172if [[ $GITHUB_REF == refs/tags/* ]]; then 173name=${GITHUB_REF:10} 174fi 175 176build="${{ matrix.build }}" 177 178export VERSION="$name" 179export ARCH=${build%-linux} 180export APP=helix 181export OUTPUT="helix-$VERSION-$ARCH.AppImage" 182export UPDATE_INFORMATION="gh-releases-zsync|$GITHUB_REPOSITORY_OWNER|helix|latest|$APP-*-$ARCH.AppImage.zsync" 183 184mkdir -p "$APP.AppDir"/usr/{bin,lib/helix} 185 186cp "target/${{ matrix.target }}/release/hx" "$APP.AppDir/usr/bin/hx" 187rm -rf runtime/grammars/sources 188cp -r runtime "$APP.AppDir/usr/lib/helix/runtime" 189 190cat << 'EOF' > "$APP.AppDir/AppRun" 191#!/bin/sh 192 193APPDIR="$(dirname "$(readlink -f "${0}")")" 194HELIX_RUNTIME="$APPDIR/usr/lib/helix/runtime" exec "$APPDIR/usr/bin/hx" "$@" 195EOF 196chmod 755 "$APP.AppDir/AppRun" 197 198curl -Lo linuxdeploy-x86_64.AppImage \ 199https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage 200chmod +x linuxdeploy-x86_64.AppImage 201 202./linuxdeploy-x86_64.AppImage \ 203--appdir "$APP.AppDir" -d contrib/Helix.desktop \ 204-i contrib/helix.png --output appimage 205 206mv "$APP-$VERSION-$ARCH.AppImage" \ 207"$APP-$VERSION-$ARCH.AppImage.zsync" dist 208 209- name : Build archive 210shell : bash 211run : | 212mkdir -p dist 213if [ "${{ matrix.os }}" = "windows-2019" ]; then 214cp "target/${{ matrix.target }}/release/hx.exe" "dist/" 215else 216cp "target/${{ matrix.target }}/release/hx" "dist/" 217fi 218if [ -d runtime/grammars/sources ]; then 219rm -rf runtime/grammars/sources 220fi 221cp -r runtime dist 222 223- uses : actions/upload-artifact@v3 224with : 225name : bins-${{ matrix.build }} 226path : dist 227 228publish : 229name : Publish 230needs : [ dist ] 231runs-on : ubuntu-latest 232steps : 233- name : Checkout sources 234uses : actions/checkout@v4 235 236- uses : actions/download-artifact@v3 237 238- name : Build archive 239shell : bash 240run : | 241set -ex 242 243source="$(pwd)" 244mkdir -p runtime/grammars/sources 245tar xJf grammars/grammars.tar.xz -C runtime/grammars/sources 246rm -rf grammars 247 248cd "$(mktemp -d)" 249mv $source/bins-* . 250mkdir dist 251 252for dir in bins-* ; do 253platform=${dir#"bins-"} 254if [[ $platform =~ "windows" ]]; then 255exe=".exe" 256fi 257pkgname=helix-$GITHUB_REF_NAME-$platform 258mkdir -p $pkgname 259cp $source/LICENSE $source/README.md $pkgname 260mkdir $pkgname/contrib 261cp -r $source/contrib/completion $pkgname/contrib 262mv bins-$platform/runtime $pkgname/ 263mv bins-$platform/hx$exe $pkgname 264chmod +x $pkgname/hx$exe 265 266if [[ "$platform" = "x86_64-linux" ]]; then 267mv bins-$platform/helix-*.AppImage* dist/ 268fi 269 270if [ "$exe" = "" ]; then 271tar cJf dist/$pkgname.tar.xz $pkgname 272else 2737z a -r dist/$pkgname.zip $pkgname 274fi 275done 276 277tar cJf dist/helix-$GITHUB_REF_NAME-source.tar.xz -C $source . 278mv dist $source/ 279 280- name : Upload binaries to release 281uses : svenstaro/upload-release-action@v2 282if : env.preview == 'false' 283with : 284repo_token : ${{ secrets.GITHUB_TOKEN }} 285file : dist/* 286file_glob : true 287tag : ${{ github.ref_name }} 288overwrite : true 289 290- name : Upload binaries as artifact 291uses : actions/upload-artifact@v3 292if : env.preview == 'true' 293with : 294name : release 295path : dist/*