From 16437c9d0f7e7bc49cb6f1f1bd3f03275fdaf923 Mon Sep 17 00:00:00 2001 From: Asmir Avdicevic Date: Tue, 22 Oct 2024 09:17:29 +0200 Subject: [PATCH] chore: clean up CI --- .github/workflows/ci.yml | 47 +------------------------------ .github/workflows/release.yml | 52 +++++++++++++++++++++++++++++------ 2 files changed, 45 insertions(+), 54 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fad0cb8..a40e187 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: toolchain: "x86_64-unknown-linux-gnu" name: "Linux GNU" - os: "macOS-latest" - toolchain: "x86_64-apple-darwin" + toolchain: "aarch64-apple-darwin" name: "macOS" - os: "windows-latest" toolchain: "x86_64-pc-windows-msvc" @@ -63,38 +63,6 @@ jobs: - name: cargo test run: cargo test --locked --workspace --all-features --bins --tests --examples - test-release: - runs-on: ${{ matrix.target.os }} - strategy: - fail-fast: false - matrix: - target: - - os: "ubuntu-latest" - toolchain: "x86_64-unknown-linux-gnu" - name: "Linux GNU" - - os: "macOS-latest" - toolchain: "x86_64-apple-darwin" - name: "macOS" - - os: "windows-latest" - toolchain: "x86_64-pc-windows-msvc" - name: "Windows MSVC" - - os: "windows-latest" - toolchain: "x86_64-pc-windows-gnu" - name: "Windows GNU" - channel: - - "stable" - - "beta" - - "nightly" - steps: - - uses: actions/checkout@v2 - - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ matrix.channel }} - targets: ${{ matrix.target.toolchain }} - - uses: swatinem/rust-cache@v2 - - name: cargo test - run: cargo test --release --locked --workspace --all-features --bins --tests --examples - # Checks correct runtime deps and features are requested by not including dev-dependencies. check-deps: runs-on: ubuntu-latest @@ -104,16 +72,3 @@ jobs: - uses: swatinem/rust-cache@v2 - name: cargo check run: cargo check --workspace --all-features --bins - - # Minimal crates needs adding proc-macro 1.0.66 as a dev dependency. - # Since it is not necessary for a bin project, disabled. - # minimal-crates: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v2 - # - uses: dtolnay/rust-toolchain@nightly - # - uses: swatinem/rust-cache@v2 - # - name: cargo check - # run: | - # rm -f Cargo.lock - # cargo +nightly check -Z minimal-versions --workspace --all-features --bins diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 16ddd8b..6ec3432 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,6 +19,20 @@ on: push: tags: - "v*" + workflow_dispatch: + inputs: + release_version: + description: "Release version" + required: true + default: "" + create_release: + description: "Create release" + required: true + default: "true" + upload_artifacts: + description: "Upload artifacts" + required: true + default: "true" env: BIN_NAME: dumbpipe @@ -32,19 +46,26 @@ jobs: upload_url: ${{ steps.release.outputs.upload_url }} release_version: ${{ env.RELEASE_VERSION }} steps: - - name: Get the release version from the tag + - name: Get the release version from the tag (push) shell: bash - if: env.RELEASE_VERSION == '' + if: env.RELEASE_VERSION == '' && github.event_name == 'push' run: | # See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027 echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV echo "version is: ${{ env.RELEASE_VERSION }}" + - name: Get the release version from the tag (dispatch) + shell: bash + if: github.event_name == 'workflow_dispatch' + run: | + echo "RELEASE_VERSION=${{ github.event.inputs.release_version }}" >> $GITHUB_ENV + echo "version is: ${{ env.RELEASE_VERSION }}" - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 1 - name: Create GitHub release id: release + if: github.event.inputs.create_release == 'true' || github.event_name == 'push' uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -57,29 +78,34 @@ jobs: runs-on: ${{ matrix.runner }} strategy: matrix: - name: [ubuntu-latest, ubuntu-arm-latest, macOS-latest, macOS-arm-latest, windows-latest] + name: [ubuntu-latest, ubuntu-arm-latest, macOS-arm-latest, macOS-latest, windows-latest] rust: [stable] include: - name: ubuntu-arm-latest os: ubuntu-latest target: linux-aarch64 + cargo_targets: "aarch64-unknown-linux-musl" runner: [self-hosted, linux, ARM64] - name: ubuntu-latest os: ubuntu-latest target: linux-x86_64 + cargo_targets: "x86_64-unknown-linux-musl" runner: [self-hosted, linux, X64] - name: macOS-latest os: macOS-latest target: darwin-x86_64 - runner: [self-hosted, macOS, X64] + cargo_targets: "x86_64-apple-darwin" + runner: [self-hosted, macOS, ARM64] - name: macOS-arm-latest os: macOS-latest target: darwin-aarch64 + cargo_targets: "aarch64-apple-darwin" runner: [self-hosted, macOS, ARM64] # TODO: windows runner is not available on the org level - name: windows-latest os: windows-latest target: windows-x86_64 + cargo_targets: "x86_64-pc-windows-msvc" runner: [windows-latest] steps: - name: Checkout repository @@ -90,26 +116,36 @@ jobs: uses: dtolnay/rust-toolchain@stable with: toolchain: ${{ matrix.rust }} + targets: ${{ matrix.cargo_targets }} + - name: Ensure musl support + if: ${{ contains(matrix.cargo_targets, '-musl') }} + run: sudo apt-get install musl-tools -y - name: Build release binary - run: cargo build --verbose --release + shell: bash + run: | + if [ "${{ matrix.name }}" = "ubuntu-arm-latest" ]; then + export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-gnu-gcc + export CC=aarch64-linux-gnu-gcc + fi + cargo build --verbose --release --target ${{ matrix.cargo_targets }} - name: Build archive shell: bash run: | - outdir="./target/release" staging="${{ env.BIN_NAME }}-${{ needs.create-release.outputs.release_version }}-${{ matrix.target }}" mkdir -p "$staging" if [ "${{ matrix.os }}" = "windows-latest" ]; then - cp "target/release/${{ env.BIN_NAME }}.exe" "$staging/" + cp "target/${{ matrix.cargo_targets }}/release/${{ env.BIN_NAME }}.exe" "$staging/" cd "$staging" 7z a "../$staging.zip" . echo "ASSET=$staging.zip" >> $GITHUB_ENV else - cp "target/release/${{ env.BIN_NAME }}" "$staging/" + cp "target/${{ matrix.cargo_targets }}/release/${{ env.BIN_NAME }}" "$staging/" tar czf "$staging.tar.gz" -C "$staging" . echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV fi - name: Upload release archive uses: actions/upload-release-asset@v1.0.2 + if: github.event.inputs.upload_artifacts == 'true' || github.event_name == 'push' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: