-
Notifications
You must be signed in to change notification settings - Fork 1
78 lines (67 loc) · 2.14 KB
/
Copy pathrelease.yml
File metadata and controls
78 lines (67 loc) · 2.14 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
name: Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
windows:
name: Windows x64
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Install Rust
shell: pwsh
run: |
rustup toolchain install nightly --profile minimal
rustup default nightly
rustc -Vv
cargo -Vv
- name: Cache cargo
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: windows-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
windows-cargo-
- name: Build release executable
run: cargo build --release
- name: Package executable
shell: pwsh
run: |
$tag = if ($env:GITHUB_REF_TYPE -eq "tag") { $env:GITHUB_REF_NAME } else { "manual-$env:GITHUB_RUN_NUMBER" }
New-Item -ItemType Directory -Force dist | Out-Null
Copy-Item target/release/caps.exe "dist/CAPS-$tag-windows-x64.exe"
Get-FileHash "dist/CAPS-$tag-windows-x64.exe" -Algorithm SHA256 |
ForEach-Object { "$($_.Hash) CAPS-$tag-windows-x64.exe" } |
Set-Content "dist/CAPS-$tag-windows-x64.exe.sha256"
- name: Upload workflow artifact
uses: actions/upload-artifact@v7
with:
name: CAPS-windows-x64
path: dist/*
- name: Publish GitHub release assets
if: github.ref_type == 'tag'
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
$tag = $env:GITHUB_REF_NAME
$notes = ".github/release-notes/$tag.md"
gh release view $tag *> $null
if ($LASTEXITCODE -ne 0) {
if (Test-Path $notes) {
gh release create $tag --title $tag --notes-file $notes
} else {
gh release create $tag --title $tag --notes "CAPS $tag"
}
}
gh release upload $tag "dist/CAPS-$tag-windows-x64.exe" "dist/CAPS-$tag-windows-x64.exe.sha256" --clobber