-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (67 loc) · 2.21 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
name: Create Release
on:
push:
branches: [ main ]
permissions:
contents: write
jobs:
release:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
# Try to download artifacts from PR build
- name: Download PR artifacts
id: download
uses: dawidd6/action-download-artifact@v2
continue-on-error: true
with:
workflow: build.yml
workflow_conclusion: success
name: build-artifacts-${{ github.sha }}
path: artifacts
# Verify SHA matches
- name: Verify build SHA
id: verify
if: steps.download.outcome == 'success'
run: |
$expected_sha = Get-Content artifacts/SHA.txt
if ($expected_sha -ne "${{ github.sha }}") {
echo "SHA mismatch - need fresh build"
exit 1
}
- name: Install Rust
if: steps.download.outcome == 'failure' || steps.verify.outcome == 'failure'
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust dependencies and build outputs
if: steps.download.outcome == 'failure' || steps.verify.outcome == 'failure'
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build
if: steps.download.outcome == 'failure' || steps.verify.outcome == 'failure'
run: cargo build --release
- name: Move build artifacts
if: steps.download.outcome == 'failure' || steps.verify.outcome == 'failure'
run: |
mkdir artifacts
move target/release/*.exe artifacts/
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: artifacts/*.exe
tag_name: release-${{ github.sha }}
name: Release ${{ github.sha }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}