Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
julianandrews committed Feb 27, 2024
1 parent a62a8b7 commit 05c6ef9
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 75 deletions.
71 changes: 22 additions & 49 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
on: [push, pull_request]
on:
push:
branches:
- '*'
pull_request: {}

name: Continuous integration

Expand All @@ -7,73 +11,42 @@ jobs:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: check
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo check

test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- run: cargo test --all-features

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
components: rustfmt
- run: cargo fmt --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
command: clippy
args: -- -D warnings
components: clippy
- run: cargo clippy -- -D warnings

benchmark:
name: Benchmark
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- uses: actions-rs/cargo@v1
with:
command: bench
args: --features benchmarks
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- run: cargo bench --features benchmarks
72 changes: 46 additions & 26 deletions .github/workflows/build.yml → .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Build
name: Create Release
on:
workflow_dispatch: {}
push:
tags:
- 'v*'

jobs:
build:
name: Build
Expand Down Expand Up @@ -36,22 +39,18 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
target: ${{ matrix.arch }}-${{ matrix.target-os }}
targets: ${{ matrix.target }}

- name: Build binary
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --target ${{ matrix.arch }}-${{ matrix.target-os }}
run: cargo build --release --verbose --target ${{ matrix.arch }}-${{ matrix.target-os }}
env:
RUST_BACKTRACE: 1

- name: Build archive
id: build_archive
Expand All @@ -64,43 +63,64 @@ jobs:
if [ "${{ matrix.build }}" = "windows" ]; then
cp "../target/${{ matrix.arch }}-${{ matrix.target-os }}/release/markovpass.exe" ./
name="markovpass-$version-${{ matrix.arch }}-${{ matrix.target-os }}.7z"
7z a "$name" LICENSE README.md markovpass.exe
7z a "$name" *
else
cp "../target/${{ matrix.arch }}-${{ matrix.target-os }}/release/markovpass" ./
name="markovpass-$version-${{ matrix.arch }}-${{ matrix.target-os }}.tar.gz"
tar -czf "$name" LICENSE README.md markovpass
tar -czf "$name" *
fi
echo "::set-output name=name::$name"
echo "name=$name" >> "$GITHUB_OUTPUT"
- name: Upload archive
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: ${{ steps.build_archive.outputs.name }}
path: archive/${{ steps.build_archive.outputs.name }}

make_deb:
name: Make .deb
runs-on: ubuntu-latest
steps:

- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
profile: minimal
override: true
toolchain: nightly

- name: Build .deb
id: deb
run: |
cargo install cargo-deb
deb_file=$(cargo deb)
echo "::set-output name=name::$(basename $deb_file)"
debfile=$(cargo deb)
result=$?
echo "debfile=$(basename $debfile)" >> "$GITHUB_OUTPUT"
exit $result
- name: Upload .deb
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ steps.deb.outputs.debfile }}
path: target/debian/${{ steps.deb.outputs.debfile }}

release:
name: Create release
needs: [build, make_deb]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create release
uses: softprops/action-gh-release@v1
with:
name: ${{ steps.deb.outputs.name }}
path: target/debian/${{ steps.deb.outputs.name }}
tag_name: ${{ github.ref_name }}
draft: true
files: |
artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 05c6ef9

Please sign in to comment.