Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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') }}
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The repository owner check 'drivercraft' does not match the repository URL in ostool/Cargo.toml which points to 'github.com/ZR233/ostool'. This inconsistency will prevent the workflow from running when triggered. Either update this check to match 'ZR233' or update the repository field in Cargo.toml to match 'drivercraft'.

Copilot uses AI. Check for mistakes.
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
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the workflow is triggered by workflow_run, the code is checked out at the ref that triggered the workflow_run event, not necessarily the latest code in main. If release-plz creates commits or tags during its execution, the build-binaries job won't have access to those changes because it checked out before those changes were made. Consider fetching the latest state or using the tag created by release-plz to checkout the correct version.

Suggested change
uses: actions/checkout@v4
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0

Copilot uses AI. Check for mistakes.

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-gnu
Comment on lines +38 to +41
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow only builds for x86_64-unknown-linux-gnu target, but cargo-binstall users may need binaries for other common platforms like macOS (aarch64-apple-darwin, x86_64-apple-darwin) and Windows (x86_64-pc-windows-msvc). Consider adding a matrix strategy to build for multiple platforms to improve the utility of the binstall integration.

Copilot uses AI. Check for mistakes.

- 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/')
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version extraction uses 'grep -m1' which will match the first occurrence of 'version' in the file. This could incorrectly match a version string in a comment or different section. Consider using a more specific pattern like 'grep -m1 '^version =' ostool/Cargo.toml' to ensure it only matches the package version field.

Suggested change
version=$(grep -m1 '^version' ostool/Cargo.toml | sed -E 's/version = "([^"]+)"/\1/')
version=$(grep -m1 '^version =' ostool/Cargo.toml | sed -E 's/version = "([^"]+)"/\1/')

Copilot uses AI. Check for mistakes.
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'
Comment on lines +68 to +69
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build and packaging steps only execute if the release already exists (exists == 'true'), which seems counterintuitive. If the release doesn't exist, no binaries will be built or uploaded. This logic appears reversed - binaries should be built when the release exists to upload to it, but the workflow won't create binaries for new releases. Consider reviewing this conditional logic to ensure it matches the intended behavior.

Copilot uses AI. Check for mistakes.
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 }}
Comment on lines +70 to +72
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shell script doesn't have error handling enabled. If any command in the multi-line script fails (e.g., cargo build fails), the subsequent commands will still execute. Consider adding 'set -e' at the beginning of the script to exit on any error, or check the exit status of the cargo build commands before proceeding.

Copilot uses AI. Check for mistakes.

- 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"
Comment on lines +76 to +84
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shell script lacks error handling. If mkdir or cp commands fail, or if the tar command fails, the subsequent sha256sum command will still execute. Consider adding 'set -e' at the beginning to ensure the script exits on any error.

Copilot uses AI. Check for mistakes.

- 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
9 changes: 7 additions & 2 deletions ostool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -24,14 +29,15 @@ 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"]}
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}
Expand All @@ -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"
Expand Down