From 3bdcd6315f03ddbeaa8b1eaa09e60be07bb42206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E7=9D=BF?= Date: Thu, 29 Jan 2026 10:58:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=B5=81=E5=92=8C=E6=9B=B4=E6=96=B0=20Cargo.?= =?UTF-8?q?toml=20=E9=85=8D=E7=BD=AE=E4=BB=A5=E6=94=AF=E6=8C=81=E4=BA=8C?= =?UTF-8?q?=E8=BF=9B=E5=88=B6=E5=8C=85=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 97 +++++++++++++++++++++++++++++++++++ ostool/Cargo.toml | 9 +++- 2 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..86053a8 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,97 @@ +name: Release + +on: + workflow_run: + workflows: ["Quality Check"] + branches: [main] + types: [completed] + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + release-plz: + if: ${{ github.repository_owner == 'drivercraft' && (github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success') }} + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Release with release-plz + uses: release-plz/action@v0.5 + with: + command: release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + + build-binaries: + needs: release-plz + if: ${{ needs.release-plz.result == 'success' }} + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: x86_64-unknown-linux-gnu + + - name: Install dependencies + run: sudo apt-get update && sudo apt-get install -y libudev-dev + + - name: Cache cargo + uses: Swatinem/rust-cache@v2 + + - name: Compute version and tag + id: meta + run: | + version=$(grep -m1 '^version' ostool/Cargo.toml | sed -E 's/version = "([^"]+)"/\1/') + echo "version=$version" >> "$GITHUB_OUTPUT" + echo "tag=ostool-v$version" >> "$GITHUB_OUTPUT" + echo "target=x86_64-unknown-linux-gnu" >> "$GITHUB_OUTPUT" + + - name: Check release exists + id: release_check + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if gh release view "${{ steps.meta.outputs.tag }}" >/dev/null 2>&1; then + echo "exists=true" >> "$GITHUB_OUTPUT" + else + echo "exists=false" >> "$GITHUB_OUTPUT" + fi + + - name: Build binaries + if: steps.release_check.outputs.exists == 'true' + run: | + cargo build --release -p ostool --bin ostool --target ${{ steps.meta.outputs.target }} + cargo build --release -p ostool --bin cargo-osrun --target ${{ steps.meta.outputs.target }} + + - name: Package artifacts + if: steps.release_check.outputs.exists == 'true' + run: | + version="${{ steps.meta.outputs.version }}" + target="${{ steps.meta.outputs.target }}" + dist="dist/ostool-${target}-v${version}" + mkdir -p "$dist" + cp "target/${target}/release/ostool" "$dist/" + cp "target/${target}/release/cargo-osrun" "$dist/" + tar -czf "ostool-${target}-v${version}.tar.gz" -C dist "ostool-${target}-v${version}" + sha256sum "ostool-${target}-v${version}.tar.gz" > "ostool-${target}-v${version}.tar.gz.sha256" + + - name: Upload release assets + if: steps.release_check.outputs.exists == 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + version="${{ steps.meta.outputs.version }}" + target="${{ steps.meta.outputs.target }}" + tag="${{ steps.meta.outputs.tag }}" + gh release upload "$tag" \ + "ostool-${target}-v${version}.tar.gz" \ + "ostool-${target}-v${version}.tar.gz.sha256" \ + --clobber diff --git a/ostool/Cargo.toml b/ostool/Cargo.toml index 461d3d3..8db3d06 100644 --- a/ostool/Cargo.toml +++ b/ostool/Cargo.toml @@ -11,6 +11,11 @@ readme = "../README.md" repository = "https://github.com/ZR233/ostool" version = "0.8.9" +[package.metadata.binstall] +bin-dir = "{ name }-{ target }-v{ version }/{ bin }{ binary-ext }" +pkg-fmt = "tgz" +pkg-url = "{ repo }/releases/download/{ name }-v{ version }/{ name }-{ target }-v{ version }{ archive-suffix }" + [[bin]] name = "ostool" path = "src/main.rs" @@ -24,7 +29,6 @@ ui-log = ["jkconfig/logging"] [dependencies] anyhow = {workspace = true, features = ["backtrace"]} -futures = "0.3" byte-unit = "5.1" cargo_metadata = "0.23" clap = {workspace = true, features = ["derive"]} @@ -32,6 +36,8 @@ colored = "3" crossterm = {workspace = true} cursive = {workspace = true, features = ["crossterm-backend"]} env_logger = {workspace = true} +fitimage = {version = "0.1", path = "../fitimage"} +futures = "0.3" indicatif = "0.18" jkconfig = {version = "0.1", path = "../jkconfig"} log = {workspace = true} @@ -47,7 +53,6 @@ tftpd = "0.5" tokio = {workspace = true, features = ["full"]} toml = {workspace = true} uboot-shell = {version = "0.2", path = "../uboot-shell"} -fitimage = {version = "0.1", path = "../fitimage"} lzma-rs = "0.3" regex = "1"