diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index b9486c3..95d06ba 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -3,11 +3,7 @@ name: Quality Check on: workflow_call: push: - branches: - - main pull_request: - branches: - - main jobs: check: @@ -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 }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f3c1715..5388886 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,6 @@ on: workflows: ["Quality Check"] branches: [main] types: [completed] - workflow_dispatch: permissions: contents: write @@ -13,12 +12,12 @@ permissions: 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 @@ -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