-
Notifications
You must be signed in to change notification settings - Fork 8
98 lines (89 loc) · 2.69 KB
/
release.yml
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
91
92
93
94
95
96
97
98
name: Release
on:
push:
tags:
- "v[0-9]+\\.[0-9]+\\.[0-9]+"
env:
CARGO_INCREMENTAL: 0
permissions:
contents: write
jobs:
setup-environment:
runs-on: ubuntu-latest
outputs:
cargo_version: ${{ steps.cargo_version.outputs.value }}
cargo_cache_key: ${{ steps.cargo_cache_key.outputs.value }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
ref: ${{ github.ref }}
- uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Set cargo cache key
id: cargo_cache_key
run: |
CARGO_CACHE_KEY="${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}"
echo "value=$CARGO_CACHE_KEY" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
~/.cargo/bin
key: ${{ steps.cargo_cache_key.outputs.value }}
id: cache-cargo-release
- name: Get Cargo version
id: cargo_version
run: |
VERSION=$(cargo read-manifest | jq -r ".version")
echo "value=$VERSION" >> $GITHUB_OUTPUT
- name: Abort if there is a Cargo.toml and git tag mismatch
run: |
if [[ "v${{ steps.cargo_version.outputs.value }}" != "${{ github.ref_name }}" ]]; then
echo "There is a Cargo.toml version and git tag mismatch." && exit 1;
fi
lint:
needs: setup-environment
uses: ./.github/workflows/lint.yml
with:
cache-key: ${{ needs.setup-environment.outputs.cargo_cache_key }}
test:
needs: setup-environment
uses: ./.github/workflows/test.yml
with:
cache-key: ${{ needs.setup-environment.outputs.cargo_cache_key }}
create-release:
needs: [lint, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/create-gh-release-action@v1
with:
changelog: CHANGELOG.md
token: ${{ secrets.GITHUB_TOKEN }}
release:
needs: create-release
name: ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: i686-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
- os: macos-11
target: x86_64-apple-darwin
- os: macos-11
target: aarch64-apple-darwin
steps:
- uses: actions/checkout@v4
- uses: taiki-e/upload-rust-binary-action@v1
with:
bin: tinty
checksum: sha256
target: ${{ matrix.target }}
token: ${{ secrets.GITHUB_TOKEN }}