From 1bc7baded5884116133dcedcf636531e42304ef2 Mon Sep 17 00:00:00 2001 From: Andrew Gunnerson Date: Sun, 14 Apr 2024 15:37:29 -0400 Subject: [PATCH] Update Github Actions workflows * Update all Actions dependencies * Use Rust triple instead of LLVM triple * Remove unnecessary explicit installation of clippy * Switch to zstd compression for Linux tarballs Signed-off-by: Andrew Gunnerson --- .github/workflows/ci.yml | 20 +++++------ .github/workflows/release.yml | 67 +++++++++++++---------------------- 2 files changed, 34 insertions(+), 53 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2564be4..2009568 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,32 +10,30 @@ jobs: runs-on: ${{ matrix.os }} env: CARGO_TERM_COLOR: always + RUSTFLAGS: -C strip=symbols strategy: fail-fast: false matrix: - os: [windows-latest, ubuntu-latest] + os: + - windows-latest + - ubuntu-latest steps: - name: Check out repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 1 - - name: Get Rust LLVM target triple + - name: Get Rust target triple id: get_target shell: bash run: | echo -n 'name=' >> "${GITHUB_OUTPUT}" - RUSTC_BOOTSTRAP=1 rustc -Z unstable-options --print target-spec-json \ - | jq -r '."llvm-target"' \ - >> "${GITHUB_OUTPUT}" + rustc -vV | sed -n 's|host: ||p' >> "${GITHUB_OUTPUT}" - name: Install build dependencies if: matrix.os == 'ubuntu-latest' run: sudo apt install -y libdbus-1-dev - - name: Install clippy - run: rustup component add clippy - - name: Run clippy checks in debug mode env: RUST_BACKTRACE: 1 @@ -43,10 +41,10 @@ jobs: cargo clippy --workspace -- -D warnings - name: Build in debug mode - run: cargo build --verbose + run: cargo build - name: Archive artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: svrbsctl-${{ steps.get_target.outputs.name }} path: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d8f1ecd..7205030 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,16 +2,15 @@ on: push: # Uncomment to test against a branch - #branches: - # - ci + branches: + - ci tags: - 'v*' jobs: - create_release: - name: Create GitHub release + get_version: + name: Get version runs-on: ubuntu-latest outputs: - upload_url: ${{ steps.create_release.outputs.upload_url }} version: ${{ steps.get_version.outputs.version }} steps: - name: Get version from tag @@ -24,49 +23,36 @@ jobs: fi echo "version=${version}" >> "${GITHUB_OUTPUT}" - - name: Create release - id: create_release - uses: actions/create-release@latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: v${{ steps.get_version.outputs.version }} - release_name: Version ${{ steps.get_version.outputs.version }} - draft: false - prerelease: false - build_and_upload: name: Build and upload assets - needs: create_release + needs: get_version runs-on: ${{ matrix.os }} env: CARGO_TERM_COLOR: always + RUSTFLAGS: -C strip=symbols strategy: fail-fast: false matrix: - os: [windows-latest, ubuntu-latest] + os: + - windows-latest + - ubuntu-latest steps: - name: Check out repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 1 - - name: Get Rust LLVM target triple + - name: Get Rust target triple id: get_target shell: bash run: | echo -n 'name=' >> "${GITHUB_OUTPUT}" - RUSTC_BOOTSTRAP=1 rustc -Z unstable-options --print target-spec-json \ - | jq -r '."llvm-target"' \ - >> "${GITHUB_OUTPUT}" + rustc -vV | sed -n 's|host: ||p' >> "${GITHUB_OUTPUT}" - name: Install build dependencies if: matrix.os == 'ubuntu-latest' run: sudo apt install -y libdbus-1-dev - - name: Install clippy - run: rustup component add clippy - - name: Run clippy checks in release mode env: RUST_BACKTRACE: 1 @@ -74,35 +60,32 @@ jobs: cargo clippy --workspace --release -- -D warnings - name: Build in release mode - run: cargo build --release --verbose - - - name: Strip release binary (non-Windows) - if: matrix.os == 'ubuntu-latest' - run: strip target/release/svrbsctl + run: cargo build --release - name: Build archive + id: build_archive shell: bash run: | - base_name=svrbsctl-${{ needs.create_release.outputs.version }}-${{ steps.get_target.outputs.name }} + base_name=svrbsctl-${{ needs.get_version.outputs.version }}-${{ steps.get_target.outputs.name }} mkdir "${base_name}" cp {README.md,LICENSE} "${base_name}/" if [[ "${{ matrix.os }}" == windows-* ]]; then cp target/release/svrbsctl.exe "${base_name}/" 7z a "${base_name}.zip" "${base_name}" - echo "ASSET=${base_name}.zip" >> "${GITHUB_ENV}" + echo "name=${base_name}.zip" >> "${GITHUB_OUTPUT}" else cp target/release/svrbsctl "${base_name}/" - tar -Jcvf "${base_name}.tar.xz" "${base_name}" - echo "ASSET=${base_name}.tar.xz" >> "${GITHUB_ENV}" + tar -I zstd -cvf "${base_name}.tar.zst" "${base_name}" + echo "name=${base_name}.tar.zst" >> "${GITHUB_OUTPUT}" fi - name: Upload release assets - uses: actions/upload-release-asset@v1.0.2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: softprops/action-gh-release@v2 with: - upload_url: ${{ needs.create_release.outputs.upload_url }} - asset_name: ${{ env.ASSET }} - asset_path: ${{ env.ASSET }} - asset_content_type: application/octet-stream + token: ${{ secrets.GITHUB_TOKEN }} + tag_name: v${{ steps.get_version.outputs.version }} + name: Version ${{ steps.get_version.outputs.version }} + draft: true + prerelease: false + files: ${{ steps.build_archive.outputs.name }}