Workflows

This commit is contained in:
2025-05-07 19:46:16 +02:00
parent 8e44310c41
commit 9594c3b5aa
2 changed files with 159 additions and 0 deletions

View File

@@ -0,0 +1,85 @@
name: Code style
on:
workflow_dispatch:
pull_request:
env:
CARGO_TERM_COLOR: always
jobs:
cargo-check:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Setup rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt,clippy
# Cache cargo registry
- name: Hash the lock file
uses: https://gitea.com/seepine/hash-files@v1
id: get-hash
with:
patterns: |
**/Cargo.lock
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: cargo-${{ steps.get-hash.outputs.hash }}
restore-keys: |
cargo-
# Cache cargo registry - end
- name: Cargo check
uses: actions-rs/cargo@v1
with:
command: check
clippy:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Setup rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt,clippy
# Cache cargo registry
- name: Hash the lock file
uses: https://gitea.com/seepine/hash-files@v1
id: get-hash
with:
patterns: |
**/Cargo.lock
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: cargo-${{ steps.get-hash.outputs.hash }}
restore-keys: |
cargo-
# Cache cargo registry - end
- name: Run clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-targets --all-features -- -Dwarnings

View File

@@ -0,0 +1,74 @@
---
name: Release packages
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
jobs:
build-and-release-artifact:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
# Cache cargo registry
- name: Hash the lock file
uses: https://gitea.com/seepine/hash-files@v1
id: get-hash
with:
patterns: |
**/Cargo.lock
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: cargo-${{ steps.get-hash.outputs.hash }}
restore-keys: |
cargo-
# Cache cargo registry - end
- name: Build application
uses: actions-rs/cargo@v1
with:
command: build
args: --release --all-features --workspace --all-targets
- name: Package application
uses: actions-rs/cargo@v1
with:
command: package
args: --all-features --workspace --allow-dirty
- name: Add registry to cargo config
run: echo -e '[registries.gitea]\nindex = "sparse+https://git.noahknegt.com/api/packages/${{ github.repository_owner }}/cargo/"\n' > ~/.cargo/config
- name: Login to cargo registry
uses: actions-rs/cargo@v1
with:
command: login
args: ${{ secrets.CARGO_REGISTRY_TOKEN }} --registry gitea
- name: Publish to cargo registry
uses: actions-rs/cargo@v1
with:
command: publish
args: --no-verify --registry gitea
env:
CARGO_NET_GIT_FETCH_WITH_CLI: true
CARGO_NET_RETRY: 2
CARGO_NET_TIMEOUT: 120