Merge pull request #59 from SwissDataScienceCenter/rust-2024 #49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish | ||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*' | ||
| branches: | ||
| - main | ||
| concurrency: | ||
| group: publish-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: true | ||
| jobs: | ||
| publish-linux: | ||
| runs-on: ubuntu-latest | ||
| 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 | ||
| 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 | ||
| - 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 | ||
| - 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 | ||
| - name: Install Rust toolchain | ||
| uses: actions-rs/toolchain@v1 | ||
| with: | ||
| toolchain: stable | ||
| target: ${{ matrix.target }} | ||
| override: true | ||
| default: true | ||
| - 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: Build | ||
| uses: actions-rs/cargo@v1 | ||
| with: | ||
| use-cross: ${{ matrix.use-cross }} | ||
| command: build | ||
| args: ${{ matrix.features }} --release --target=${{ matrix.target }} | ||
| - name: Strip debug information from executable | ||
| id: strip | ||
| shell: bash | ||
| run: | | ||
| # Figure out what strip tool to use if any | ||
| STRIP="strip" | ||
| case ${{ matrix.target }} in | ||
| arm-unknown-linux-gnueabihf) STRIP="arm-linux-gnueabihf-strip" ;; | ||
| aarch64-unknown-linux-gnu) STRIP="aarch64-linux-gnu-strip" ;; | ||
| aarch64-unknown-linux-musl) STRIP="aarch64-linux-gnu-strip" ;; | ||
| *-pc-windows-msvc) STRIP="" ;; | ||
| esac; | ||
| # Setup paths | ||
| BIN_DIR="_cicd/stripped-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}" | ||
| # Also strip if possible | ||
| if [ -n "${STRIP}" ]; then | ||
| "${STRIP}" "${BIN_PATH}" | ||
| fi | ||
| # Let subsequent steps know where to find the (stripped) 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.strip.outputs.BIN_PATH }} | ||
| - name: Publish Pre-Release | ||
| id: publish-pre | ||
| if: ${{ github.ref }} == 'refs/heads/main' | ||
|
Check warning on line 137 in .github/workflows/publish.yml
|
||
| 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.strip.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 | ||
| 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 | ||
| 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 | ||
| 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' | ||
|
Check warning on line 225 in .github/workflows/publish.yml
|
||
| 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 | ||
| 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: Build | ||
| uses: actions-rs/cargo@v1 | ||
| 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 | ||
| 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' | ||
|
Check warning on line 289 in .github/workflows/publish.yml
|
||
| 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 | ||