on master help sign in
publish a source tarball with version and grammars (#1875)
838cfccMichael Davis
.github/workflows/release.yml+88−21
@@ -1,32 +1,81 @@
1name: Release
1name: Release
2on:
2on:
3− # schedule:
4− # - cron: '0 0 * * *' # midnight UTC
5−
6 push:
3 push:
7 tags:
4 tags:
8− - 'v[0-9]+.[0-9]+.[0-9]+'
5+ - '[0-9]+.[0-9]+'
9− ## - release
6+ - '[0-9]+.[0-9]+.[0-9]+'
10
7
11jobs:
8jobs:
9+ fetch-grammars:
10+ name: Fetch Grammars
11+ runs-on: ubuntu-latest
12+ steps:
13+ - name: Checkout sources
14+ uses: actions/checkout@v3
15+
16+ - name: Install stable toolchain
17+ uses: actions-rs/toolchain@v1
18+ with:
19+ profile: minimal
20+ toolchain: stable
21+ override: true
22+
23+ - name: Cache cargo registry
24+ uses: actions/cache@v3
25+ with:
26+ path: ~/.cargo/registry
27+ key: ${{ runner.os }}-v2-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
28+ restore-keys: ${{ runner.os }}-v2-cargo-registry-
29+
30+ - name: Cache cargo index
31+ uses: actions/cache@v3
32+ with:
33+ path: ~/.cargo/git
34+ key: ${{ runner.os }}-v2-cargo-index-${{ hashFiles('**/Cargo.lock') }}
35+ restore-keys: ${{ runner.os }}-v2-cargo-index-
36+
37+ - name: Cache cargo target dir
38+ uses: actions/cache@v3
39+ with:
40+ path: target
41+ key: ${{ runner.os }}-v2-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
42+ restore-keys: ${{ runner.os }}-v2-cargo-build-target-
43+
44+ - name: Fetch tree-sitter grammars
45+ uses: actions-rs/cargo@v1
46+ env:
47+ HELIX_DISABLE_AUTO_GRAMMAR_BUILD: yes
48+ with:
49+ command: run
50+ args: -- --grammar fetch
51+
52+ - name: Bundle grammars
53+ run: tar cJf grammars.tar.xz -C runtime/grammars/sources .
54+
55+ - uses: actions/upload-artifact@v3
56+ with:
57+ name: grammars
58+ path: grammars.tar.xz
59+
12 dist:
60 dist:
13 name: Dist
61 name: Dist
62+ needs: [fetch-grammars]
14 runs-on: ${{ matrix.os }}
63 runs-on: ${{ matrix.os }}
15 strategy:
64 strategy:
16 fail-fast: false # don't fail other jobs if one fails
65 fail-fast: false # don't fail other jobs if one fails
17 matrix:
66 matrix:
18− build: [x86_64-linux, aarch64-linux, x86_64-macos, x86_64-windows] #, x86_64-win-gnu, win32-msvc
67+ build: [x86_64-linux, x86_64-macos, x86_64-windows] #, x86_64-win-gnu, win32-msvc
19 include:
68 include:
20 - build: x86_64-linux
69 - build: x86_64-linux
21 os: ubuntu-20.04
70 os: ubuntu-20.04
22 rust: stable
71 rust: stable
23 target: x86_64-unknown-linux-gnu
72 target: x86_64-unknown-linux-gnu
24 cross: false
73 cross: false
25− - build: aarch64-linux
74+ # - build: aarch64-linux
26− os: ubuntu-20.04
75+ # os: ubuntu-20.04
27− rust: stable
76+ # rust: stable
28− target: aarch64-unknown-linux-gnu
77+ # target: aarch64-unknown-linux-gnu
29− cross: true
78+ # cross: true
30 - build: x86_64-macos
79 - build: x86_64-macos
31 os: macos-latest
80 os: macos-latest
32 rust: stable
81 rust: stable
@@ -54,6 +103,15 @@ jobs:
54 - name: Checkout sources
103 - name: Checkout sources
55 uses: actions/checkout@v3
104 uses: actions/checkout@v3
56
105
106+ - name: Download grammars
107+ uses: actions/download-artifact@v2
108+
109+ - name: Move grammars under runtime
110+ if: "!startsWith(matrix.os, 'windows')"
111+ run: |
112+ mkdir -p runtime/grammars/sources
113+ tar xJf grammars/grammars.tar.xz -C runtime/grammars/sources
114+
57 - name: Install ${{ matrix.rust }} toolchain
115 - name: Install ${{ matrix.rust }} toolchain
58 uses: actions-rs/toolchain@v1
116 uses: actions-rs/toolchain@v1
59 with:
117 with:
@@ -98,6 +156,7 @@ jobs:
98 else
156 else
99 cp "target/${{ matrix.target }}/release/hx" "dist/"
157 cp "target/${{ matrix.target }}/release/hx" "dist/"
100 fi
158 fi
159+ rm -rf runtime/grammars/sources
101 cp -r runtime dist
160 cp -r runtime dist
102
161
103 - uses: actions/upload-artifact@v3
162 - uses: actions/upload-artifact@v3
@@ -118,7 +177,7 @@ jobs:
118 - name: Calculate tag name
177 - name: Calculate tag name
119 run: |
178 run: |
120 name=dev
179 name=dev
121− if [[ $GITHUB_REF == refs/tags/v* ]]; then
180+ if [[ $GITHUB_REF == refs/tags/* ]]; then
122 name=${GITHUB_REF:10}
181 name=${GITHUB_REF:10}
123 fi
182 fi
124 echo ::set-output name=val::$name
183 echo ::set-output name=val::$name
@@ -130,8 +189,13 @@ jobs:
130 run: |
189 run: |
131 set -ex
190 set -ex
132
191
192+ source="$(pwd)"
193+ mkdir -p runtime/grammars/sources
194+ tar xJf grammars/grammars.tar.xz -C runtime/grammars/sources
133− rm -rf tmp
195+ rm -rf grammars
134− mkdir tmp
196+
197+ cd "$(mktemp -d)"
198+ mv $source/bins-* .
135 mkdir dist
199 mkdir dist
136
200
137 for dir in bins-* ; do
201 for dir in bins-* ; do
@@ -140,19 +204,22 @@ jobs:
140 exe=".exe"
204 exe=".exe"
141 fi
205 fi
142 pkgname=helix-$TAG-$platform
206 pkgname=helix-$TAG-$platform
143− mkdir tmp/$pkgname
207+ mkdir $pkgname
144− cp LICENSE README.md tmp/$pkgname
208+ cp $source/LICENSE $source/README.md $pkgname
145− mv bins-$platform/runtime tmp/$pkgname/
209+ mv bins-$platform/runtime $pkgname/
146− mv bins-$platform/hx$exe tmp/$pkgname
210+ mv bins-$platform/hx$exe $pkgname
147− chmod +x tmp/$pkgname/hx$exe
211+ chmod +x $pkgname/hx$exe
148
212
149 if [ "$exe" = "" ]; then
213 if [ "$exe" = "" ]; then
150− tar cJf dist/$pkgname.tar.xz -C tmp $pkgname
214+ tar cJf dist/$pkgname.tar.xz $pkgname
151 else
215 else
152− (cd tmp && 7z a -r ../dist/$pkgname.zip $pkgname)
216+ 7z a -r dist/$pkgname.zip $pkgname
153 fi
217 fi
154 done
218 done
155
219
220+ tar cJf dist/helix-$TAG-source.tar.xz -C $source .
221+ mv dist $source/
222+
156 - name: Upload binaries to release
223 - name: Upload binaries to release
157 uses: svenstaro/upload-release-action@v2
224 uses: svenstaro/upload-release-action@v2
158 with:
225 with:
VERSIONnew file+1
@@ -0,0 +1 @@
1+22.03
helix-term/build.rs+5−2
@@ -2,6 +2,8 @@ use helix_loader::grammar::{build_grammars, fetch_grammars};
2use std::borrow::Cow;
2use std::borrow::Cow;
3use std::process::Command;
3use std::process::Command;
4
4
5+const VERSION: &str = include_str!("../VERSION");
6+
5fn main() {
7fn main() {
6 let git_hash = Command::new("git")
8 let git_hash = Command::new("git")
7 .args(&["rev-parse", "HEAD"])
9 .args(&["rev-parse", "HEAD"])
@@ -11,8 +13,8 @@ fn main() {
11 .and_then(|x| String::from_utf8(x.stdout).ok());
13 .and_then(|x| String::from_utf8(x.stdout).ok());
12
14
13 let version: Cow<_> = match git_hash {
15 let version: Cow<_> = match git_hash {
14− Some(git_hash) => format!("{} ({})", env!("CARGO_PKG_VERSION"), &git_hash[..8]).into(),
16+ Some(git_hash) => format!("{} ({})", VERSION, &git_hash[..8]).into(),
15− None => env!("CARGO_PKG_VERSION").into(),
17+ None => VERSION.into(),
16 };
18 };
17
19
18 if std::env::var("HELIX_DISABLE_AUTO_GRAMMAR_BUILD").is_err() {
20 if std::env::var("HELIX_DISABLE_AUTO_GRAMMAR_BUILD").is_err() {
@@ -21,6 +23,7 @@ fn main() {
21 }
23 }
22
24
23 println!("cargo:rerun-if-changed=../runtime/grammars/");
25 println!("cargo:rerun-if-changed=../runtime/grammars/");
26+ println!("cargo:rerun-if-changed=../VERSION");
24
27
25 println!("cargo:rustc-env=VERSION_AND_GIT_HASH={}", version);
28 println!("cargo:rustc-env=VERSION_AND_GIT_HASH={}", version);
26}
29}