1.1.1 #16
Workflow file for this run
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: Cargo Build | |
| on: | |
| push: | |
| pull_request: | |
| release: | |
| types: [created] | |
| permissions: | |
| id-token: write | |
| contents: write | |
| attestations: write | |
| jobs: | |
| build: | |
| name: ${{ matrix.job.os }} (${{ matrix.job.target }}) | |
| runs-on: ${{ matrix.job.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| job: | |
| - { os: ubuntu-latest, target: arm-unknown-linux-gnueabihf , use-cross: true } | |
| - { os: ubuntu-latest, target: arm-unknown-linux-musleabihf, use-cross: true } | |
| - { os: ubuntu-latest, target: aarch64-unknown-linux-gnu , use-cross: true } | |
| - { os: ubuntu-latest, target: i686-unknown-linux-gnu , use-cross: true } | |
| - { os: ubuntu-latest, target: i686-unknown-linux-musl , use-cross: true } | |
| - { os: ubuntu-latest, target: x86_64-unknown-linux-gnu , use-cross: true } | |
| - { os: ubuntu-latest, target: x86_64-unknown-linux-musl , use-cross: true } | |
| - { os: macos-latest, target: x86_64-apple-darwin } | |
| - { os: macos-latest, target: aarch64-apple-darwin } | |
| steps: | |
| - name: Checkout source code | |
| uses: actions/checkout@v3 | |
| - 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: Extract crate information | |
| shell: bash | |
| run: | | |
| echo "PROJECT_NAME=ccurl" >> $GITHUB_ENV | |
| echo "PROJECT_VERSION=$(sed -n 's/^version = "\(.*\)"/\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 | |
| - name: Install Rust toolchain | |
| run: | | |
| rustup set profile minimal | |
| rustup toolchain install stable | |
| rustup override set stable | |
| rustup target add ${{ matrix.job.target }} | |
| - 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 cargo cmd | |
| shell: bash | |
| run: echo "CARGO_CMD=cargo" >> $GITHUB_ENV | |
| - name: Set cargo cmd to cross | |
| shell: bash | |
| if: ${{ matrix.job.use-cross == true }} | |
| run: echo "CARGO_CMD=cross" >> $GITHUB_ENV | |
| - name: Rust cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ matrix.job.os }}-${{ matrix.job.target }} | |
| - name: Install cross | |
| if: ${{ matrix.job.use-cross == true }} | |
| run: cargo install cross | |
| - name: Build | |
| run: ${{ env.CARGO_CMD }} build --locked --release --target=${{ matrix.job.target }} | |
| - name: Create tarball | |
| id: package | |
| shell: bash | |
| run: | | |
| PKG_STAGING="$(pwd)/package" | |
| PKG_suffix=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_suffix=".zip" ;; esac; | |
| PKG_BASENAME=${PROJECT_NAME}-v${PROJECT_VERSION}-${{ matrix.job.target }} | |
| PKG_NAME=${PKG_BASENAME}${PKG_suffix} | |
| echo "PKG_NAME=${PKG_NAME}" >> $GITHUB_OUTPUT | |
| ARCHIVE_DIR="${PKG_STAGING}/${PKG_BASENAME}/" | |
| mkdir -p "${ARCHIVE_DIR}" | |
| # Binary | |
| cp "target/${{ matrix.job.target }}/release/${BIN_NAME}/ccurl" "$ARCHIVE_DIR" | |
| # 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: "Artifact upload: tarball" | |
| uses: actions/upload-artifact@master | |
| with: | |
| name: ${{ steps.package.outputs.PKG_NAME }} | |
| path: ${{ steps.package.outputs.PKG_PATH }} | |
| - name: Check for release | |
| id: is-release | |
| shell: bash | |
| run: | | |
| unset IS_RELEASE ; if [[ $GITHUB_REF =~ ^refs/tags/v[0-9].* ]]; then IS_RELEASE='true' ; fi | |
| echo "IS_RELEASE=${IS_RELEASE}" >> $GITHUB_OUTPUT | |
| - name: Attest build provenance | |
| uses: actions/attest-build-provenance@v3 | |
| if: steps.is-release.outputs.IS_RELEASE | |
| with: | |
| subject-path: ${{ steps.package.outputs.PKG_PATH }} | |
| - name: Publish archives and packages | |
| uses: softprops/action-gh-release@v1 | |
| if: steps.is-release.outputs.IS_RELEASE | |
| with: | |
| files: | | |
| ${{ steps.package.outputs.PKG_PATH }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |