|
| 1 | +name: Publish |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - 'v*' |
| 6 | + branches: |
| 7 | + - main |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + strategy: |
| 12 | + fail-fast: true |
| 13 | + matrix: |
| 14 | + build: |
| 15 | + - aarch64 |
| 16 | + - aarch64-musl |
| 17 | + # - i686 |
| 18 | + - amd64-musl |
| 19 | + - amd64 |
| 20 | + include: |
| 21 | + - build: aarch64 |
| 22 | + os: ubuntu-latest |
| 23 | + target: aarch64-unknown-linux-gnu |
| 24 | + use-cross: true |
| 25 | + features: "--no-default-features --features rustls" |
| 26 | + - build: aarch64-musl |
| 27 | + os: ubuntu-latest |
| 28 | + target: aarch64-unknown-linux-musl |
| 29 | + use-cross: true |
| 30 | + features: "--no-default-features --features rustls" |
| 31 | + # - build: i686 |
| 32 | + # os: ubuntu-latest |
| 33 | + # target: i686-unknown-linux-gnu |
| 34 | + # use-cross: true |
| 35 | + # features: "--no-default-features --features rustls" |
| 36 | + - build: amd64 |
| 37 | + os: ubuntu-latest |
| 38 | + target: x86_64-unknown-linux-gnu |
| 39 | + use-cross: false |
| 40 | + features: "" |
| 41 | + - build: amd64-musl |
| 42 | + os: ubuntu-latest |
| 43 | + target: x86_64-unknown-linux-musl |
| 44 | + use-cross: true |
| 45 | + features: "--no-default-features --features rustls" |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 |
| 48 | + with: |
| 49 | + fetch-depth: 0 |
| 50 | + |
| 51 | + - name: Install prerequisites |
| 52 | + shell: bash |
| 53 | + run: | |
| 54 | + sudo apt-get -y update |
| 55 | + case ${{ matrix.target }} in |
| 56 | + arm-unknown-linux-gnueabihf) sudo apt-get -y install gcc-arm-linux-gnueabihf ;; |
| 57 | + aarch64-unknown-linux-gnu) sudo apt-get -y install gcc-aarch64-linux-gnu ;; |
| 58 | + aarch64-unknown-linux-musl) sudo apt-get -y install gcc-aarch64-linux-gnu ;; |
| 59 | + esac |
| 60 | + sudo apt-get -y install libssl-dev openssl pkg-config |
| 61 | +
|
| 62 | + - name: Extract crate information |
| 63 | + shell: bash |
| 64 | + run: | |
| 65 | + echo "PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV |
| 66 | + echo "PROJECT_MAINTAINER=$(sed -n 's/^authors = \["\(.*\)"\]/\1/p' Cargo.toml)" >> $GITHUB_ENV |
| 67 | + echo "PROJECT_HOMEPAGE=$(sed -n 's/^homepage = "\(.*\)"/\1/p' Cargo.toml)" >> $GITHUB_ENV |
| 68 | + PROJECT_VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)" |
| 69 | + echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV |
| 70 | + if [[ $PROJECT_VERSION == *-pre ]]; then |
| 71 | + echo "VERSION_SUFFIX=nightly" >> $GITHUB_ENV |
| 72 | + else |
| 73 | + echo "VERSION_SUFFIX=$PROJECT_VERSION" >> $GITHUB_ENV |
| 74 | + fi |
| 75 | +
|
| 76 | + - name: Install Rust toolchain |
| 77 | + uses: actions-rs/toolchain@v1 |
| 78 | + with: |
| 79 | + toolchain: stable |
| 80 | + target: ${{ matrix.target }} |
| 81 | + override: true |
| 82 | + default: true |
| 83 | + |
| 84 | + - name: Show version information (Rust, cargo, GCC) |
| 85 | + shell: bash |
| 86 | + run: | |
| 87 | + gcc --version || true |
| 88 | + rustup -V |
| 89 | + rustup toolchain list |
| 90 | + rustup default |
| 91 | + cargo -V |
| 92 | + rustc -V |
| 93 | + - name: Build |
| 94 | + uses: actions-rs/cargo@v1 |
| 95 | + with: |
| 96 | + use-cross: ${{ matrix.use-cross }} |
| 97 | + command: build |
| 98 | + args: ${{ matrix.features }} --release --target=${{ matrix.target }} |
| 99 | + |
| 100 | + - name: Strip debug information from executable |
| 101 | + id: strip |
| 102 | + shell: bash |
| 103 | + run: | |
| 104 | + # Figure out what strip tool to use if any |
| 105 | + STRIP="strip" |
| 106 | + case ${{ matrix.target }} in |
| 107 | + arm-unknown-linux-gnueabihf) STRIP="arm-linux-gnueabihf-strip" ;; |
| 108 | + aarch64-unknown-linux-gnu) STRIP="aarch64-linux-gnu-strip" ;; |
| 109 | + aarch64-unknown-linux-musl) STRIP="aarch64-linux-gnu-strip" ;; |
| 110 | + *-pc-windows-msvc) STRIP="" ;; |
| 111 | + esac; |
| 112 | + # Setup paths |
| 113 | + BIN_DIR="_cicd/stripped-release-bin/" |
| 114 | + mkdir -p "${BIN_DIR}" |
| 115 | + BIN_NAME="${{ env.PROJECT_NAME }}" |
| 116 | + BIN_PATH="${BIN_DIR}/${BIN_NAME}_${{ matrix.build }}-${{ env.VERSION_SUFFIX }}" |
| 117 | + # Copy the release build binary to the result location |
| 118 | + cp "target/${{ matrix.target }}/release/${BIN_NAME}" "${BIN_PATH}" |
| 119 | + # Also strip if possible |
| 120 | + if [ -n "${STRIP}" ]; then |
| 121 | + "${STRIP}" "${BIN_PATH}" |
| 122 | + fi |
| 123 | + # Let subsequent steps know where to find the (stripped) bin |
| 124 | + echo "BIN_PATH=${BIN_PATH}" >> $GITHUB_OUTPUT |
| 125 | +
|
| 126 | + - name: Publish Release |
| 127 | + id: publish |
| 128 | + uses: softprops/action-gh-release@v1 |
| 129 | + if: startsWith(github.ref, 'refs/tags/') |
| 130 | + env: |
| 131 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 132 | + with: |
| 133 | + files: | |
| 134 | + ${{ steps.strip.outputs.BIN_PATH }} |
| 135 | +
|
| 136 | + - name: Publish Pre-Release |
| 137 | + id: publish-pre |
| 138 | + if: ${{ github.ref }} == 'refs/heads/main' |
| 139 | + env: |
| 140 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 141 | + uses: "ncipollo/release-action@v1" |
| 142 | + with: |
| 143 | + token: "${{ secrets.GITHUB_TOKEN }}" |
| 144 | + prerelease: true |
| 145 | + allowUpdates: true |
| 146 | + tag: "nightly" |
| 147 | + commit: "main" |
| 148 | + name: "renku-cli nightly" |
| 149 | + replacesArtifacts: true |
| 150 | + artifacts: ${{ steps.strip.outputs.BIN_PATH }} |
| 151 | + |
| 152 | + build-win: |
| 153 | + runs-on: windows-latest |
| 154 | + |
| 155 | + steps: |
| 156 | + - name: Checkout |
| 157 | + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 |
| 158 | + with: |
| 159 | + fetch-depth: 0 |
| 160 | + |
| 161 | + - name: Install Rust toolchain |
| 162 | + uses: actions-rs/toolchain@v1 |
| 163 | + with: |
| 164 | + toolchain: stable |
| 165 | + override: true |
| 166 | + default: true |
| 167 | + |
| 168 | + - name: Extract crate information |
| 169 | + shell: bash |
| 170 | + run: | |
| 171 | + echo "PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV |
| 172 | + PROJECT_VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)" |
| 173 | + echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV |
| 174 | + if [[ $PROJECT_VERSION == *-pre ]]; then |
| 175 | + echo "VERSION_SUFFIX=nightly" >> $GITHUB_ENV |
| 176 | + else |
| 177 | + echo "VERSION_SUFFIX=$PROJECT_VERSION" >> $GITHUB_ENV |
| 178 | + fi |
| 179 | +
|
| 180 | + - name: Build |
| 181 | + uses: actions-rs/cargo@v1 |
| 182 | + with: |
| 183 | + command: build |
| 184 | + args: ${{ matrix.features }} --release |
| 185 | + |
| 186 | + - name: Rename binary |
| 187 | + run: | |
| 188 | + mv target/release/${{ env.PROJECT_NAME }}.exe target/release/${{ env.PROJECT_NAME }}-${{ env.VERSION_SUFFIX }}.exe |
| 189 | +
|
| 190 | + - name: Publish Release |
| 191 | + id: publish |
| 192 | + uses: softprops/action-gh-release@v1 |
| 193 | + if: startsWith(github.ref, 'refs/tags/') |
| 194 | + env: |
| 195 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 196 | + with: |
| 197 | + files: | |
| 198 | + target/release/${{ env.PROJECT_NAME }}-${{ env.VERSION_SUFFIX }}.exe |
| 199 | +
|
| 200 | + - name: Publish Pre-Release |
| 201 | + id: publish-pre |
| 202 | + if: ${{ github.ref }} == 'refs/heads/main' |
| 203 | + env: |
| 204 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 205 | + uses: "ncipollo/release-action@v1" |
| 206 | + with: |
| 207 | + token: "${{ secrets.GITHUB_TOKEN }}" |
| 208 | + prerelease: true |
| 209 | + allowUpdates: true |
| 210 | + tag: "nightly" |
| 211 | + commit: "main" |
| 212 | + name: "renku-cli nightly" |
| 213 | + replacesArtifacts: true |
| 214 | + artifacts: target/release/${{ env.PROJECT_NAME }}-${{ env.VERSION_SUFFIX }}.exe |
| 215 | + |
| 216 | + build-mac: |
| 217 | + runs-on: macos-latest |
| 218 | + |
| 219 | + steps: |
| 220 | + - name: Checkout |
| 221 | + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 |
| 222 | + with: |
| 223 | + fetch-depth: 0 |
| 224 | + |
| 225 | + - name: Install Rust toolchain |
| 226 | + uses: actions-rs/toolchain@v1 |
| 227 | + with: |
| 228 | + toolchain: stable |
| 229 | + target: x86_64-apple-darwin |
| 230 | + override: true |
| 231 | + default: true |
| 232 | + |
| 233 | + - name: Extract crate information |
| 234 | + shell: bash |
| 235 | + run: | |
| 236 | + echo "PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV |
| 237 | + PROJECT_VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)" |
| 238 | + echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV |
| 239 | + if [[ $PROJECT_VERSION == *-pre ]]; then |
| 240 | + echo "VERSION_SUFFIX=nightly" >> $GITHUB_ENV |
| 241 | + else |
| 242 | + echo "VERSION_SUFFIX=$PROJECT_VERSION" >> $GITHUB_ENV |
| 243 | + fi |
| 244 | +
|
| 245 | + - name: Build |
| 246 | + uses: actions-rs/cargo@v1 |
| 247 | + with: |
| 248 | + command: build |
| 249 | + args: ${{ matrix.features }} --release |
| 250 | + |
| 251 | + - name: Rename and strip binary |
| 252 | + run: | |
| 253 | + strip target/release/${{ env.PROJECT_NAME }} |
| 254 | + mv target/release/${{ env.PROJECT_NAME }} target/release/${{ env.PROJECT_NAME }}_darwin-${{ env.VERSION_SUFFIX }} |
| 255 | +
|
| 256 | + - name: Publish Release |
| 257 | + id: publish |
| 258 | + uses: softprops/action-gh-release@v1 |
| 259 | + if: startsWith(github.ref, 'refs/tags/') |
| 260 | + env: |
| 261 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 262 | + with: |
| 263 | + prerelease: ${{ github.ref }} == "refs/heads/main" |
| 264 | + files: | |
| 265 | + target/release/${{ env.PROJECT_NAME }}_darwin-${{ env.VERSION_SUFFIX }} |
| 266 | +
|
| 267 | + - name: Publish Pre-Release |
| 268 | + id: publish-pre |
| 269 | + if: ${{ github.ref }} == 'refs/heads/main' |
| 270 | + env: |
| 271 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 272 | + uses: "ncipollo/release-action@v1" |
| 273 | + with: |
| 274 | + token: "${{ secrets.GITHUB_TOKEN }}" |
| 275 | + prerelease: true |
| 276 | + allowUpdates: true |
| 277 | + tag: "nightly" |
| 278 | + commit: "main" |
| 279 | + name: "renku-cli nightly" |
| 280 | + replacesArtifacts: true |
| 281 | + artifacts: target/release/${{ env.PROJECT_NAME }}_darwin-${{ env.VERSION_SUFFIX }} |
0 commit comments