name: Test
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
unix:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
rust: [stable]
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}
- uses: actions/checkout@v2
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Determine Target Env
run: |
eval $(rustc --print cfg | grep target_)
echo "::set-env name=target_triple::${target_arch:-unknown}-${target_vendor:-unknown}-${target_os:-unknown}${target_env:+-}${target_env:-}"
- name: Backage binary distributions
run: |
tar -czf target/k8s-gcr-auth-helper-${{ env.target_triple }}.tar.gz -C target/debug k8s-gcr-auth-helper
- name: Upload build distribution
uses: actions/upload-artifact@v1
with:
name: k8s-gcr-auth-helper-${{ env.target_triple }}.tar.gz
path: target/k8s-gcr-auth-helper-${{ env.target_triple }}.tar.gz
windows:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
rust: [stable]
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}
- uses: actions/checkout@v2
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Prep for installer build
run: cargo install cargo-wix
- name: Build
run: |
cargo build --verbose --no-default-features --features rustls-tls
cargo wix --no-build --dbg-build --nocapture -i ((cargo pkgid) -replace "^.*#","" -replace "([^0-9.].*)?$","")
(cargo pkgid) -replace "^.*#","" -replace "([^0-9.].*)?$","" -replace "^","::set-env name=BUILD_VERSION::"
- name: Run tests
run: cargo test --verbose --no-default-features --features rustls-tls
- name: Upload build artifact
uses: actions/upload-artifact@v1
with:
name: k8s-gcr-auth-helper-x86_64-pc-windows-msvc
path: target/debug/k8s-gcr-auth-helper.exe
- name: Upload build artifact
uses: actions/upload-artifact@v1
with:
name: k8s-gcr-auth-helper-x86_64-pc-windows-msvc-msi
path: target/wix/k8s-gcr-auth-helper-${{ env.BUILD_VERSION }}-x86_64.msi
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Docker build
run: |
mkdir -p target
docker build --tag k8s-gcr-auth-helper:build --target build .
docker build --tag k8s-gcr-auth-helper:latest .
ID=$(docker run -d k8s-gcr-auth-helper:build cat)
docker cp $ID:/home/rust/.cargo/bin/k8s-gcr-auth-helper ./target/
docker rm --force $ID
tar -czf target/k8s-gcr-auth-helper-x86_64-unknown-linux-musl.tar.gz -C target k8s-gcr-auth-helper
- name: Upload build distribution
uses: actions/upload-artifact@v1
with:
name: k8s-gcr-auth-helper-x86_64-unknown-linux-musl.tar.gz
path: target/k8s-gcr-auth-helper-x86_64-unknown-linux-musl.tar.gz