name: Test
on:
push:
branches:
- '*'
pull_request:
jobs:
security-audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
name: Checkout the repository
- uses: actions/cache@v2.1.5
name: Cache cargo
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/audit-check@v1
name: Audit check cargo packages
with:
token: ${{ secrets.GITHUB_TOKEN }}
version:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2.3.4
with:
fetch-depth: 0
- uses: chaaz/versio-actions/install@v1.1
name: Install versio
- name: Check projects
run: versio check
- name: Print changes
run: versio plan
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USER: ${{ github.actor }}
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/cache@v2.1.5
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
- uses: actions-rs/cargo@v1
with:
command: check
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
steps:
- run: ${{ matrix.install }}
env:
DEBIAN_FRONTEND: noninteractive
- uses: actions/checkout@v2.3.4
- uses: actions/cache@v2.1.5
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
- uses: actions-rs/cargo@v1
with:
command: test
bench:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/cache@v2.1.5
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
- uses: actions-rs/cargo@v1
with:
command: bench
lints:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/cache@v2.1.5
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
components: rustfmt, clippy
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets --all-features -- -D warnings -Dclippy::all -D clippy::pedantic
-D clippy::cargo
- name: Prettify code
uses: creyD/prettier_action@v3.3
with:
prettier_options: --check **/*.{yml,yaml}
publish-to-cargo:
if: "github.ref == 'refs/heads/main' && contains(github.event.head_commit.message,\
\ 'build(deploy): Versio update versions')"
needs:
- version
- test
- lints
- check
- security-audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
with:
token: ${{ secrets.COMMITTER_TOKEN }}
fetch-depth: 0
- uses: actions-rs/cargo@v1
name: Install TOML Reader
with:
command: install
args: toml-cli
- id: get_version
name: Calculate current version number
run: echo ::set-output name=VERSION::$(toml get Cargo.toml package.version |
tail -c +2 | head -c -2)
shell: bash
- id: get_cargo_version
name: Calculate cargo version number
run: echo ::set-output name=VERSION::$(cargo search serde | sed -r "s/.* = \"([0-9].*)\"
+#.*/\1/g" | head -n 1)
- env:
CARGO_TOKEN: ${{ secrets.CARGO_TOKEN }}
if: ${{ steps.get_version.outputs.VERSION != steps.get_cargo_version.outputs.VERSION
}}
run: |
cargo login "$CARGO_TOKEN"
cargo publish
merge-and-push:
if: github.ref == 'refs/heads/main'
needs:
- version
- test
- lints
- check
- security-audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
with:
token: ${{ secrets.COMMITTER_TOKEN }}
fetch-depth: 0
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git-user-signingkey: true
git-commit-gpgsign: true
git-tag-gpgsign: true
- uses: chaaz/versio-actions/install@v1.1
name: Install versio
- name: Generate release
run: versio release
env:
GITHUB_TOKEN: ${{ secrets.COMMITTER_TOKEN }}
GITHUB_USER: ${{ github.actor }}