From 442e59f4ccb8c93c33a7e49f1367042cdd07c9ef Mon Sep 17 00:00:00 2001 From: Dustin Blackman Date: Wed, 29 Nov 2023 23:18:42 -0500 Subject: [PATCH] chore: Move to faster builds --- .cargo/config.toml | 2 - .github/workflows/release.yml | 96 +++++++++++++++++++++++++++++++++++ .gitignore | 1 + Cargo.toml | 13 ++--- rust-toolchain.toml | 1 - tools/goreleaser-dist.sh | 2 +- tools/release-env.sh | 13 ----- 7 files changed, 103 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/release.yml delete mode 100755 tools/release-env.sh diff --git a/.cargo/config.toml b/.cargo/config.toml index 26f1183..c61a49c 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -9,5 +9,3 @@ deny = ["bin", "cargo-deny"] gha = ["bin", "cargo-gha"] llvm-cov = ["bin", "cargo-llvm-cov"] nextest = ["bin", "cargo-nextest"] -xwin = ["bin", "cargo-xwin"] -zigbuild = ["bin", "cargo-zigbuild"] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e21eb6d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,96 @@ +on: workflow_dispatch +name: build +jobs: + linux-amd: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + target: x86_64-unknown-linux-gnu + - name: Build + run: cargo build --release --target x86_64-unknown-linux-gnu + - name: Upload + uses: actions/upload-artifact@v2 + with: + name: x86_64-unknown-linux-gnu + path: target/x86_64-unknown-linux-gnu/release/languagetool-code-comments + + linux-arm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: goto-bus-stop/setup-zig@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + target: aarch64-unknown-linux-gnu + - name: Build + run: | + sudo apt-get install gcc-aarch64-linux-gnu + cargo install cargo-zigbuild + rustup target add aarch64-unknown-linux-gnu + cargo zigbuild --release --target aarch64-unknown-linux-gnu + - name: Upload + uses: actions/upload-artifact@v2 + with: + name: aarch64-unknown-linux-gnu + path: target/aarch64-unknown-linux-gnu/release/languagetool-code-comments + + macos-amd: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + target: x86_64-apple-darwin + toolchain: stable + - name: Build + run: cargo build --release --target x86_64-apple-darwin + - name: Upload + uses: actions/upload-artifact@v2 + with: + name: x86_64-apple-darwin + path: target/x86_64-apple-darwin/release/languagetool-code-comments + + macos-arm: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - uses: goto-bus-stop/setup-zig@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + target: aarch64-apple-darwin + - name: Build + run: | + cargo install cargo-zigbuild + rustup target add aarch64-apple-darwin + cargo zigbuild --release --target aarch64-apple-darwin + - name: Upload + uses: actions/upload-artifact@v2 + with: + name: aarch64-apple-darwin + path: target/aarch64-apple-darwin/release/languagetool-code-comments + + windows-amd: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + target: x86_64-pc-windows-msvc + - name: Build + run: cargo build --release --target x86_64-pc-windows-msvc + - name: Upload + uses: actions/upload-artifact@v2 + with: + name: x86_64-pc-windows-msvc + path: target/x86_64-pc-windows-msvc/release/languagetool-code-comments.exe diff --git a/.gitignore b/.gitignore index 07b226d..895c22e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .bin/ .gha/ dist/ +dist-gh/ /target test.ts completions diff --git a/Cargo.toml b/Cargo.toml index 8230cce..3a67704 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,8 +41,6 @@ cargo-deny = { version = "0.13.5" } cargo-gha = { version = "0.4.6" } cargo-llvm-cov = { version = "0.5.25" } cargo-nextest = { version = "0.9.57", locked = true } -cargo-xwin = { version = "0.14.8" } -cargo-zigbuild = { version = "0.17.4" } dprint = { version = "0.40.2" } git-cliff = { version = "1.3.1" } rust-script = { version = "0.21.0" } @@ -96,6 +94,11 @@ release = '''set -e cargo bin cargo-deny check licenses ./tools/thirdparty/run.sh + rm -rf dist-gh + mkdir dist-gh + export GH_RUN_ID=$(cargo gha gh run list -R dustinblackman/languagetool-code-comments -w build --json databaseId | jq -rc '.[0].databaseId') + cargo gha gh run download -D dist-gh $GH_RUN_ID + export LTCC_VERSION=$(cat Cargo.toml | grep version | head -n1 | awk -F '"' '{print $2}') cargo bin git-cliff -o CHANGELOG.md --tag "v$LTCC_VERSION" cargo bin dprint fmt @@ -112,12 +115,6 @@ release = '''set -e git tag -d "v$LTCC_VERSION" git tag -a "v$LTCC_VERSION" -m "v$LTCC_VERSION" - ./tools/release-env.sh zigbuild --release --target x86_64-apple-darwin - ./tools/release-env.sh zigbuild --release --target aarch64-apple-darwin - ./tools/release-env.sh zigbuild --release --target x86_64-unknown-linux-gnu - ./tools/release-env.sh zigbuild --release --target aarch64-unknown-linux-gnu - ./tools/release-env.sh xwin build --release --target x86_64-pc-windows-msvc --xwin-arch x86_64 --xwin-cache-dir .bin/xwin/x86_64 - git push git push --tags cargo cmd goreleaser diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 6f1704e..33f37a5 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,3 @@ [toolchain] channel = "1.74.0" components = ["rustfmt", "clippy", "llvm-tools-preview"] -targets = ["x86_64-apple-darwin", "aarch64-apple-darwin", "x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu", "x86_64-pc-windows-gnu"] diff --git a/tools/goreleaser-dist.sh b/tools/goreleaser-dist.sh index edbc1f6..241d283 100755 --- a/tools/goreleaser-dist.sh +++ b/tools/goreleaser-dist.sh @@ -24,7 +24,7 @@ goTargetToRust() { rm -rf "./dist/languagetool-code-comments_${target}" mkdir -p "./dist/languagetool-code-comments_${target}" -rustbin="./target/$(goTargetToRust)/release/languagetool-code-comments" +rustbin="./dist-gh/$(goTargetToRust)/languagetool-code-comments" if [[ "$target" == "windows_amd64_v1" ]]; then rustbin="${rustbin}.exe" fi diff --git a/tools/release-env.sh b/tools/release-env.sh deleted file mode 100755 index 3ada00c..0000000 --- a/tools/release-env.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -export PATHTMP=$(echo "$PATH" | sd ':' '\n' | grep -E '(^/usr|^/bin|homebrew)' | grep -v "$USER" | sd '\n' ':') -export HOMETMP="$TMPDIR/homedir-$(basename "$PWD")" - -rm -rf "$HOMETMP" -mkdir -p "$HOMETMP" -ln -s "$HOME/.cargo" "$HOMETMP/.cargo" -ln -s "$HOME/.rustup" "$HOMETMP/.rustup" - -env -i PATH="$PATHTMP:$HOMETMP/.cargo/bin" HOME="$HOMETMP" bash --noprofile --norc -c "cargo $*" - -rm -rf "$HOMETMP"