-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3bf645c
commit 70f43c0
Showing
10 changed files
with
1,545 additions
and
44 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
name: Cargo Build | ||
on: | ||
push: | ||
pull_request: | ||
release: | ||
types: [created] | ||
jobs: | ||
build: | ||
name: ${{ matrix.job.os }} (${{ matrix.job.target }}) | ||
runs-on: ${{ matrix.job.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
job: | ||
- { os: ubuntu-20.04, target: arm-unknown-linux-gnueabihf , use-cross: true } | ||
- { os: ubuntu-20.04, target: arm-unknown-linux-musleabihf, use-cross: true } | ||
- { os: ubuntu-20.04, target: aarch64-unknown-linux-gnu , use-cross: true } | ||
- { os: ubuntu-20.04, target: i686-unknown-linux-gnu , use-cross: true } | ||
- { os: ubuntu-20.04, target: i686-unknown-linux-musl , use-cross: true } | ||
- { os: ubuntu-20.04, target: x86_64-unknown-linux-gnu , use-cross: true } | ||
- { os: ubuntu-20.04, 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: 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 }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
.ccurl_rc | ||
|
||
target/ |
Oops, something went wrong.