Repository navigation
90 lines (80 loc) · 2.32 KB
/
Copy pathcicd.yml
File metadata and controls
90 lines (80 loc) · 2.32 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: CICD
on:
pull_request:
branches: [main]
push:
branches: [main]
tags: ['v[0-9]+\.[0-9]+\.[0-9]+']
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
permissions:
contents: read
jobs:
analysis:
name: Code Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Check Format
run: cargo fmt --all --check --quiet
- name: Check Clippy
run: cargo clippy --all-features --all-targets -- -D warnings
test:
name: Test
needs: [analysis]
strategy:
fail-fast: true
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v7
- name: Run Tests
run: cargo test --all-features --all-targets
prepare-release:
if: startsWith(github.ref, 'refs/tags/v')
name: Prepare Release
needs: [test]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Create Release
run: |
gh release delete "${{ github.ref_name }}" --yes || true
gh release create "${{ github.ref_name }}" --generate-notes --latest
release:
if: startsWith(github.ref, 'refs/tags/v')
name: Release
needs: [prepare-release]
env:
BINS: "git-todo git-user"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
strategy:
matrix:
platform: [
{ os: macos-latest, zip: git-tools-macos-arm64.zip },
{ os: ubuntu-latest, zip: git-tools-linux-amd64.zip },
{ os: windows-latest, zip: git-tools-windows-amd64.zip },
]
runs-on: ${{ matrix.platform.os }}
steps:
- uses: actions/checkout@v7
- name: Build and Upload
shell: sh
run: |
TAG="${{ github.ref_name }}"
VERSION="${TAG#v}"
perl -pi -e "s/^version = .*/version = \"$VERSION\"/" Cargo.toml
for bin in ${{ env.BINS }}; do
cargo install --path "crates/$bin" --root release --force --no-track
done
(cd release/bin && sha256sum * > hashes.txt)
7z a "${{ matrix.platform.zip }}" ./release/bin/* -mx=9
gh release upload "$TAG" "${{ matrix.platform.zip }}" --clobber