From 6e0f00824ae0d123ff7c8bbd7e81a48a953b449a Mon Sep 17 00:00:00 2001 From: Henrik Friedrichsen Date: Sat, 16 Jan 2021 00:06:05 +0100 Subject: [PATCH] Improve CI/CD pipeline - Separate checks/release builds - Add cargo fmt back - Upload release builds as assets Fixes #393 --- .github/workflows/cd.yml | 71 +++++++++++++++++++++++++ .github/workflows/{build.yml => ci.yml} | 31 ++++++----- 2 files changed, 89 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/cd.yml rename .github/workflows/{build.yml => ci.yml} (52%) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..39f2c33 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,71 @@ +name: CD + +on: + push: + tags: + - "v*.*.*" + +jobs: + publish: + name: Publishing ${{ matrix.build_target }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + build_target: [linux, macos] + include: + - build_target: linux + os: ubuntu-latest + artifact_prefix: linux + target: x86_64-unknown-linux-gnu + features: '' + - build_target: macos + os: macos-latest + artifact_prefix: macos + target: x86_64-apple-darwin + features: '--no-default-features --features portaudio_backend,cursive/pancurses-backend' + steps: + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + target: ${{ matrix.target }} + profile: minimal + - name: Install macOS dependencies + if: matrix.os == 'macos-latest' + run: brew install portaudio pkg-config + - name: Install Linux dependencies + if: matrix.os == 'ubuntu-latest' + run: | + sudo apt update + sudo apt install libpulse-dev libdbus-1-dev libncursesw5-dev libxcb-shape0-dev libxcb-xfixes0-dev + - uses: actions/checkout@v2 + name: Checkout src + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Running cargo build + uses: actions-rs/cargo@v1 + with: + command: build + args: --locked --release --target ${{ matrix.target }} ${{ matrix.features }} + - name: Extract git tag + shell: bash + run: echo "##[set-output name=tag;]$(echo ${GITHUB_REF#refs/tags/})" + id: extract_tag + - name: Packaging assets + shell: bash + run: | + cd target/${{ matrix.target }}/release + strip ncspot + tar czvf ncspot-${{ steps.extract_tag.outputs.tag }}-${{ matrix.artifact_prefix }}.tar.gz ncspot + shasum -a 256 ncspot-${{ steps.extract_tag.outputs.tag }}-${{ matrix.artifact_prefix }}.tar.gz > ncspot-${{ steps.extract_tag.outputs.tag }}-${{ matrix.artifact_prefix }}.sha256 + - name: Releasing assets + uses: softprops/action-gh-release@v1 + with: + files: target/${{ matrix.target }}/release/ncspot-* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/build.yml b/.github/workflows/ci.yml similarity index 52% rename from .github/workflows/build.yml rename to .github/workflows/ci.yml index a12cb75..5a8dc09 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Build +name: CI on: push: @@ -7,16 +7,7 @@ on: branches: [ master ] jobs: - build-macos: - runs-on: macos-latest - steps: - - uses: actions/checkout@v2 - - name: Install dependencies - run: brew install portaudio pkg-config - - name: Build - run: cargo build --verbose --no-default-features --features portaudio_backend,cursive/pancurses-backend - - build-linux: + check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -24,5 +15,19 @@ jobs: run: sudo apt update - name: Install dependencies run: sudo apt install libpulse-dev libdbus-1-dev libncursesw5-dev libxcb-shape0-dev libxcb-xfixes0-dev - - name: Build - run: cargo build --verbose + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: cargo check + run: cargo check + + fmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: cargo fmt + run: cargo fmt --all -- --check