Last active
March 30, 2020 14:48
-
-
Save Igosuki/7c2e1cca86c8eaf8ca91064e5bab541b to your computer and use it in GitHub Desktop.
Workflow for cargo
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
on: [push] | |
env: | |
BUILD_ENV: staging | |
RUN_CMD: 'docker run --rm -it --user rust -e RUSTFLAGS="-C target-cpu=skylake" -v "$HOME/.cargo/git":/home/rust/.cargo/git -v "$(pwd)/cargo-registry":/home/rust/.cargo/registry -v "$(pwd)/cargo-target":/home/rust/src/target -v "$(pwd)":/home/rust/src ekidd/rust-musl-builder:nightly-2019-12-19' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- uses: actions/cache@v1 | |
with: | |
path: ./cargo-registry | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.*') }} | |
restore-keys: | | |
${{ runner.os }}-cargo- | |
- uses: actions/cache@v1 | |
with: | |
path: ./cargo-target | |
key: ${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.*') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-target- | |
- uses: actions/cache@v1 | |
with: | |
path: ~/.cargo/git | |
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.*') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-target- | |
- name: Default Build command | |
if: github.ref != 'refs/heads/master' | |
run: | | |
alias rust-musl-builder-nightly=$RUN_CMD | |
rust-musl-builder-nightly cargo build | |
- name: Release build | |
if: github.ref == 'refs/heads/master' | |
run: | | |
alias rust-musl-builder-nightly=$RUN_CMD | |
rust-musl-builder-nightly cargo build --release | |
- name: Upload artefact | |
if: github.ref == 'refs/heads/master' | |
run: | | |
ARTIFACT="cargo-target/x86_64-unknown-linux-musl/release/binary" | |
GIT_SHA=$(git rev-parse --short HEAD) | |
echo "Upload artifact $slug" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment