-
-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (59 loc) · 1.8 KB
/
cd.yml
File metadata and controls
61 lines (59 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Continuous Delivery
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
release-type:
description: 'Release type (major, minor, patch)'
required: false
default: 'patch'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Check formatting
run: cargo fmt -- --check
- name: Lint
run: cargo clippy -- -D warnings
- name: Run tests
run: cargo test --all --verbose
- name: Install cargo-release
run: cargo install cargo-release
- name: Run cargo-release (version bump, changelog, tag)
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
cargo release ${{ github.event.inputs.release-type }} --execute --no-publish;
else
cargo release --execute --no-publish;
fi
- name: Create GitHub Release with changelog
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
body_path: CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --verbose