-
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
27c3d27
commit cd28cc6
Showing
4 changed files
with
231 additions
and
29 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,228 @@ | ||
name: Build | ||
|
||
env: | ||
MIN_SUPPORTED_RUST_VERSION: "1.46.0" | ||
CICD_INTERMEDIATES_DIR: "_cicd-intermediates" | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
build: | ||
name: ${{ matrix.job.target }} (${{ matrix.job.os }}) | ||
runs-on: ${{ matrix.job.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
job: | ||
# Tier 1 | ||
- { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } | ||
# Need to find a way to install gcc | ||
# - { target: i686-pc-windows-gnu , os: windows-2019 } | ||
- { target: i686-pc-windows-msvc , os: windows-2019 } | ||
- { target: i686-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } | ||
- { target: x86_64-apple-darwin , os: macos-10.15 } | ||
- { target: x86_64-pc-windows-gnu , os: windows-2019 } | ||
- { target: x86_64-pc-windows-msvc , os: windows-2019 } | ||
- { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04 } | ||
# Tier 2 with Host Tools | ||
- { target: aarch64-apple-darwin , os: macos-11.0 } | ||
- { target: aarch64-pc-windows-msvc , os: windows-2019 } | ||
- { target: aarch64-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } | ||
- { target: arm-unknown-linux-gnueabi , os: ubuntu-20.04, use-cross: true } | ||
- { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04, use-cross: true } | ||
- { target: armv7-unknown-linux-gnueabihf , os: ubuntu-20.04, use-cross: true } | ||
- { target: mips-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } | ||
- { target: mips64-unknown-linux-gnuabi64 , os: ubuntu-20.04, use-cross: true } | ||
- { target: mips64el-unknown-linux-gnuabi64, os: ubuntu-20.04, use-cross: true } | ||
- { target: mipsel-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } | ||
- { target: powerpc-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } | ||
# powerpc64 unknown linux gnu doesn't work | ||
# - { target: powerpc64-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } | ||
- { target: powerpc64le-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } | ||
- { target: riscv64gc-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } | ||
- { target: s390x-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } | ||
# freebsd doesn't work | ||
# - { target: x86_64-unknown-freebsd , os: ubuntu-20.04, use-cross: true } | ||
# illumos doesn't work. | ||
# - { target: x86_64-unknown-illumos , os: ubuntu-20.04, use-cross: true } | ||
# - { target: arm-unknown-linux-musleabihf , os: ubuntu-20.04, use-cross: true } | ||
- { target: i686-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } | ||
- { target: x86_64-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } | ||
- { target: x86_64-unknown-netbsd , os: ubuntu-20.04, use-cross: true } | ||
# Tier 2 | ||
# - { target: aarch64-apple-ios , os: macos-11 } | ||
# - { target: aarch64-apple-ios-sim , os: macos-11 } | ||
# - { target: aarch64-fuchsia , os: ubuntu-20.04, use-cross: true } | ||
# - { target: aarch64-linux-android , os: ubuntu-20.04, use-cross: true } | ||
# - { target: aarch64-unknown-none-softfloat , os: ubuntu-20.04, use-cross: true } | ||
# - { target: aarch64-unknown-none , os: ubuntu-20.04, use-cross: true } | ||
# - { target: arm-linux-androideabi , os: ubuntu-20.04, use-cross: true } | ||
# - { target: arm-unknown-linux-musleabi , os: ubuntu-20.04, use-cross: true } | ||
# - { target: arm-unknown-linux-musleabihf , os: ubuntu-20.04, use-cross: true } | ||
# - { target: armebv7r-none-eabi , os: ubuntu-20.04, use-cross: true } | ||
# - { target: armebv7r-none-eabihf , os: ubuntu-20.04, use-cross: true } | ||
# - { target: armv5te-unknown-linux-gnueabi , os: ubuntu-20.04, use-cross: true } | ||
# - { target: armv5te-unknown-linux-musleabi , os: ubuntu-20.04, use-cross: true } | ||
# - { target: armv7-linux-androideabi , os: ubuntu-20.04, use-cross: true } | ||
# - { target: armv7-unknown-linux-gnueabi , os: ubuntu-20.04, use-cross: true } | ||
# - { target: armv7-unknown-linux-musleabi , os: ubuntu-20.04, use-cross: true } | ||
# - { target: armv7-unknown-linux-musleabihf , os: ubuntu-20.04, use-cross: true } | ||
# - { target: armv7a-none-eabi , os: ubuntu-20.04, use-cross: true } | ||
# - { target: armv7r-none-eabi , os: ubuntu-20.04, use-cross: true } | ||
# - { target: armv7r-none-eabihf , os: ubuntu-20.04, use-cross: true } | ||
# | ||
# - { target: x86_64-fortanix-unknown-sgx , os: ubuntu-20.04, use-cross: true } | ||
# - { target: x86_64-fuchsia , os: ubuntu-20.04, use-cross: true } | ||
# - { target: x86_64-linux-android , os: ubuntu-20.04, use-cross: true } | ||
# - { target: x86_64-pc-solaris , os: ubuntu-20.04, use-cross: true } | ||
# - { target: x86_64-unknown-linux-gnux32 , os: ubuntu-20.04, use-cross: true } | ||
# - { target: x86_64-unknown-redox , os: ubuntu-20.04, use-cross: true } | ||
# Tier 3 | ||
|
||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@v2 | ||
|
||
- 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=${{ github.event.repository.name }}" >> $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 | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
target: ${{ matrix.job.target }} | ||
override: true | ||
profile: minimal # minimal component installation (ie, no documentation) | ||
|
||
- 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.job.use-cross }} | ||
command: build | ||
args: --locked --release --target=${{ matrix.job.target }} | ||
|
||
- name: Strip debug information from executable | ||
id: strip | ||
shell: bash | ||
run: | | ||
# Figure out suffix of binary | ||
EXE_suffix="" | ||
case ${{ matrix.job.target }} in | ||
*-pc-windows-*) EXE_suffix=".exe" ;; | ||
esac; | ||
# Figure out what strip tool to use if any | ||
STRIP="strip" | ||
case ${{ matrix.job.target }} in | ||
arm-unknown-linux-*) STRIP="arm-linux-gnueabihf-strip" ;; | ||
aarch64-pc-*) STRIP="" ;; | ||
aarch64-unknown-*) STRIP="" ;; | ||
armv7-unknown-*) STRIP="" ;; | ||
mips-unknown-*) STRIP="" ;; | ||
mips64-unknown-*) STRIP="" ;; | ||
mips64el-unknown-*) STRIP="" ;; | ||
mipsel-unknown-*) STRIP="" ;; | ||
powerpc-unknown-*) STRIP="" ;; | ||
powerpc64-unknown-*) STRIP="" ;; | ||
powerpc64le-unknown-*) STRIP="" ;; | ||
riscv64gc-unknown-*) STRIP="" ;; | ||
s390x-unknown-*) STRIP="" ;; | ||
x86_64-unknown-freebsd) STRIP="" ;; | ||
x86_64-unknown-illumos) STRIP="" ;; | ||
esac; | ||
# Setup paths | ||
BIN_DIR="${{ env.CICD_INTERMEDIATES_DIR }}/stripped-release-bin/" | ||
mkdir -p "${BIN_DIR}" | ||
BIN_NAME="${{ env.PROJECT_NAME }}${EXE_suffix}" | ||
BIN_PATH="${BIN_DIR}/${BIN_NAME}" | ||
TRIPLET_NAME="${{ matrix.job.target }}" | ||
# Copy the release build binary to the result location | ||
cp "target/$TRIPLET_NAME/release/${BIN_NAME}" "${BIN_DIR}" | ||
# Also strip if possible | ||
if [ -n "${STRIP}" ]; then | ||
"${STRIP}" "${BIN_PATH}" | ||
fi | ||
# Let subsequent steps know where to find the (stripped) bin | ||
echo ::set-output name=BIN_PATH::${BIN_PATH} | ||
echo ::set-output name=BIN_NAME::${BIN_NAME} | ||
- name: Create tarball | ||
id: package | ||
shell: bash | ||
run: | | ||
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 ::set-output name=PKG_NAME::${PKG_NAME} | ||
PKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/package" | ||
ARCHIVE_DIR="${PKG_STAGING}/${PKG_BASENAME}/" | ||
mkdir -p "${ARCHIVE_DIR}" | ||
mkdir -p "${ARCHIVE_DIR}/autocomplete" | ||
# Binary | ||
cp "${{ steps.strip.outputs.BIN_PATH }}" "$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 ::set-output name=PKG_PATH::"${PKG_STAGING}/${PKG_NAME}" | ||
- 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 ::set-output name=IS_RELEASE::${IS_RELEASE} | ||
- 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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