diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 6da2384..edc1c0d 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -12,7 +12,6 @@ jobs: steps: - name: Create artifacts directory run: mkdir artifacts - - name: Get the release version from the tag if: env.VERSION == '' run: | @@ -22,16 +21,12 @@ jobs: else echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV fi - - name: Validate version environment variable - run: | - echo "Version being built against is version ${{ env.VERSION }}"! - + run: echo "Version being built against is version ${{ env.VERSION }}"! - name: Save version number to artifact run: echo "${{ env.VERSION }}" > artifacts/release-version - - name: Upload artifacts - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: name: artifacts path: artifacts @@ -45,56 +40,63 @@ jobs: strategy: fail-fast: false matrix: + # prettier-ignore job: - # prettier-ignore - - { name: "macOS-arm64", os: "macOS-latest", target: "aarch64-apple-darwin", artifact_prefix: "macos-arm64", use-cross: true } - - { name: "macOS-amd64", os: "macOS-latest", target: "x86_64-apple-darwin", artifact_prefix: "macos" } - - { name: "windows-amd64", os: "windows-latest", target: "x86_64-pc-windows-msvc", artifact_prefix: "windows" } - - { name: "windows-aarch64", os: "windows-latest", target: "aarch64-pc-windows-msvc", artifact_prefix: "windows-aarch64", use-cross: true } - - { name: "linux-gnu", os: "ubuntu-latest", target: "x86_64-unknown-linux-gnu", artifact_prefix: "linux" } - - { name: "linux-musl", os: "ubuntu-latest", target: "x86_64-unknown-linux-musl", artifact_prefix: "linux-musl", use-cross: true, } - - { name: "aarch64-gnu", os: "ubuntu-latest", target: "aarch64-unknown-linux-gnu", artifact_prefix: "aarch64-gnu", use-cross: true, test-bin: "--bin kdash" } - - { name: "aarch64-musl", os: "ubuntu-latest", target: "aarch64-unknown-linux-musl", artifact_prefix: "aarch64-musl", use-cross: true, test-bin: "--bin kdash" } - - { name: "arm-gnu", os: "ubuntu-latest", target: "arm-unknown-linux-gnueabihf", artifact_prefix: "armv6-gnu", use-cross: true, test-bin: "--bin kdash" } - - { name: "arm-musl", os: "ubuntu-latest", target: "arm-unknown-linux-musleabihf", artifact_prefix: "armv6-musl", use-cross: true, test-bin: "--bin kdash" } - - { name: "armv7-gnu", os: "ubuntu-latest", target: "armv7-unknown-linux-gnueabihf", artifact_prefix: "armv7-gnu", use-cross: true, test-bin: "--bin kdash" } - - { name: "armv7-musl", os: "ubuntu-latest", target: "armv7-unknown-linux-musleabihf", artifact_prefix: "armv7-musl", use-cross: true, test-bin: "--bin kdash" } + - { name: "macOS-arm64", os: "macOS-latest", target: "aarch64-apple-darwin", artifact_prefix: "macos-arm64", use-cross: true } + - { name: "macOS-amd64", os: "macOS-latest", target: "x86_64-apple-darwin", artifact_prefix: "macos" } + - { name: "windows-amd64", os: "windows-latest", target: "x86_64-pc-windows-msvc", artifact_prefix: "windows" } + - { name: "windows-aarch64", os: "windows-latest", target: "aarch64-pc-windows-msvc", artifact_prefix: "windows-aarch64", use-cross: true } + - { name: "linux-gnu", os: "ubuntu-latest", target: "x86_64-unknown-linux-gnu", artifact_prefix: "linux" } + - { name: "linux-musl", os: "ubuntu-latest", target: "x86_64-unknown-linux-musl", artifact_prefix: "linux-musl", use-cross: true, } + - { name: "linux-aarch64-gnu", os: "ubuntu-latest", target: "aarch64-unknown-linux-gnu", artifact_prefix: "aarch64-gnu", use-cross: true, test-bin: "--bin kdash" } + - { name: "linux-aarch64-musl", os: "ubuntu-latest", target: "aarch64-unknown-linux-musl", artifact_prefix: "aarch64-musl", use-cross: true, test-bin: "--bin kdash" } + - { name: "linux-arm-gnu", os: "ubuntu-latest", target: "arm-unknown-linux-gnueabihf", artifact_prefix: "armv6-gnu", use-cross: true, test-bin: "--bin kdash" } + - { name: "linux-arm-musl", os: "ubuntu-latest", target: "arm-unknown-linux-musleabihf", artifact_prefix: "armv6-musl", use-cross: true, test-bin: "--bin kdash" } + - { name: "linux-armv7-gnu", os: "ubuntu-latest", target: "armv7-unknown-linux-gnueabihf", artifact_prefix: "armv7-gnu", use-cross: true, test-bin: "--bin kdash" } + - { name: "linux-armv7-musl", os: "ubuntu-latest", target: "armv7-unknown-linux-musleabihf", artifact_prefix: "armv7-musl", use-cross: true, test-bin: "--bin kdash" } rust: [stable] steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 1 - + - uses: actions/cache@v3 + name: Cache Cargo registry + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }} + - uses: actions/cache@v3 + if: startsWith(matrix.job.name, 'linux-') + with: + path: ~/.cargo/bin + key: ${{ runner.os }}-cargo-bin-${{ hashFiles('.github/workflows/cd.yml') }} - name: Get shared artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: artifacts path: artifacts - - name: Set release version shell: bash run: | release_version="$(cat ./artifacts/release-version)" echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV - - name: Validate release environment variables run: | echo "Release version: ${{ env.RELEASE_VERSION }}" - - - name: Install toolchain - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@stable + name: Set Rust toolchain + with: + targets: ${{ matrix.job.target }} + - uses: taiki-e/setup-cross-toolchain-action@v1 with: - toolchain: ${{ matrix.rust }} - override: true + # NB: sets CARGO_BUILD_TARGET evar - do not need --target flag in build target: ${{ matrix.job.target }} - profile: minimal # minimal component installation (ie, no documentation) - + - uses: taiki-e/install-action@cross + if: ${{ matrix.job.cross }} - name: Installing needed macOS dependencies if: matrix.job.os == 'macos-latest' run: brew install openssl@1.1 - - name: Installing needed Ubuntu dependencies if: matrix.job.os == 'ubuntu-latest' shell: bash @@ -107,26 +109,14 @@ jobs: esac - name: Build - uses: actions-rs/cargo@v1 - with: - use-cross: ${{ matrix.job.use-cross }} - command: build - args: --release --verbose --target=${{ matrix.job.target }} - toolchain: ${{ matrix.rust }} - + run: cargo build --release --verbose --target=${{ matrix.job.target }} --locked - name: Verify file shell: bash run: | file target/${{ matrix.job.target }}/release/kdash - ldd target/${{ matrix.job.target }}/release/kdash - - name: Test if: matrix.job.target != 'aarch64-apple-darwin' - uses: actions-rs/cargo@v1 - with: - use-cross: ${{ matrix.job.use-cross }} - command: test - args: --target=${{ matrix.job.target }} ${{ matrix.job.test-bin }} + run: cargo test --release --verbose --target=${{ matrix.job.target }} ${{ matrix.job.test-bin }} - name: Packaging final binary (Windows) if: matrix.job.os == 'windows-latest' @@ -149,7 +139,7 @@ jobs: # set the right strip executable STRIP="strip"; case ${{ matrix.job.target }} in - arm-*-linux-*) STRIP="arm-linux-gnueabihf-strip" ;; + arm*-linux-*) STRIP="arm-linux-gnueabihf-strip" ;; aarch64-*-linux-*) STRIP="aarch64-linux-gnu-strip" ;; esac; cd target/${{ matrix.job.target }}/release @@ -176,7 +166,7 @@ jobs: cp target/${{ matrix.job.target }}/release/${{ env.RELEASE_NAME }}.sha256 artifacts/ - name: Upload artifacts - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: name: artifacts path: artifacts @@ -187,12 +177,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 1 - name: Get release artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: artifacts path: artifacts @@ -238,12 +228,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 1 - name: Get release artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: artifacts path: artifacts @@ -302,7 +292,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Get release artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: artifacts path: artifacts @@ -332,16 +322,18 @@ jobs: needs: [build-release-artifacts] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + - uses: actions/cache@v3 + name: Cache Cargo registry with: - toolchain: stable - override: true - profile: minimal # minimal component installation (ie, no documentation) + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }} + - uses: actions/cache@v3 + with: + path: ~/.cargo/bin + key: ${{ runner.os }}-cargo-bin-${{ hashFiles('.github/workflows/cd.yml') }} + - uses: dtolnay/rust-toolchain@stable - run: | sudo apt-get update sudo apt-get install -y -qq pkg-config libssl-dev libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev - - uses: actions-rs/cargo@v1 - with: - command: publish - args: --token ${{ secrets.CARGO_API_KEY }} --allow-dirty + - run: cargo publish --token ${{ secrets.CARGO_API_KEY }} --allow-dirty diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c21f7d1..f5fdaf6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,14 +25,14 @@ jobs: needs: prepare steps: - uses: actions/checkout@master - - uses: actions-rs/toolchain@v1 + - uses: actions/cache@v3 + name: Cache Cargo registry with: - toolchain: stable - profile: minimal - override: true - - uses: actions-rs/cargo@v1 - with: - command: check + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }} + - uses: dtolnay/rust-toolchain@stable + name: Set Rust toolchain + - run: cargo check --all --all-targets --workspace test: name: Test Suite @@ -40,16 +40,16 @@ jobs: needs: prepare steps: - uses: actions/checkout@v1 - - uses: actions-rs/toolchain@v1 + - uses: actions/cache@v3 + name: Cache Cargo registry with: - toolchain: nightly - profile: minimal - override: true + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }} + - uses: dtolnay/rust-toolchain@stable + name: Set Rust toolchain # These dependencies are required for `clipboard` - run: sudo apt-get install -y -qq libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev - - uses: actions-rs/cargo@v1 - with: - command: test + - run: cargo test env: CARGO_INCREMENTAL: '0' RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' @@ -70,16 +70,16 @@ jobs: needs: prepare steps: - uses: actions/checkout@master - - uses: actions-rs/toolchain@v1 + - uses: actions/cache@v3 + name: Cache Cargo registry with: - toolchain: stable - profile: minimal - override: true - components: rustfmt - - uses: actions-rs/cargo@v1 + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }} + - uses: dtolnay/rust-toolchain@stable + name: Set Rust toolchain with: - command: fmt - args: --all -- --check + components: rustfmt + - run: cargo fmt --all -- --check clippy: name: Clippy @@ -87,15 +87,15 @@ jobs: needs: prepare steps: - uses: actions/checkout@master - - uses: actions-rs/toolchain@v1 + - uses: actions/cache@v3 + name: Cache Cargo registry with: - toolchain: stable - profile: minimal - override: true - components: clippy - - uses: actions-rs/cargo@v1 + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }} + - uses: dtolnay/rust-toolchain@stable + name: Set Rust toolchain with: - command: clippy - args: --all --all-features --all-targets --workspace -- -D warnings + components: clippy + - run: cargo clippy --all --all-features --all-targets --workspace -- -D warnings env: CARGO_INCREMENTAL: '0' diff --git a/.github/workflows/cicd-test.yml b/.github/workflows/cicd-test.yml index 4ad5319..eb9871b 100644 --- a/.github/workflows/cicd-test.yml +++ b/.github/workflows/cicd-test.yml @@ -5,6 +5,7 @@ on: name: CICD test jobs: + build-release-artifacts: name: build-release runs-on: ${{ matrix.job.os }} @@ -13,40 +14,51 @@ jobs: strategy: fail-fast: false matrix: + # prettier-ignore job: - # prettier-ignore - - { name: "macOS-arm64", os: "macOS-latest", target: "aarch64-apple-darwin", artifact_prefix: "macos-arm64", use-cross: true } - - { name: "macOS-amd64", os: "macOS-latest", target: "x86_64-apple-darwin", artifact_prefix: "macos" } - - { name: "windows-amd64", os: "windows-latest", target: "x86_64-pc-windows-msvc", artifact_prefix: "windows" } - - { name: "windows-aarch64", os: "windows-latest", target: "aarch64-pc-windows-msvc", artifact_prefix: "windows-aarch64", use-cross: true } - - { name: "linux-gnu", os: "ubuntu-latest", target: "x86_64-unknown-linux-gnu", artifact_prefix: "linux" } - - { name: "linux-musl", os: "ubuntu-latest", target: "x86_64-unknown-linux-musl", artifact_prefix: "linux-musl", use-cross: true, } - - { name: "aarch64-gnu", os: "ubuntu-latest", target: "aarch64-unknown-linux-gnu", artifact_prefix: "aarch64-gnu", use-cross: true, test-bin: "--bin kdash" } - - { name: "aarch64-musl", os: "ubuntu-latest", target: "aarch64-unknown-linux-musl", artifact_prefix: "aarch64-musl", use-cross: true, test-bin: "--bin kdash" } - - { name: "arm-gnu", os: "ubuntu-latest", target: "arm-unknown-linux-gnueabihf", artifact_prefix: "armv6-gnu", use-cross: true, test-bin: "--bin kdash" } - - { name: "arm-musl", os: "ubuntu-latest", target: "arm-unknown-linux-musleabihf", artifact_prefix: "armv6-musl", use-cross: true, test-bin: "--bin kdash" } - - { name: "armv7-gnu", os: "ubuntu-latest", target: "armv7-unknown-linux-gnueabihf", artifact_prefix: "armv7-gnu", use-cross: true, test-bin: "--bin kdash" } - - { name: "armv7-musl", os: "ubuntu-latest", target: "armv7-unknown-linux-musleabihf", artifact_prefix: "armv7-musl", use-cross: true, test-bin: "--bin kdash" } + - { name: "macOS-arm64", os: "macOS-latest", target: "aarch64-apple-darwin", artifact_prefix: "macos-arm64", use-cross: true } + - { name: "macOS-amd64", os: "macOS-latest", target: "x86_64-apple-darwin", artifact_prefix: "macos" } + - { name: "windows-amd64", os: "windows-latest", target: "x86_64-pc-windows-msvc", artifact_prefix: "windows" } + - { name: "windows-aarch64", os: "windows-latest", target: "aarch64-pc-windows-msvc", artifact_prefix: "windows-aarch64", use-cross: true } + - { name: "linux-gnu", os: "ubuntu-latest", target: "x86_64-unknown-linux-gnu", artifact_prefix: "linux" } + - { name: "linux-musl", os: "ubuntu-latest", target: "x86_64-unknown-linux-musl", artifact_prefix: "linux-musl", use-cross: true, } + - { name: "linux-aarch64-gnu", os: "ubuntu-latest", target: "aarch64-unknown-linux-gnu", artifact_prefix: "aarch64-gnu", use-cross: true, test-bin: "--bin kdash" } + - { name: "linux-aarch64-musl", os: "ubuntu-latest", target: "aarch64-unknown-linux-musl", artifact_prefix: "aarch64-musl", use-cross: true, test-bin: "--bin kdash" } + - { name: "linux-arm-gnu", os: "ubuntu-latest", target: "arm-unknown-linux-gnueabihf", artifact_prefix: "armv6-gnu", use-cross: true, test-bin: "--bin kdash" } + - { name: "linux-arm-musl", os: "ubuntu-latest", target: "arm-unknown-linux-musleabihf", artifact_prefix: "armv6-musl", use-cross: true, test-bin: "--bin kdash" } + - { name: "linux-armv7-gnu", os: "ubuntu-latest", target: "armv7-unknown-linux-gnueabihf", artifact_prefix: "armv7-gnu", use-cross: true, test-bin: "--bin kdash" } + - { name: "linux-armv7-musl", os: "ubuntu-latest", target: "armv7-unknown-linux-musleabihf", artifact_prefix: "armv7-musl", use-cross: true, test-bin: "--bin kdash" } rust: [stable] steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 1 + - uses: actions/cache@v3 + name: Cache Cargo registry + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }} + - uses: actions/cache@v3 + if: startsWith(matrix.job.name, 'linux-') + with: + path: ~/.cargo/bin + key: ${{ runner.os }}-cargo-bin-${{ hashFiles('.github/workflows/cd.yml') }} - - name: Install toolchain - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@stable + name: Set Rust toolchain with: - toolchain: ${{ matrix.rust }} - override: true + targets: ${{ matrix.job.target }} + - uses: taiki-e/setup-cross-toolchain-action@v1 + with: + # NB: sets CARGO_BUILD_TARGET evar - do not need --target flag in build target: ${{ matrix.job.target }} - profile: minimal # minimal component installation (ie, no documentation) - + - uses: taiki-e/install-action@cross + if: ${{ matrix.job.cross }} - name: Installing needed macOS dependencies if: matrix.job.os == 'macos-latest' run: brew install openssl@1.1 - - name: Installing needed Ubuntu dependencies if: matrix.job.os == 'ubuntu-latest' shell: bash @@ -59,23 +71,66 @@ jobs: esac - name: Build - uses: actions-rs/cargo@v1 - with: - use-cross: ${{ matrix.job.use-cross }} - command: build - args: --release --verbose --target=${{ matrix.job.target }} - toolchain: ${{ matrix.rust }} - + run: cargo build --release --verbose --target=${{ matrix.job.target }} --locked - name: Verify file shell: bash run: | file target/${{ matrix.job.target }}/release/kdash - ldd target/${{ matrix.job.target }}/release/kdash - - name: Test if: matrix.job.target != 'aarch64-apple-darwin' - uses: actions-rs/cargo@v1 + run: cargo test --release --verbose --target=${{ matrix.job.target }} ${{ matrix.job.test-bin }} + + - name: Packaging final binary (Windows) + if: matrix.job.os == 'windows-latest' + shell: bash + run: | + cd target/${{ matrix.job.target }}/release + BINARY_NAME=kdash.exe + # strip the binary + strip $BINARY_NAME + RELEASE_NAME=kdash-${{ matrix.job.artifact_prefix }} + tar czvf $RELEASE_NAME.tar.gz $BINARY_NAME + # create sha checksum files + certutil -hashfile $RELEASE_NAME.tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > $RELEASE_NAME.sha256 + echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV + + - name: Packaging final binary (macOS and Linux) + if: matrix.job.os != 'windows-latest' + shell: bash + run: | + # set the right strip executable + STRIP="strip"; + case ${{ matrix.job.target }} in + arm*-linux-*) STRIP="arm-linux-gnueabihf-strip" ;; + aarch64-*-linux-*) STRIP="aarch64-linux-gnu-strip" ;; + esac; + cd target/${{ matrix.job.target }}/release + BINARY_NAME=kdash + # strip the binary + "$STRIP" "$BINARY_NAME" + RELEASE_NAME=kdash-${{ matrix.job.artifact_prefix }} + tar czvf $RELEASE_NAME.tar.gz $BINARY_NAME + # create sha checksum files + shasum -a 256 $RELEASE_NAME.tar.gz > $RELEASE_NAME.sha256 + echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV + + publish-cargo: + name: Publishing to Cargo + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v3 + name: Cache Cargo registry with: - use-cross: ${{ matrix.job.use-cross }} - command: test - args: --target=${{ matrix.job.target }} ${{ matrix.job.test-bin }} + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }} + - uses: actions/cache@v3 + with: + path: ~/.cargo/bin + key: ${{ runner.os }}-cargo-bin-${{ hashFiles('.github/workflows/cd.yml') }} + - uses: dtolnay/rust-toolchain@stable + - run: | + sudo apt-get update + sudo apt-get install -y -qq pkg-config libssl-dev libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev + - run: cargo publish --token ${{ secrets.CARGO_API_KEY }} --allow-dirty --dry-run + diff --git a/README.md b/README.md index fb3738c..50b436e 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ curl https://raw.githubusercontent.com/kdash-rs/kdash/main/deployment/getLatest. ### Manual -Binaries for macOS, Linux and Windows are available on the [releases](https://github.com/kdash-rs/kdash/releases) page +Binaries for macOS (x86_64, arm64), Linux GNU/MUSL(x86_64, armv6, armv7, aarch64) and Windows (x86_64, aarch64) are available on the [releases](https://github.com/kdash-rs/kdash/releases) page 1. Download the latest [binary](https://github.com/kdash-rs/kdash/releases) for your OS. 1. For Linux/macOS: