ci: unify into single job #35
Workflow file for this run
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
on: [pull_request, push] | |
name: Check, Lint, Build, Release | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
check-lint: | |
name: Check, Lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
components: rustfmt, clippy | |
- name: Install buf | |
uses: bufbuild/buf-action@v1 | |
with: | |
setup_only: true | |
- name: run protolint | |
uses: plexsystems/[email protected] | |
with: | |
configDirectory: . | |
srcDirectory: proto | |
- name: Install buf | |
uses: bufbuild/buf-action@v1 | |
with: | |
setup_only: true | |
# Disabled, since buf format is not configurable | |
#- name: Buf format | |
# run: buf format -d --exit-code | |
- name: Buf lint | |
run: buf lint --error-format github-actions | |
- name: Cargo check | |
run: cargo check | |
- name: Clippy | |
run: cargo clippy --all-targets --all-features | |
build-release: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: ubuntu-latest | |
name: x86_64-unknown-linux-gnu | |
binary-suffix: "" | |
rustflags: "" | |
- os: macos-latest-large | |
name: x86_64-apple-darwin | |
binary-suffix: "" | |
rustflags: "" | |
- os: ubuntu-latest | |
name: x86_64-pc-windows-gnu | |
binary-suffix: .exe | |
rustflags: "-C linker=/usr/bin/x86_64-w64-mingw32-gcc" | |
name: Check, Lint, Build, Release (${{ matrix.name }}) | |
runs-on: ${{ matrix.os }} | |
permissions: | |
contents: write | |
timeout-minutes: 20 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install latest stable toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
components: rustfmt, clippy | |
target: ${{ matrix.name }} | |
- name: Rust Cache | |
uses: Swatinem/[email protected] | |
with: | |
toolchain: stable | |
target: ${{ matrix.name }} | |
- name: Install mingw-w64 | |
run: sudo apt install mingw-w64 | |
if: ${{ matrix.name == 'x86_64-pc-windows-gnu' }} | |
- name: Rustfmt | |
run: cargo fmt --all -- --check | |
- name: Build | |
run: cargo build --release --target ${{ matrix.name }} | |
env: | |
RUSTFLAGS: ${{ matrix.rustflags }} | |
- name: "Set environment variables: version number and output filenames" | |
run: | | |
APP_VERSION=$(cargo metadata --format-version 1 | \ | |
jq -er '.packages | map(select(.name == "bip300301_enforcer") | .version) | .[0]') | |
APP_FILENAME="bip300301_enforcer-${APP_VERSION}-${{ matrix.name }}${{ matrix.binary-suffix }}" | |
echo "APP_VERSION=$APP_VERSION" >> "$GITHUB_ENV" | |
echo "APP_FILENAME=$APP_FILENAME" >> "$GITHUB_ENV" | |
- run: | | |
mkdir release | |
cp target/${{ matrix.name }}/release/bip300301_enforcer${{ matrix.binary-suffix }} release/${{ env.APP_FILENAME }} | |
- name: "Upload artifacts" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.APP_FILENAME }} | |
if-no-files-found: error | |
path: | | |
release/${{ env.APP_FILENAME }} | |
- name: Release | |
uses: softprops/[email protected] | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
release/${{ env.APP_FILENAME }} | |
fail_on_unmatched_files: true | |
upload-releases-to-releases-drivechain-info: | |
name: Upload releases to releases.drivechain.info | |
runs-on: ubuntu-latest | |
needs: [build-release] | |
if: github.ref == 'refs/heads/master' | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
- name: Create zip files for releases.drivechain.info | |
run: | | |
shopt -s extglob | |
mv bip300301_enforcer-+([0-9]).+([0-9]).+([0-9])-x86_64-apple-darwin bip300301-enforcer-latest-x86_64-apple-darwin | |
zip -r bip300301-enforcer-latest-x86_64-apple-darwin.zip \ | |
bip300301-enforcer-latest-x86_64-apple-darwin | |
mv bip300301_enforcer-+([0-9]).+([0-9]).+([0-9])-x86_64-pc-windows-gnu.exe bip300301-enforcer-latest-x86_64-pc-windows-gnu.exe | |
zip -r bip300301-enforcer-latest-x86_64-pc-windows-gnu.zip \ | |
bip300301-enforcer-latest-x86_64-pc-windows-gnu.exe | |
mv bip300301_enforcer-+([0-9]).+([0-9]).+([0-9])-x86_64-unknown-linux-gnu bip300301-enforcer-latest-x86_64-unknown-linux-gnu | |
zip -r bip300301-enforcer-latest-x86_64-unknown-linux-gnu.zip \ | |
bip300301-enforcer-latest-x86_64-unknown-linux-gnu \ | |
- name: Upload release assets to releases.drivechain.info | |
uses: cross-the-world/ssh-scp-ssh-pipelines@latest | |
with: | |
host: 45.33.96.47 | |
user: root | |
pass: ${{ secrets.RELEASES_SERVER_PW }} | |
port: 22 | |
scp: | | |
'bip300301-enforcer-latest-*.zip' => '/var/www/html/' |