From 99096396df95e37e9bd926a73b0c7423337f8a92 Mon Sep 17 00:00:00 2001 From: Ralf Grubenmann Date: Wed, 11 Mar 2026 11:14:00 +0100 Subject: [PATCH 1/3] update release CI to match self_update and simplify yaml --- .github/workflows/publish.yml | 336 +++++++++------------------------- Cargo.lock | 2 +- Cargo.toml | 6 +- build.rs | 4 + 4 files changed, 89 insertions(+), 259 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7227af0..763ca82 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,85 +1,68 @@ name: Publish on: push: + branches: + - "main" tags: - "v*" - branches: - - main - -concurrency: - group: publish-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true + workflow_dispatch: +env: + GITHUB_TOKEN: ${{ github.token }} + RUST_BACKTRACE: 1 jobs: - publish-linux: - runs-on: ubuntu-latest + release: + name: Release - ${{ matrix.platform.os_name }} + env: + RNK_RELEASE_VERSION: ${{ github.event.release.tag_name }} strategy: - fail-fast: true matrix: - build: - - aarch64 - - aarch64-musl - - amd64-musl - - amd64 - include: - - build: aarch64 - os: ubuntu-latest - target: aarch64-unknown-linux-gnu - use-cross: true - features: "--no-default-features --features rustls" - - build: aarch64-musl - os: ubuntu-latest - target: aarch64-unknown-linux-musl - use-cross: true - features: "--no-default-features --features rustls" - - build: amd64 - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - use-cross: false - features: "" - - build: amd64-musl + platform: + - os_name: Linux-x86_64 os: ubuntu-latest target: x86_64-unknown-linux-musl - use-cross: true - features: "--no-default-features --features rustls" - steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 - with: - fetch-depth: 0 + bin: rnk + name: rnk-x86_64-unknown-linux-musl-${{RNK_RELEASE_VERSION}}.tar.gz + cargo_command: cargo - - name: Install prerequisites - shell: bash - run: | - sudo apt-get -y update - case ${{ matrix.target }} in - arm-unknown-linux-gnueabihf) sudo apt-get -y install gcc-arm-linux-gnueabihf ;; - aarch64-unknown-linux-gnu) sudo apt-get -y install gcc-aarch64-linux-gnu ;; - aarch64-unknown-linux-musl) sudo apt-get -y install gcc-aarch64-linux-gnu ;; - esac - sudo apt-get -y install libssl-dev openssl pkg-config + - os_name: Linux-aarch64 + os: ubuntu-24.04-arm + target: aarch64-unknown-linux-musl + bin: rnk + name: rnk-aarch64-unknown-linux-musl-${{RNK_RELEASE_VERSION}}.tar.gz + cargo_command: cargo + + - os_name: Windows-x86_64 + os: windows-latest + target: x86_64-pc-windows-msvc + bin: rnk.exe + name: rnk-x86_64-pc-windows-msvc-${{RNK_RELEASE_VERSION}}.zip + cargo_command: cargo + + - os_name: macOS-x86_64 + os: macOS-latest + target: x86_64-apple-darwin + bin: rnk + name: rnk-x86_64-apple-darwin-${{RNK_RELEASE_VERSION}}.tar.gz + cargo_command: cargo - - name: Extract crate information - shell: bash - run: | - echo "PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV - echo "PROJECT_MAINTAINER=$(sed -n 's/^authors = \["\(.*\)"\]/\1/p' Cargo.toml)" >> $GITHUB_ENV - echo "PROJECT_HOMEPAGE=$(sed -n 's/^homepage = "\(.*\)"/\1/p' Cargo.toml)" >> $GITHUB_ENV - PROJECT_VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)" - echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV - if [[ $PROJECT_VERSION == *-pre ]]; then - echo "VERSION_SUFFIX=nightly" >> $GITHUB_ENV - else - echo "VERSION_SUFFIX=$PROJECT_VERSION" >> $GITHUB_ENV - fi + - os_name: macOS-aarch64 + os: macOS-latest + target: aarch64-apple-darwin + bin: rnk + name: rnk-aarch64-apple-darwin-${{RNK_RELEASE_VERSION}}.tar.gz + cargo_command: cargo - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 + runs-on: ${{ matrix.platform.os }} + steps: + - name: Checkout + uses: actions/checkout@v5 + - name: Strip version leading v + run: echo "RNK_RELEASE_VERSION=${RNK_RELEASE_VERSION##v}" >> $GITHUB_ENV + - name: Install toolchain + uses: dtolnay/rust-toolchain@stable with: - toolchain: stable - target: ${{ matrix.target }} - override: true - default: true - + targets: ${{ matrix.platform.target }} - name: Show version information (Rust, cargo, GCC) shell: bash run: | @@ -89,201 +72,46 @@ jobs: rustup default cargo -V rustc -V - - name: Build - uses: actions-rs/cargo@v1 - with: - use-cross: ${{ matrix.use-cross }} - command: build - args: ${{ matrix.features }} --release --target=${{ matrix.target }} - - - name: set bin path - id: bin-path - shell: bash - run: | - # Setup paths - BIN_DIR="_cicd/release-bin/" - mkdir -p "${BIN_DIR}" - BIN_NAME="${{ env.PROJECT_NAME }}" - BIN_PATH="${BIN_DIR}/${BIN_NAME}_${{ matrix.build }}-${{ env.VERSION_SUFFIX }}" - # Copy the release build binary to the result location - cp "target/${{ matrix.target }}/release/${BIN_NAME}" "${BIN_PATH}" - # Let subsequent steps know where to find the bin - echo "BIN_PATH=${BIN_PATH}" >> $GITHUB_OUTPUT - - - name: Publish Release - id: publish - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - files: | - ${{ steps.bin-path.outputs.BIN_PATH }} - - - name: Publish Pre-Release - id: publish-pre - if: ${{ github.ref }} == 'refs/heads/main' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: "ncipollo/release-action@v1" - with: - token: "${{ secrets.GITHUB_TOKEN }}" - prerelease: true - allowUpdates: true - tag: "nightly" - commit: "main" - name: "renku-cli nightly" - replacesArtifacts: true - artifacts: ${{ steps.bin-path.outputs.BIN_PATH }} - - publish-mac: - runs-on: macos-latest - - strategy: - fail-fast: true - matrix: - build: - - aarch64 - - amd64 - include: - - build: amd64 - target: x86_64-apple-darwin - use-cross: true - features: "" - - build: aarch64 - target: aarch64-apple-darwin - use-cross: false - features: "" - steps: - - name: Checkout - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 + - name: Rust cache + uses: Swatinem/rust-cache@v2 with: - fetch-depth: 0 - - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - target: ${{ matrix.target }} - override: true - default: true - - - name: Extract crate information + prefix-key: "v0-rust" + cache-workspace-crates: "true" + - name: Install build dependencies on Linux + run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools openssl libssl-dev + if: contains(matrix.platform.os, 'ubuntu') + - name: Build binary (*nix) shell: bash run: | - echo "PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV - PROJECT_VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)" - echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV - if [[ $PROJECT_VERSION == *-pre ]]; then - echo "VERSION_SUFFIX=nightly" >> $GITHUB_ENV - else - echo "VERSION_SUFFIX=$PROJECT_VERSION" >> $GITHUB_ENV - fi - - - name: Add build env parameters - shell: bash - run: | - echo "SDKROOT=$(xcrun --show-sdk-path)" >> $GITHUB_ENV - echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun --show-sdk-platform-version)" >> $GITHUB_ENV - - - name: Build - uses: actions-rs/cargo@v1 - with: - use-cross: ${{ matrix.use-cross }} - command: build - args: ${{ matrix.features }} --release --target=${{ matrix.target }} - - - name: Rename binary + ${{ matrix.platform.cargo_command }} build --locked --release --target ${{ matrix.platform.target }} + if: ${{ !contains(matrix.platform.os, 'windows') }} + - name: Build binary (Windows) + # We have to use the platform's native shell. If we use bash on + # Windows then OpenSSL complains that the Perl it finds doesn't use + # the platform's native paths and refuses to build. + shell: powershell run: | - mv target/${{ matrix.target }}/release/${{ env.PROJECT_NAME }} target/release/${{ env.PROJECT_NAME }}_darwin-${{ matrix.build }}-${{ env.VERSION_SUFFIX }} - - - name: Publish Release - id: publish - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - prerelease: ${{ github.ref }} == "refs/heads/main" - files: | - target/release/${{ env.PROJECT_NAME }}_darwin-${{ matrix.build }}-${{ env.VERSION_SUFFIX }} - - - name: Publish Pre-Release - id: publish-pre - if: ${{ github.ref }} == 'refs/heads/main' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: "ncipollo/release-action@v1" - with: - token: "${{ secrets.GITHUB_TOKEN }}" - prerelease: true - allowUpdates: true - tag: "nightly" - commit: "main" - name: "renku-cli nightly" - replacesArtifacts: true - artifacts: target/release/${{ env.PROJECT_NAME }}_darwin-${{ matrix.build }}-${{ env.VERSION_SUFFIX }} - - publish-win: - runs-on: windows-latest - - steps: - - name: Checkout - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 - with: - fetch-depth: 0 - - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - default: true - - - name: Extract crate information + & ${{ matrix.platform.cargo_command }} build --locked --release --target ${{ matrix.platform.target }} + if: contains(matrix.platform.os, 'windows') + - name: Package as archive shell: bash run: | - echo "PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV - PROJECT_VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)" - echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV - if [[ $PROJECT_VERSION == *-pre ]]; then - echo "VERSION_SUFFIX=nightly" >> $GITHUB_ENV + cd target/${{ matrix.platform.target }}/release + if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then + 7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} else - echo "VERSION_SUFFIX=$PROJECT_VERSION" >> $GITHUB_ENV + tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} fi - - - name: Build - uses: actions-rs/cargo@v1 + cd - + - uses: actions/upload-artifact@v4 with: - command: build - args: ${{ matrix.features }} --release - - - name: Rename binary - run: | - mv target/release/${{ env.PROJECT_NAME }}.exe target/release/${{ env.PROJECT_NAME }}-${{ env.VERSION_SUFFIX }}.exe - - - name: Publish Release - id: publish + name: "${{matrix.platform.os_name}}" + path: | + rnk*.gz + rnk*.zip + - name: Publish GitHub release uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - files: | - target/release/${{ env.PROJECT_NAME }}-${{ env.VERSION_SUFFIX }}.exe - - - name: Publish Pre-Release - id: publish-pre - if: ${{ github.ref }} == 'refs/heads/main' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: "ncipollo/release-action@v1" with: - token: "${{ secrets.GITHUB_TOKEN }}" - prerelease: true - allowUpdates: true - tag: "nightly" - commit: "main" - name: "renku-cli nightly" - replacesArtifacts: true - artifacts: target/release/${{ env.PROJECT_NAME }}-${{ env.VERSION_SUFFIX }}.exe + draft: true + files: "rnk*" + if: startsWith( github.ref, 'refs/tags/v' ) diff --git a/Cargo.lock b/Cargo.lock index 00c4a39..1fcfb2b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2669,7 +2669,7 @@ dependencies = [ [[package]] name = "rnk" -version = "0.1.0-nightly" +version = "0.0.0" dependencies = [ "assert_cmd", "better-panic", diff --git a/Cargo.toml b/Cargo.toml index 7300f40..f04cc39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,6 @@ name = "rnk" description = "A command line interface to the Renku platform" homepage = "https://renkulab.io/" -version = "0.1.0-nightly" edition = "2024" license = "Apache-2.0" repository = "https://github.com/SwissDatascienceCenter/renku-cli" @@ -16,7 +15,7 @@ build = "build.rs" [dependencies] clap = { version = "4.5.13", features = ["derive", "wrap_help"] } clap_complete = { version = "4.5.61", features = ["unstable-dynamic"] } -console = {version = "0.15.11"} +console = { version = "0.15.11" } env_logger = { version = "0.11.5" } log = { version = "0.4.22" } openssl = { version = "0.10.75", optional = true } @@ -76,7 +75,6 @@ vergen = { version = "8.3.2", features = [ ] } [profile.release] -strip ="debuginfo" +strip = "debuginfo" opt-level = "z" lto = true - diff --git a/build.rs b/build.rs index f4ba71b..13d1f15 100644 --- a/build.rs +++ b/build.rs @@ -1,6 +1,10 @@ use vergen::EmitBuilder; pub fn main() { + if let Ok(val) = std::env::var("RNK_RELEASE_VERSION") { + println!("cargo:rustc-env=CARGO_PKG_VERSION={}", val); + } + println!("cargo:rerun-if-env-changed=RNK_RELEASE_VERSION"); EmitBuilder::builder() .all_build() .all_git() From 43b62031a4e25db7d401fe2557d8956deb65dfff Mon Sep 17 00:00:00 2001 From: Ralf Grubenmann Date: Thu, 12 Mar 2026 13:30:15 +0100 Subject: [PATCH 2/3] add back concurrency option --- .github/workflows/publish.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 763ca82..12d1ba8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,7 +6,9 @@ on: tags: - "v*" workflow_dispatch: - +concurrency: + group: publish-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true env: GITHUB_TOKEN: ${{ github.token }} RUST_BACKTRACE: 1 @@ -14,7 +16,7 @@ jobs: release: name: Release - ${{ matrix.platform.os_name }} env: - RNK_RELEASE_VERSION: ${{ github.event.release.tag_name }} + RNK_RELEASE_VERSION: ${{ github.ref_name }} strategy: matrix: platform: @@ -110,7 +112,7 @@ jobs: rnk*.gz rnk*.zip - name: Publish GitHub release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: draft: true files: "rnk*" From 7df7db95ca186e40e9f1ee2acaabddb0db6e96e5 Mon Sep 17 00:00:00 2001 From: Ralf Grubenmann Date: Fri, 13 Mar 2026 15:10:19 +0100 Subject: [PATCH 3/3] adjust install script to deal with new tarfiles --- docs/install.md | 3 +- install.sh | 87 ++++++++++++++----------------------------------- 2 files changed, 27 insertions(+), 63 deletions(-) diff --git a/docs/install.md b/docs/install.md index ed6d243..120da7d 100644 --- a/docs/install.md +++ b/docs/install.md @@ -108,7 +108,8 @@ existing tag. The convenient way is to use the `installer.sh` script that is provided from this repository. It will download the correct binary from the release page and put it in `/usr/local/bin` on your system. -It requires `curl` and `sudo` to copy the binary to `/usr/local/bin`. +It requires `curl`, `jq` and finally `sudo` to copy the binary to +`/usr/local/bin`. ``` curl -sfSL https://raw.githubusercontent.com/SwissDataScienceCenter/renku-cli/main/install.sh | bash diff --git a/install.sh b/install.sh index c0217ce..f3f92ea 100755 --- a/install.sh +++ b/install.sh @@ -6,12 +6,9 @@ os=$(uname) arch=$(uname -m) dist=$(uname -o) api_url_prefix="${API_URL_PREFIX:-https://api.github.com/repos/SwissDataScienceCenter/renku-cli/releases}" -dl_url_prefix="${DL_URL_PREFIX:-https://github.com/SwissDataScienceCenter/renku-cli/releases}" -binary_name="${BINARY_NAME:-rnk}" version="" check_latest=0 verbosity=${VERBOSITY:-0} -jq="" tdir="." target="/usr/local/bin" os_id="" @@ -47,15 +44,6 @@ assert_exec() { fi } -curl_silent() { - if [ "$verbosity" -eq 0 ]; then - curl -sSL -o /dev/null --stderr /dev/null --fail "$@" - else - debug "curl -sSL --fail $@" - curl -sSL -o /dev/null --fail "$@" - fi -} - print_help() { debug "Install script for renku-cli for macos and linux" debug @@ -68,34 +56,19 @@ print_help() { debug " Install the given version instead of latest" } -find_latest_release_name() { - if [ -n "$version" ]; then - echo "$version" - else - # get latest release - local latest_response=$(curl -sSL "$api_url_prefix/latest") - if [[ -z "$latest_response" ]] || [[ "$latest_response" =~ .*404.* ]]; then - debug_v "No latest release. Use nightly." - echo "nightly" - else - debug_v "Latest release response: $latest_response" - if [ -z "$jq" ]; then - echo $latest_response | tr ',' '\n' | grep "tag_name" | cut -d':' -f2 | tr -d '[:space:]' - else - echo $latest_response | jq -r '.tag_name' - fi - fi - fi -} +find_latest_release() { + # get latest release + local latest_response=$(curl -sSL "$api_url_prefix/latest") + local version=$(echo $latest_response | jq -r '.tag_name') + local version_num="${version:1}" -find_binary_name() { - local v=$(echo $version | tr -d 'v') local suffix="" case "$os" in Linux) + suffix="unknown-linux-musl" ;; Darwin) - suffix="darwin-" + suffix="apple-darwin" ;; *) debug "Unknown os: $os" @@ -104,32 +77,27 @@ find_binary_name() { case "$arch" in x86_64) - suffix="${suffix}amd64" + suffix="x86_64-${suffix}" ;; aarch64) - suffix="${suffix}aarch64" + suffix="aarch64-${suffix}" ;; arm64) - suffix="${suffix}aarch64" + suffix="aarch64-${suffix}" ;; *) debug "Unknown architecture: $arch" exit 1 esac - if [ "$os_id" == "alpine" ]; then - suffix="${suffix}-musl" - fi - if [ "$v" == "nightly" ]; then - debug_v "Obtain correct version for nightly" - v=$(curl -sSL --fail "https://raw.githubusercontent.com/SwissDataScienceCenter/renku-cli/main/Cargo.toml" | grep "^version" | cut -d'=' -f2 | tr -d '[:space:]' | tr -d '"') - suffix="${suffix}-$v" - else - suffix="${suffix}-$v" + local name_prefix="rnk-${suffix}-${version_num}" + local url=$(echo $latest_response | jq -r ".assets[]|select(.name | startswith(\"$name_prefix\"))|.browser_download_url") + if [ -z "$url" ]; then + echo "No download url could be found for $name_prefix." + exit 1 fi - - echo "rnk_${suffix}" + echo $version_num $url } while getopts "ht:cv" arg; do @@ -151,13 +119,6 @@ while getopts "ht:cv" arg; do esac done -## check for jq otherwise use grep -if ! type -P rjq >/dev/null; then - debug_v "jq is not installed, use grep instead" -else - jq="jq" -fi - # The aarch64 executables won't work on Android if [ "$dist" == "Android" ]; then debug "Sorry, Android is not yet supported." @@ -166,6 +127,8 @@ fi ## check for curl assert_exec "curl" +## check for jq +assert_exec jq ## check for cut, grep (should be available) assert_exec "cut" assert_exec "grep" @@ -176,7 +139,7 @@ fi if [ $check_latest -eq 1 ]; then debug_v "Check for latest version only" - find_latest_release_name + find_latest_release exit 0 else # Check for nixos @@ -189,17 +152,17 @@ else ## check for sudo first assert_exec "sudo" - version=$(find_latest_release_name) - binary=$(find_binary_name) - url="$dl_url_prefix/download/$version/$binary" - debug "Getting renku-cli $version..." + read version url < <(find_latest_release) + debug "Getting renku-cli $version ..." debug_v "from: $url" - curl -# -sSL --fail -o "$tdir/rnk" "$url" + curl -# -sSL --fail -o "$tdir/rnk.tar.gz" "$url" + tar -xzf "$tdir/rnk.tar.gz" -C "$tdir" + chmod 755 "$tdir/rnk" debug "Installing to $target" sudo mkdir -p "$target" - sudo cp "$tdir/rnk" "$target/$binary_name" + sudo cp "$tdir/rnk" "$target/rnk" debug "Done." fi fi