From 5371aa0e7c708f2df7e267d6a95a02350d0ee5f4 Mon Sep 17 00:00:00 2001 From: Anton Malinskiy Date: Thu, 24 Apr 2025 02:01:58 +1000 Subject: [PATCH 1/4] feat(android): add google_apis_playstore system image --- src/cli/android/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cli/android/mod.rs b/src/cli/android/mod.rs index ca0bfb9..450f536 100644 --- a/src/cli/android/mod.rs +++ b/src/cli/android/mod.rs @@ -19,6 +19,8 @@ pub enum SystemImage { Default, #[clap(name = "google_apis")] GoogleApis, + #[clap(name = "google_apis_playstore")] + GoogleApisPlaystore, } impl Display for SystemImage { @@ -26,6 +28,7 @@ impl Display for SystemImage { match self { SystemImage::Default => f.write_str("default"), SystemImage::GoogleApis => f.write_str("google_apis"), + SystemImage::GoogleApisPlaystore => f.write_str("google_apis_playstore"), } } } @@ -207,7 +210,7 @@ If you are interesting in library testing then please use advance mode with --li } (_, _, Some(SystemImage::Default) | None, Some(OsVersion::Android15)) => { return Err(ConfigurationError::UnsupportedRunConfiguration { - message: "Android OS version 15 only supports google-apis system image".into(), + message: "Android OS version 15 only supports google_apis or google_apis_playstore system image".into(), } .into()); } From 763595b22e26ae207264b9f4fe741cfb0f60cd19 Mon Sep 17 00:00:00 2001 From: Anton Malinskiy Date: Thu, 24 Apr 2025 09:47:21 +1000 Subject: [PATCH 2/4] fix(deps): update ring due to RUSTSEC-2025-0009 --- Cargo.lock | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ceffb96..a3151f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -231,9 +231,12 @@ checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cc" -version = "1.0.90" +version = "1.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "8e3a13707ac958681c13b39b458c073d0d9bc8a22cb1b2f4c8e55eb72c13f362" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -1548,15 +1551,14 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.8" +version = "0.17.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" dependencies = [ "cc", "cfg-if", "getrandom", "libc", - "spin", "untrusted", "windows-sys 0.52.0", ] @@ -1827,6 +1829,12 @@ dependencies = [ "dirs", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -1873,12 +1881,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - [[package]] name = "stable_deref_trait" version = "1.2.0" From 34dbea87a43edd790d4a5286c75831855013ae78 Mon Sep 17 00:00:00 2001 From: Anton Malinskiy Date: Thu, 24 Apr 2025 10:36:52 +1000 Subject: [PATCH 3/4] feat(rust): bump msrv --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 8ea1650..ff2102e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ name = "marathon-cloud" repository = "https://github.com/MarathonLabs/marathon-cloud-cli" version = "0.0.1" edition = "2021" -rust-version = "1.74" +rust-version = "1.84.1" default-run = "marathon-cloud" [[bin]] From 0127513fa48f6f7541693c3f725ea63dbf05ced0 Mon Sep 17 00:00:00 2001 From: Anton Malinskiy Date: Thu, 24 Apr 2025 17:04:07 +1000 Subject: [PATCH 4/4] fix(ci): remove windows gnu --- .github/workflows/ci.yaml | 785 ++++++++++++++++++++------------------ 1 file changed, 412 insertions(+), 373 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f1150f2..1cfa2ff 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,9 +12,9 @@ on: pull_request: push: branches: - - main + - main tags: - - '*' + - "*" jobs: all-jobs: @@ -35,21 +35,21 @@ jobs: name: Extract crate metadata runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Extract crate information - id: crate_metadata - run: | - cargo metadata --no-deps --format-version 1 | jq -r '"name=" + .packages[0].name' | tee -a $GITHUB_OUTPUT - cargo metadata --no-deps --format-version 1 | jq -r '"maintainer=" + .packages[0].authors[0]' | tee -a $GITHUB_OUTPUT - cargo metadata --no-deps --format-version 1 | jq -r '"homepage=" + .packages[0].homepage' | tee -a $GITHUB_OUTPUT - cargo metadata --no-deps --format-version 1 | jq -r '"msrv=" + .packages[0].rust_version' | tee -a $GITHUB_OUTPUT - - if [[ $GITHUB_REF =~ ^refs/tags/[0-9].* ]]; then - VERSION=$(echo $GITHUB_REF | cut -d / -f 3) - echo "version=${VERSION}" >> $GITHUB_OUTPUT - else - cargo metadata --no-deps --format-version 1 | jq -r '"version=" + .packages[0].version' | tee -a $GITHUB_OUTPUT - fi + - uses: actions/checkout@v4 + - name: Extract crate information + id: crate_metadata + run: | + cargo metadata --no-deps --format-version 1 | jq -r '"name=" + .packages[0].name' | tee -a $GITHUB_OUTPUT + cargo metadata --no-deps --format-version 1 | jq -r '"maintainer=" + .packages[0].authors[0]' | tee -a $GITHUB_OUTPUT + cargo metadata --no-deps --format-version 1 | jq -r '"homepage=" + .packages[0].homepage' | tee -a $GITHUB_OUTPUT + cargo metadata --no-deps --format-version 1 | jq -r '"msrv=" + .packages[0].rust_version' | tee -a $GITHUB_OUTPUT + + if [[ $GITHUB_REF =~ ^refs/tags/[0-9].* ]]; then + VERSION=$(echo $GITHUB_REF | cut -d / -f 3) + echo "version=${VERSION}" >> $GITHUB_OUTPUT + else + cargo metadata --no-deps --format-version 1 | jq -r '"version=" + .packages[0].version' | tee -a $GITHUB_OUTPUT + fi outputs: name: ${{ steps.crate_metadata.outputs.name }} @@ -62,42 +62,42 @@ jobs: name: Ensure 'cargo fmt' has been run runs-on: ubuntu-22.04 steps: - - uses: dtolnay/rust-toolchain@stable - with: - components: rustfmt - - uses: actions/checkout@v4 - - run: cargo fmt -- --check + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + - uses: actions/checkout@v4 + - run: cargo fmt -- --check min_version: name: Minimum supported rust version runs-on: ubuntu-22.04 needs: crate_metadata steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Install rust toolchain (v${{ needs.crate_metadata.outputs.msrv }}) - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ needs.crate_metadata.outputs.msrv }} - components: clippy - - name: Run clippy (on minimum supported rust version to prevent warnings we can't fix) - run: cargo clippy --locked --all-targets ${{ env.MSRV_FEATURES }} - - name: Run tests - run: cargo test --locked ${{ env.MSRV_FEATURES }} + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Install rust toolchain (v${{ needs.crate_metadata.outputs.msrv }}) + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ needs.crate_metadata.outputs.msrv }} + components: clippy + - name: Run clippy (on minimum supported rust version to prevent warnings we can't fix) + run: cargo clippy --locked --all-targets ${{ env.MSRV_FEATURES }} + - name: Run tests + run: cargo test --locked ${{ env.MSRV_FEATURES }} documentation: name: Documentation runs-on: ubuntu-22.04 steps: - - name: Git checkout - uses: actions/checkout@v4 - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - - name: Generate documentation - run: mkdir -p target/release/man && OUT_DIR=target/release/man/ cargo run --bin marathon-cloud-mangen - - name: Show man page - run: man target/release/man/marathon-cloud.1 + - name: Git checkout + uses: actions/checkout@v4 + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + - name: Generate documentation + run: mkdir -p target/release/man && OUT_DIR=target/release/man/ cargo run --bin marathon-cloud-mangen + - name: Show man page + run: man target/release/man/marathon-cloud.1 cargo-audit: name: cargo audit @@ -114,337 +114,376 @@ jobs: fail-fast: false matrix: job: - - { target: aarch64-unknown-linux-gnu , os: ubuntu-22.04, dpkg_arch: arm64, use-cross: true } - - { target: aarch64-unknown-linux-musl , os: ubuntu-22.04, dpkg_arch: arm64, use-cross: true } - - { target: arm-unknown-linux-gnueabihf , os: ubuntu-22.04, dpkg_arch: armhf, use-cross: true } - - { target: arm-unknown-linux-musleabihf , os: ubuntu-22.04, dpkg_arch: musl-linux-armhf, use-cross: true } - - { target: i686-pc-windows-msvc , os: windows-2019, } - - { target: i686-unknown-linux-gnu , os: ubuntu-22.04, dpkg_arch: i686, use-cross: true } - - { target: i686-unknown-linux-musl , os: ubuntu-22.04, dpkg_arch: musl-linux-i686, use-cross: true } - - { target: 'x86_64-apple-darwin,aarch64-apple-darwin', os: macos-13, } - - { target: x86_64-pc-windows-gnu , os: windows-2019, } - - { target: x86_64-pc-windows-msvc , os: windows-2019, } - - { target: x86_64-unknown-linux-gnu , os: ubuntu-22.04, dpkg_arch: amd64, use-cross: true } - - { target: x86_64-unknown-linux-musl , os: ubuntu-22.04, dpkg_arch: musl-linux-amd64, use-cross: true } + - { + target: aarch64-unknown-linux-gnu, + os: ubuntu-22.04, + dpkg_arch: arm64, + use-cross: true, + } + - { + target: aarch64-unknown-linux-musl, + os: ubuntu-22.04, + dpkg_arch: arm64, + use-cross: true, + } + - { + target: arm-unknown-linux-gnueabihf, + os: ubuntu-22.04, + dpkg_arch: armhf, + use-cross: true, + } + - { + target: arm-unknown-linux-musleabihf, + os: ubuntu-22.04, + dpkg_arch: musl-linux-armhf, + use-cross: true, + } + - { target: i686-pc-windows-msvc, os: windows-2019 } + - { + target: i686-unknown-linux-gnu, + os: ubuntu-22.04, + dpkg_arch: i686, + use-cross: true, + } + - { + target: i686-unknown-linux-musl, + os: ubuntu-22.04, + dpkg_arch: musl-linux-i686, + use-cross: true, + } + - { target: "x86_64-apple-darwin,aarch64-apple-darwin", os: macos-13 } + - { target: x86_64-pc-windows-msvc, os: windows-2019 } + - { + target: x86_64-unknown-linux-gnu, + os: ubuntu-22.04, + dpkg_arch: amd64, + use-cross: true, + } + - { + target: x86_64-unknown-linux-musl, + os: ubuntu-22.04, + dpkg_arch: musl-linux-amd64, + use-cross: true, + } env: BUILD_CMD: cargo CARGO_EDIT_VERSION: 0.12.2 steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Check for release - id: is-release - shell: bash - run: | - unset IS_RELEASE ; if [[ $GITHUB_REF =~ ^refs/tags/[0-9].* ]]; then IS_RELEASE='true' ; fi - echo "IS_RELEASE=${IS_RELEASE}" >> $GITHUB_OUTPUT - unset VERSION - VERSION=$(echo $GITHUB_REF | cut -d / -f 3) - echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT - - - name: Install prerequisites - shell: bash - run: | - case ${{ matrix.job.target }} in - arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;; - aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;; - esac - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.job.target }} - - - run: | - cargo install --version ${{ env.CARGO_EDIT_VERSION }} cargo-edit - cargo set-version ${{ steps.is-release.outputs.VERSION }} - if: steps.is-release.outputs.IS_RELEASE - - - name: Install cross - if: matrix.job.use-cross - uses: taiki-e/install-action@v2 - with: - tool: cross - - - name: Overwrite build command env variable - if: matrix.job.use-cross - shell: bash - run: echo "BUILD_CMD=cross" >> $GITHUB_ENV - - - name: Show version information (Rust, cargo, GCC) - shell: bash - run: | - gcc --version || true - rustup -V - rustup toolchain list - rustup default - cargo -V - rustc -V - - - name: Set binary name & path - id: bin - shell: bash - run: | - # Figure out suffix of binary - EXE_suffix="" - case ${{ matrix.job.target }} in - *-pc-windows-*) EXE_suffix=".exe" ;; - esac; - - # Setup paths - BIN_NAME="${{ needs.crate_metadata.outputs.name }}${EXE_suffix}" - # For macos we use universal binary - if [[ ${{ matrix.job.os }} = macos-* ]]; then - BIN_PATH="target/universal-apple-darwin/release/${BIN_NAME}" - else - BIN_PATH="target/${{ matrix.job.target }}/release/${BIN_NAME}" - fi - - # Let subsequent steps know where to find the binary - - echo "BIN_PATH=${BIN_PATH}" >> $GITHUB_OUTPUT - echo "BIN_NAME=${BIN_NAME}" >> $GITHUB_OUTPUT - - - name: Build - shell: bash - run: | - if [[ ${{ matrix.job.os }} = macos-* ]] - then - # For macos we build universal binary - for i in $(echo "${{ matrix.job.target}}" | sed "s/,/ /g") - do - $BUILD_CMD build --locked --release --target=$i - done - - BIN_INTEL_PATH="target/x86_64-apple-darwin/release/${{ steps.bin.outputs.BIN_NAME}}" - BIN_APPLE_PATH="target/aarch64-apple-darwin/release/${{ steps.bin.outputs.BIN_NAME}}" - - mkdir -p target/universal-apple-darwin/release - lipo -create -output target/universal-apple-darwin/release/${{ steps.bin.outputs.BIN_NAME}} ${BIN_INTEL_PATH} ${BIN_APPLE_PATH} - else - $BUILD_CMD build --locked --release --target=${{ matrix.job.target }} - fi - - - name: Set testing options - id: test-options - shell: bash - run: | - # test only library unit tests and binary for arm-type targets - unset CARGO_TEST_OPTIONS - unset CARGO_TEST_OPTIONS ; case ${{ matrix.job.target }} in arm-* | aarch64-*) CARGO_TEST_OPTIONS="--lib --bin ${{ needs.crate_metadata.outputs.name }}" ;; esac; - echo "CARGO_TEST_OPTIONS=${CARGO_TEST_OPTIONS}" >> $GITHUB_OUTPUT - - - name: Run tests - shell: bash - run: | - if [[ ${{ matrix.job.os }} = windows-* ]]; then - powershell.exe -command "$BUILD_CMD test --locked --target=${{ matrix.job.target }} ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}}" - elif [[ ${{ matrix.job.os }} = macos-* ]]; then - # For macos universal binary we test using x86 since GitHub Actions do not yet support arm execution environment - $BUILD_CMD test --locked --target=x86_64-apple-darwin ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}} - else - $BUILD_CMD test --locked --target=${{ matrix.job.target }} ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}} - fi - - - name: Generate manpage - shell: bash - run: | - if [[ ${{ matrix.job.os }} = windows-* ]] - then - mkdir -p target/release/man - powershell.exe -command "$BUILD_CMD run --target=${{ matrix.job.target }} --bin marathon-cloud-mangen target\\release\\man" - elif [[ ${{ matrix.job.os }} = macos-* ]]; then - # For macos universal binary we test using x86 since GitHub Actions do not yet support arm execution environment - mkdir -p target/release/man - OUT_DIR=target/release/man/ $BUILD_CMD run --target=x86_64-apple-darwin --bin marathon-cloud-mangen - else - mkdir -p target/release/man - OUT_DIR=target/release/man/ $BUILD_CMD run --target=${{ matrix.job.target }} --bin marathon-cloud-mangen - fi - - - name: Generate completions - shell: bash - run: | - if [[ ${{ matrix.job.os }} = windows-* ]] - then - mkdir -p target/release/autocomplete - powershell.exe -command "$BUILD_CMD -q run --target=${{ matrix.job.target }} -- completions bash" > target/release/autocomplete/marathon-cloud.bash - powershell.exe -command "$BUILD_CMD -q run --target=${{ matrix.job.target }} -- completions fish" > target/release/autocomplete/marathon-cloud.fish - powershell.exe -command "$BUILD_CMD -q run --target=${{ matrix.job.target }} -- completions powershell" > target/release/autocomplete/_marathon-cloud.ps1 - powershell.exe -command "$BUILD_CMD -q run --target=${{ matrix.job.target }} -- completions zsh" > target/release/autocomplete/marathon-cloud.zsh - elif [[ ${{ matrix.job.os }} = macos-* ]]; then - # For macos universal binary we test using x86 since GitHub Actions do not yet support arm execution environment - mkdir -p target/release/autocomplete - $BUILD_CMD -q run --target=x86_64-apple-darwin -- completions bash > target/release/autocomplete/marathon-cloud.bash - $BUILD_CMD -q run --target=x86_64-apple-darwin -- completions fish > target/release/autocomplete/marathon-cloud.fish - $BUILD_CMD -q run --target=x86_64-apple-darwin -- completions powershell > target/release/autocomplete/_marathon-cloud.ps1 - $BUILD_CMD -q run --target=x86_64-apple-darwin -- completions zsh > target/release/autocomplete/marathon-cloud.zsh - else - mkdir -p target/release/autocomplete - $BUILD_CMD -q run --target=${{ matrix.job.target }} -- completions bash > target/release/autocomplete/marathon-cloud.bash - $BUILD_CMD -q run --target=${{ matrix.job.target }} -- completions fish > target/release/autocomplete/marathon-cloud.fish - $BUILD_CMD -q run --target=${{ matrix.job.target }} -- completions powershell > target/release/autocomplete/_marathon-cloud.ps1 - $BUILD_CMD -q run --target=${{ matrix.job.target }} -- completions zsh > target/release/autocomplete/marathon-cloud.zsh - fi - - - name: Create tarball - id: package - shell: bash - run: | - PKG_suffix=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_suffix=".zip" ;; esac; - if [[ ${{ matrix.job.os }} = macos-* ]]; then - PKG_BASENAME=${{ needs.crate_metadata.outputs.name }}-v${{ needs.crate_metadata.outputs.version }}-universal-apple-darwin - else - PKG_BASENAME=${{ needs.crate_metadata.outputs.name }}-v${{ needs.crate_metadata.outputs.version }}-${{ matrix.job.target }} - fi - PKG_NAME=${PKG_BASENAME}${PKG_suffix} - echo "PKG_NAME=${PKG_NAME}" >> $GITHUB_OUTPUT - - PKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/package" - ARCHIVE_DIR="${PKG_STAGING}/${PKG_BASENAME}/" - mkdir -p "${ARCHIVE_DIR}" - mkdir -p "${ARCHIVE_DIR}/autocomplete" - - # Binary - cp "${{ steps.bin.outputs.BIN_PATH }}" "$ARCHIVE_DIR" - - # README, LICENSE and CHANGELOG files - cp "README.md" "LICENSE" "$ARCHIVE_DIR" - - # Man page - cp 'target/release/man/marathon-cloud.1' "$ARCHIVE_DIR" - - # Autocompletion files - cp 'target/release/autocomplete/marathon-cloud.bash' "$ARCHIVE_DIR/autocomplete/${{ needs.crate_metadata.outputs.name }}.bash" - cp 'target/release/autocomplete/marathon-cloud.fish' "$ARCHIVE_DIR/autocomplete/${{ needs.crate_metadata.outputs.name }}.fish" - cp 'target/release/autocomplete/_marathon-cloud.ps1' "$ARCHIVE_DIR/autocomplete/_${{ needs.crate_metadata.outputs.name }}.ps1" - cp 'target/release/autocomplete/marathon-cloud.zsh' "$ARCHIVE_DIR/autocomplete/${{ needs.crate_metadata.outputs.name }}.zsh" - - # base compressed package - pushd "${PKG_STAGING}/" >/dev/null - case ${{ matrix.job.target }} in - *-pc-windows-*) 7z -y a "${PKG_NAME}" "${PKG_BASENAME}"/* | tail -2 ;; - *) tar czf "${PKG_NAME}" "${PKG_BASENAME}"/* ;; - esac; - popd >/dev/null - - # Let subsequent steps know where to find the compressed package - echo "PKG_PATH=${PKG_STAGING}/${PKG_NAME}" >> $GITHUB_OUTPUT - - - name: Create Debian package - id: debian-package - shell: bash - if: startsWith(matrix.job.os, 'ubuntu') - run: | - COPYRIGHT_YEARS="2023 - "$(date "+%Y") - DPKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/debian-package" - DPKG_DIR="${DPKG_STAGING}/dpkg" - mkdir -p "${DPKG_DIR}" - - DPKG_BASENAME=${{ needs.crate_metadata.outputs.name }} - DPKG_CONFLICTS=${{ needs.crate_metadata.outputs.name }}-musl - case ${{ matrix.job.target }} in *-musl) DPKG_BASENAME=${{ needs.crate_metadata.outputs.name }}-musl ; DPKG_CONFLICTS=${{ needs.crate_metadata.outputs.name }} ;; esac; - DPKG_VERSION=${{ needs.crate_metadata.outputs.version }} - DPKG_ARCH="${{ matrix.job.dpkg_arch }}" - DPKG_NAME="${DPKG_BASENAME}_v${DPKG_VERSION}_${DPKG_ARCH}.deb" - echo "DPKG_NAME=${DPKG_NAME}" >> $GITHUB_OUTPUT - - # Binary - install -Dm755 "${{ steps.bin.outputs.BIN_PATH }}" "${DPKG_DIR}/usr/bin/${{ steps.bin.outputs.BIN_NAME }}" - - # Man page - install -Dm644 'target/release/man/marathon-cloud.1' "${DPKG_DIR}/usr/share/man/man1/${{ needs.crate_metadata.outputs.name }}.1" - gzip -n --best "${DPKG_DIR}/usr/share/man/man1/${{ needs.crate_metadata.outputs.name }}.1" - - # Autocompletion files - install -Dm644 'target/release/autocomplete/marathon-cloud.bash' "${DPKG_DIR}/usr/share/bash-completion/completions/${{ needs.crate_metadata.outputs.name }}" - install -Dm644 'target/release/autocomplete/marathon-cloud.fish' "${DPKG_DIR}/usr/share/fish/vendor_completions.d/${{ needs.crate_metadata.outputs.name }}.fish" - install -Dm644 'target/release/autocomplete/marathon-cloud.zsh' "${DPKG_DIR}/usr/share/zsh/vendor-completions/_${{ needs.crate_metadata.outputs.name }}" - - # README and LICENSE - install -Dm644 "README.md" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/README.md" - install -Dm644 "LICENSE" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/LICENSE" - - cat > "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/copyright" < "${DPKG_DIR}/DEBIAN/control" <> $GITHUB_OUTPUT - - # build dpkg - fakeroot dpkg-deb --build "${DPKG_DIR}" "${DPKG_PATH}" - - - name: "Artifact upload: tarball" - uses: actions/upload-artifact@master - with: - name: ${{ steps.package.outputs.PKG_NAME }} - path: ${{ steps.package.outputs.PKG_PATH }} - - - name: "Artifact upload: Debian package" - uses: actions/upload-artifact@master - if: steps.debian-package.outputs.DPKG_NAME - with: - name: ${{ steps.debian-package.outputs.DPKG_NAME }} - path: ${{ steps.debian-package.outputs.DPKG_PATH }} - - - name: Publish archives and packages - uses: softprops/action-gh-release@v2 - if: steps.is-release.outputs.IS_RELEASE - with: - files: | - ${{ steps.package.outputs.PKG_PATH }} - ${{ steps.debian-package.outputs.DPKG_PATH }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Check for release + id: is-release + shell: bash + run: | + unset IS_RELEASE ; if [[ $GITHUB_REF =~ ^refs/tags/[0-9].* ]]; then IS_RELEASE='true' ; fi + echo "IS_RELEASE=${IS_RELEASE}" >> $GITHUB_OUTPUT + unset VERSION + VERSION=$(echo $GITHUB_REF | cut -d / -f 3) + echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT + + - name: Install prerequisites + shell: bash + run: | + case ${{ matrix.job.target }} in + arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;; + aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;; + esac + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.job.target }} + + - run: | + cargo install --version ${{ env.CARGO_EDIT_VERSION }} cargo-edit + cargo set-version ${{ steps.is-release.outputs.VERSION }} + if: steps.is-release.outputs.IS_RELEASE + + - name: Install cross + if: matrix.job.use-cross + uses: taiki-e/install-action@v2 + with: + tool: cross + + - name: Overwrite build command env variable + if: matrix.job.use-cross + shell: bash + run: echo "BUILD_CMD=cross" >> $GITHUB_ENV + + - name: Show version information (Rust, cargo, GCC) + shell: bash + run: | + gcc --version || true + rustup -V + rustup toolchain list + rustup default + cargo -V + rustc -V + + - name: Set binary name & path + id: bin + shell: bash + run: | + # Figure out suffix of binary + EXE_suffix="" + case ${{ matrix.job.target }} in + *-pc-windows-*) EXE_suffix=".exe" ;; + esac; + + # Setup paths + BIN_NAME="${{ needs.crate_metadata.outputs.name }}${EXE_suffix}" + # For macos we use universal binary + if [[ ${{ matrix.job.os }} = macos-* ]]; then + BIN_PATH="target/universal-apple-darwin/release/${BIN_NAME}" + else + BIN_PATH="target/${{ matrix.job.target }}/release/${BIN_NAME}" + fi + + # Let subsequent steps know where to find the binary + + echo "BIN_PATH=${BIN_PATH}" >> $GITHUB_OUTPUT + echo "BIN_NAME=${BIN_NAME}" >> $GITHUB_OUTPUT + + - name: Build + shell: bash + run: | + if [[ ${{ matrix.job.os }} = macos-* ]] + then + # For macos we build universal binary + for i in $(echo "${{ matrix.job.target}}" | sed "s/,/ /g") + do + $BUILD_CMD build --locked --release --target=$i + done + + BIN_INTEL_PATH="target/x86_64-apple-darwin/release/${{ steps.bin.outputs.BIN_NAME}}" + BIN_APPLE_PATH="target/aarch64-apple-darwin/release/${{ steps.bin.outputs.BIN_NAME}}" + + mkdir -p target/universal-apple-darwin/release + lipo -create -output target/universal-apple-darwin/release/${{ steps.bin.outputs.BIN_NAME}} ${BIN_INTEL_PATH} ${BIN_APPLE_PATH} + else + $BUILD_CMD build --locked --release --target=${{ matrix.job.target }} + fi + + - name: Set testing options + id: test-options + shell: bash + run: | + # test only library unit tests and binary for arm-type targets + unset CARGO_TEST_OPTIONS + unset CARGO_TEST_OPTIONS ; case ${{ matrix.job.target }} in arm-* | aarch64-*) CARGO_TEST_OPTIONS="--lib --bin ${{ needs.crate_metadata.outputs.name }}" ;; esac; + echo "CARGO_TEST_OPTIONS=${CARGO_TEST_OPTIONS}" >> $GITHUB_OUTPUT + + - name: Run tests + shell: bash + run: | + if [[ ${{ matrix.job.os }} = windows-* ]]; then + powershell.exe -command "$BUILD_CMD test --locked --target=${{ matrix.job.target }} ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}}" + elif [[ ${{ matrix.job.os }} = macos-* ]]; then + # For macos universal binary we test using x86 since GitHub Actions do not yet support arm execution environment + $BUILD_CMD test --locked --target=x86_64-apple-darwin ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}} + else + $BUILD_CMD test --locked --target=${{ matrix.job.target }} ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}} + fi + + - name: Generate manpage + shell: bash + run: | + if [[ ${{ matrix.job.os }} = windows-* ]] + then + mkdir -p target/release/man + powershell.exe -command "$BUILD_CMD run --target=${{ matrix.job.target }} --bin marathon-cloud-mangen target\\release\\man" + elif [[ ${{ matrix.job.os }} = macos-* ]]; then + # For macos universal binary we test using x86 since GitHub Actions do not yet support arm execution environment + mkdir -p target/release/man + OUT_DIR=target/release/man/ $BUILD_CMD run --target=x86_64-apple-darwin --bin marathon-cloud-mangen + else + mkdir -p target/release/man + OUT_DIR=target/release/man/ $BUILD_CMD run --target=${{ matrix.job.target }} --bin marathon-cloud-mangen + fi + + - name: Generate completions + shell: bash + run: | + if [[ ${{ matrix.job.os }} = windows-* ]] + then + mkdir -p target/release/autocomplete + powershell.exe -command "$BUILD_CMD -q run --target=${{ matrix.job.target }} -- completions bash" > target/release/autocomplete/marathon-cloud.bash + powershell.exe -command "$BUILD_CMD -q run --target=${{ matrix.job.target }} -- completions fish" > target/release/autocomplete/marathon-cloud.fish + powershell.exe -command "$BUILD_CMD -q run --target=${{ matrix.job.target }} -- completions powershell" > target/release/autocomplete/_marathon-cloud.ps1 + powershell.exe -command "$BUILD_CMD -q run --target=${{ matrix.job.target }} -- completions zsh" > target/release/autocomplete/marathon-cloud.zsh + elif [[ ${{ matrix.job.os }} = macos-* ]]; then + # For macos universal binary we test using x86 since GitHub Actions do not yet support arm execution environment + mkdir -p target/release/autocomplete + $BUILD_CMD -q run --target=x86_64-apple-darwin -- completions bash > target/release/autocomplete/marathon-cloud.bash + $BUILD_CMD -q run --target=x86_64-apple-darwin -- completions fish > target/release/autocomplete/marathon-cloud.fish + $BUILD_CMD -q run --target=x86_64-apple-darwin -- completions powershell > target/release/autocomplete/_marathon-cloud.ps1 + $BUILD_CMD -q run --target=x86_64-apple-darwin -- completions zsh > target/release/autocomplete/marathon-cloud.zsh + else + mkdir -p target/release/autocomplete + $BUILD_CMD -q run --target=${{ matrix.job.target }} -- completions bash > target/release/autocomplete/marathon-cloud.bash + $BUILD_CMD -q run --target=${{ matrix.job.target }} -- completions fish > target/release/autocomplete/marathon-cloud.fish + $BUILD_CMD -q run --target=${{ matrix.job.target }} -- completions powershell > target/release/autocomplete/_marathon-cloud.ps1 + $BUILD_CMD -q run --target=${{ matrix.job.target }} -- completions zsh > target/release/autocomplete/marathon-cloud.zsh + fi + + - name: Create tarball + id: package + shell: bash + run: | + PKG_suffix=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_suffix=".zip" ;; esac; + if [[ ${{ matrix.job.os }} = macos-* ]]; then + PKG_BASENAME=${{ needs.crate_metadata.outputs.name }}-v${{ needs.crate_metadata.outputs.version }}-universal-apple-darwin + else + PKG_BASENAME=${{ needs.crate_metadata.outputs.name }}-v${{ needs.crate_metadata.outputs.version }}-${{ matrix.job.target }} + fi + PKG_NAME=${PKG_BASENAME}${PKG_suffix} + echo "PKG_NAME=${PKG_NAME}" >> $GITHUB_OUTPUT + + PKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/package" + ARCHIVE_DIR="${PKG_STAGING}/${PKG_BASENAME}/" + mkdir -p "${ARCHIVE_DIR}" + mkdir -p "${ARCHIVE_DIR}/autocomplete" + + # Binary + cp "${{ steps.bin.outputs.BIN_PATH }}" "$ARCHIVE_DIR" + + # README, LICENSE and CHANGELOG files + cp "README.md" "LICENSE" "$ARCHIVE_DIR" + + # Man page + cp 'target/release/man/marathon-cloud.1' "$ARCHIVE_DIR" + + # Autocompletion files + cp 'target/release/autocomplete/marathon-cloud.bash' "$ARCHIVE_DIR/autocomplete/${{ needs.crate_metadata.outputs.name }}.bash" + cp 'target/release/autocomplete/marathon-cloud.fish' "$ARCHIVE_DIR/autocomplete/${{ needs.crate_metadata.outputs.name }}.fish" + cp 'target/release/autocomplete/_marathon-cloud.ps1' "$ARCHIVE_DIR/autocomplete/_${{ needs.crate_metadata.outputs.name }}.ps1" + cp 'target/release/autocomplete/marathon-cloud.zsh' "$ARCHIVE_DIR/autocomplete/${{ needs.crate_metadata.outputs.name }}.zsh" + + # base compressed package + pushd "${PKG_STAGING}/" >/dev/null + case ${{ matrix.job.target }} in + *-pc-windows-*) 7z -y a "${PKG_NAME}" "${PKG_BASENAME}"/* | tail -2 ;; + *) tar czf "${PKG_NAME}" "${PKG_BASENAME}"/* ;; + esac; + popd >/dev/null + + # Let subsequent steps know where to find the compressed package + echo "PKG_PATH=${PKG_STAGING}/${PKG_NAME}" >> $GITHUB_OUTPUT + + - name: Create Debian package + id: debian-package + shell: bash + if: startsWith(matrix.job.os, 'ubuntu') + run: | + COPYRIGHT_YEARS="2023 - "$(date "+%Y") + DPKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/debian-package" + DPKG_DIR="${DPKG_STAGING}/dpkg" + mkdir -p "${DPKG_DIR}" + + DPKG_BASENAME=${{ needs.crate_metadata.outputs.name }} + DPKG_CONFLICTS=${{ needs.crate_metadata.outputs.name }}-musl + case ${{ matrix.job.target }} in *-musl) DPKG_BASENAME=${{ needs.crate_metadata.outputs.name }}-musl ; DPKG_CONFLICTS=${{ needs.crate_metadata.outputs.name }} ;; esac; + DPKG_VERSION=${{ needs.crate_metadata.outputs.version }} + DPKG_ARCH="${{ matrix.job.dpkg_arch }}" + DPKG_NAME="${DPKG_BASENAME}_v${DPKG_VERSION}_${DPKG_ARCH}.deb" + echo "DPKG_NAME=${DPKG_NAME}" >> $GITHUB_OUTPUT + + # Binary + install -Dm755 "${{ steps.bin.outputs.BIN_PATH }}" "${DPKG_DIR}/usr/bin/${{ steps.bin.outputs.BIN_NAME }}" + + # Man page + install -Dm644 'target/release/man/marathon-cloud.1' "${DPKG_DIR}/usr/share/man/man1/${{ needs.crate_metadata.outputs.name }}.1" + gzip -n --best "${DPKG_DIR}/usr/share/man/man1/${{ needs.crate_metadata.outputs.name }}.1" + + # Autocompletion files + install -Dm644 'target/release/autocomplete/marathon-cloud.bash' "${DPKG_DIR}/usr/share/bash-completion/completions/${{ needs.crate_metadata.outputs.name }}" + install -Dm644 'target/release/autocomplete/marathon-cloud.fish' "${DPKG_DIR}/usr/share/fish/vendor_completions.d/${{ needs.crate_metadata.outputs.name }}.fish" + install -Dm644 'target/release/autocomplete/marathon-cloud.zsh' "${DPKG_DIR}/usr/share/zsh/vendor-completions/_${{ needs.crate_metadata.outputs.name }}" + + # README and LICENSE + install -Dm644 "README.md" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/README.md" + install -Dm644 "LICENSE" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/LICENSE" + + cat > "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/copyright" < "${DPKG_DIR}/DEBIAN/control" <> $GITHUB_OUTPUT + + # build dpkg + fakeroot dpkg-deb --build "${DPKG_DIR}" "${DPKG_PATH}" + + - name: "Artifact upload: tarball" + uses: actions/upload-artifact@master + with: + name: ${{ steps.package.outputs.PKG_NAME }} + path: ${{ steps.package.outputs.PKG_PATH }} + + - name: "Artifact upload: Debian package" + uses: actions/upload-artifact@master + if: steps.debian-package.outputs.DPKG_NAME + with: + name: ${{ steps.debian-package.outputs.DPKG_NAME }} + path: ${{ steps.debian-package.outputs.DPKG_PATH }} + + - name: Publish archives and packages + uses: softprops/action-gh-release@v2 + if: steps.is-release.outputs.IS_RELEASE + with: + files: | + ${{ steps.package.outputs.PKG_PATH }} + ${{ steps.debian-package.outputs.DPKG_PATH }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} homebrew: runs-on: ubuntu-latest needs: @@ -465,9 +504,9 @@ jobs: - uses: actions/checkout@v4 if: steps.is-release.outputs.IS_RELEASE with: - repository: 'Malinskiy/homebrew-tap' - ref: 'master' - path: 'homebrew-tap' + repository: "Malinskiy/homebrew-tap" + ref: "master" + path: "homebrew-tap" token: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} - uses: ruby/setup-ruby@v1 if: steps.is-release.outputs.IS_RELEASE @@ -522,7 +561,7 @@ jobs: output: checksums.txt patterns: | * - - name: Upload checksums + - name: Upload checksums uses: softprops/action-gh-release@v1 if: steps.is-release.outputs.IS_RELEASE env: