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
6 changes: 1 addition & 5 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ name: Quality Check
on:
workflow_call:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
check:
Expand All @@ -19,7 +15,7 @@ jobs:
targets: [x86_64-unknown-linux-gnu]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: ${{ matrix.rust-toolchain }}
Expand Down
95 changes: 9 additions & 86 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@ on:
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') }}
if: &release_condition ${{ github.repository_owner == 'drivercraft' && github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-22.04
steps:
- &checkout
name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
fetch-depth: 0
persist-credentials: false
Expand All @@ -36,99 +35,23 @@ jobs:
uses: release-plz/action@v0.5
with:
command: release
env:
env: &release_env
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
# Create a PR with the new versions and changelog, preparing the next release.

release-plz-pr:
name: Release-plz PR
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
if: *release_condition
runs-on: ubuntu-22.04
concurrency:
group: release-plz-${{ github.ref }}
group: release-plz-pr-${{ github.ref }}
cancel-in-progress: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- *checkout
- *install-rust
- *setup-libudenv
- name: Run release-plz
uses: release-plz/action@v0.5
with:
command: release-pr
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
env: *release_env