From c572bdfb4f0a571c65dc87e601280734387a66bb Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Mon, 28 Mar 2022 08:18:03 -0500 Subject: [PATCH 1/3] publish a source tarball with version and grammars --- .github/workflows/release.yml | 119 ++++++++++++++++++++++++++++------ helix-term/build.rs | 15 ++++- 2 files changed, 111 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d954385e58b0..54b6faee6504 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,32 +1,81 @@ name: Release on: - # schedule: - # - cron: '0 0 * * *' # midnight UTC - push: tags: - - 'v[0-9]+.[0-9]+.[0-9]+' - ## - release + - '[0-9]+.[0-9]+' + - '[0-9]+.[0-9]+.[0-9]+' jobs: + fetch-grammars: + name: Fetch Grammars + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v3 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - name: Cache cargo registry + uses: actions/cache@v3 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-v2-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-v2-cargo-registry- + + - name: Cache cargo index + uses: actions/cache@v3 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-v2-cargo-index-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-v2-cargo-index- + + - name: Cache cargo target dir + uses: actions/cache@v3 + with: + path: target + key: ${{ runner.os }}-v2-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-v2-cargo-build-target- + + - name: Fetch tree-sitter grammars + uses: actions-rs/cargo@v1 + env: + HELIX_DISABLE_AUTO_GRAMMAR_BUILD: yes + with: + command: run + args: -- --grammar fetch + + - name: Bundle grammars + run: tar cJf grammars.tar.xz -C runtime/grammars/sources . + + - uses: actions/upload-artifact@v3 + with: + name: grammars + path: grammars.tar.xz + dist: name: Dist + needs: [fetch-grammars] runs-on: ${{ matrix.os }} strategy: fail-fast: false # don't fail other jobs if one fails matrix: - build: [x86_64-linux, aarch64-linux, x86_64-macos, x86_64-windows] #, x86_64-win-gnu, win32-msvc + build: [x86_64-linux, x86_64-macos, x86_64-windows] #, x86_64-win-gnu, win32-msvc include: - build: x86_64-linux os: ubuntu-20.04 rust: stable target: x86_64-unknown-linux-gnu cross: false - - build: aarch64-linux - os: ubuntu-20.04 - rust: stable - target: aarch64-unknown-linux-gnu - cross: true + # - build: aarch64-linux + # os: ubuntu-20.04 + # rust: stable + # target: aarch64-unknown-linux-gnu + # cross: true - build: x86_64-macos os: macos-latest rust: stable @@ -54,6 +103,24 @@ jobs: - name: Checkout sources uses: actions/checkout@v3 + - name: Download grammars + uses: actions/download-artifact@v2 + + - name: Move grammars under runtime + if: "!startsWith(matrix.os, 'windows')" + run: | + mkdir -p runtime/grammars/sources + tar xJf grammars/grammars.tar.xz -C runtime/grammars/sources + + - name: Write tag name to .version file + shell: bash + run: | + name=dev + if [[ $GITHUB_REF == refs/tags/* ]]; then + name=${GITHUB_REF:10} + fi + echo -n $name > .version + - name: Install ${{ matrix.rust }} toolchain uses: actions-rs/toolchain@v1 with: @@ -98,6 +165,7 @@ jobs: else cp "target/${{ matrix.target }}/release/hx" "dist/" fi + rm -rf runtime/grammars/sources cp -r runtime dist - uses: actions/upload-artifact@v3 @@ -118,7 +186,7 @@ jobs: - name: Calculate tag name run: | name=dev - if [[ $GITHUB_REF == refs/tags/v* ]]; then + if [[ $GITHUB_REF == refs/tags/* ]]; then name=${GITHUB_REF:10} fi echo ::set-output name=val::$name @@ -130,8 +198,14 @@ jobs: run: | set -ex - rm -rf tmp - mkdir tmp + source="$(pwd)" + mkdir -p runtime/grammars/sources + tar xJf grammars/grammars.tar.xz -C runtime/grammars/sources + echo -n "$TAG" > .version + rm -rf grammars + + cd "$(mktemp -d)" + mv $source/bins-* . mkdir dist for dir in bins-* ; do @@ -140,19 +214,22 @@ jobs: exe=".exe" fi pkgname=helix-$TAG-$platform - mkdir tmp/$pkgname - cp LICENSE README.md tmp/$pkgname - mv bins-$platform/runtime tmp/$pkgname/ - mv bins-$platform/hx$exe tmp/$pkgname - chmod +x tmp/$pkgname/hx$exe + mkdir $pkgname + cp $source/LICENSE $source/README.md $pkgname + mv bins-$platform/runtime $pkgname/ + mv bins-$platform/hx$exe $pkgname + chmod +x $pkgname/hx$exe if [ "$exe" = "" ]; then - tar cJf dist/$pkgname.tar.xz -C tmp $pkgname + tar cJf dist/$pkgname.tar.xz $pkgname else - (cd tmp && 7z a -r ../dist/$pkgname.zip $pkgname) + 7z a -r dist/$pkgname.zip $pkgname fi done + tar cJf dist/helix-$TAG-source.tar.xz -C $source . + mv dist $source/ + - name: Upload binaries to release uses: svenstaro/upload-release-action@v2 with: diff --git a/helix-term/build.rs b/helix-term/build.rs index 526cdc41311a..30d4b5c78ff4 100644 --- a/helix-term/build.rs +++ b/helix-term/build.rs @@ -1,8 +1,18 @@ use helix_loader::grammar::{build_grammars, fetch_grammars}; use std::borrow::Cow; +use std::io::Read; use std::process::Command; fn main() { + let mut version = String::new(); + + if std::fs::File::open("../.version") + .and_then(|mut f| f.read_to_string(&mut version)) + .is_err() + { + version = "dev".to_string(); + } + let git_hash = Command::new("git") .args(&["rev-parse", "HEAD"]) .output() @@ -11,8 +21,8 @@ fn main() { .and_then(|x| String::from_utf8(x.stdout).ok()); let version: Cow<_> = match git_hash { - Some(git_hash) => format!("{} ({})", env!("CARGO_PKG_VERSION"), &git_hash[..8]).into(), - None => env!("CARGO_PKG_VERSION").into(), + Some(git_hash) => format!("{} ({})", version, &git_hash[..8]).into(), + None => version.into(), }; if std::env::var("HELIX_DISABLE_AUTO_GRAMMAR_BUILD").is_err() { @@ -21,6 +31,7 @@ fn main() { } println!("cargo:rerun-if-changed=../runtime/grammars/"); + println!("cargo:rerun-if-changed=../.version"); println!("cargo:rustc-env=VERSION_AND_GIT_HASH={}", version); } From c6cdf63cd0c74ac6a34b8820982fd7b67aaf54b0 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Mon, 28 Mar 2022 19:26:10 -0500 Subject: [PATCH 2/3] include_str! the release version from a VERSION file --- VERSION | 1 + helix-term/build.rs | 18 +++++------------- 2 files changed, 6 insertions(+), 13 deletions(-) create mode 100644 VERSION diff --git a/VERSION b/VERSION new file mode 100644 index 000000000000..24b267470136 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +22.03 \ No newline at end of file diff --git a/helix-term/build.rs b/helix-term/build.rs index 30d4b5c78ff4..974f4b5ed7f0 100644 --- a/helix-term/build.rs +++ b/helix-term/build.rs @@ -1,18 +1,10 @@ use helix_loader::grammar::{build_grammars, fetch_grammars}; use std::borrow::Cow; -use std::io::Read; use std::process::Command; -fn main() { - let mut version = String::new(); - - if std::fs::File::open("../.version") - .and_then(|mut f| f.read_to_string(&mut version)) - .is_err() - { - version = "dev".to_string(); - } +const VERSION: &str = include_str!("../VERSION"); +fn main() { let git_hash = Command::new("git") .args(&["rev-parse", "HEAD"]) .output() @@ -21,8 +13,8 @@ fn main() { .and_then(|x| String::from_utf8(x.stdout).ok()); let version: Cow<_> = match git_hash { - Some(git_hash) => format!("{} ({})", version, &git_hash[..8]).into(), - None => version.into(), + Some(git_hash) => format!("{} ({})", VERSION, &git_hash[..8]).into(), + None => VERSION.into(), }; if std::env::var("HELIX_DISABLE_AUTO_GRAMMAR_BUILD").is_err() { @@ -31,7 +23,7 @@ fn main() { } println!("cargo:rerun-if-changed=../runtime/grammars/"); - println!("cargo:rerun-if-changed=../.version"); + println!("cargo:rerun-if-changed=../VERSION"); println!("cargo:rustc-env=VERSION_AND_GIT_HASH={}", version); } From 1ef4c88beb9f38dbf8dcdc6134ba5a1e979db427 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Mon, 28 Mar 2022 19:35:05 -0500 Subject: [PATCH 3/3] remove setting of .version file from tag don't need this anymore since the file is checked into source --- .github/workflows/release.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 54b6faee6504..eb36c786702d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -112,15 +112,6 @@ jobs: mkdir -p runtime/grammars/sources tar xJf grammars/grammars.tar.xz -C runtime/grammars/sources - - name: Write tag name to .version file - shell: bash - run: | - name=dev - if [[ $GITHUB_REF == refs/tags/* ]]; then - name=${GITHUB_REF:10} - fi - echo -n $name > .version - - name: Install ${{ matrix.rust }} toolchain uses: actions-rs/toolchain@v1 with: @@ -201,7 +192,6 @@ jobs: source="$(pwd)" mkdir -p runtime/grammars/sources tar xJf grammars/grammars.tar.xz -C runtime/grammars/sources - echo -n "$TAG" > .version rm -rf grammars cd "$(mktemp -d)"