-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (108 loc) · 3.63 KB
/
release.yml
File metadata and controls
114 lines (108 loc) · 3.63 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
permissions:
contents: write
jobs:
create-release:
name: Create GitHub Release
runs-on: ubuntu-latest
steps:
- name: Create release if not exists
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
version="${{ github.ref_name }}"
repo="${{ github.repository }}"
if ! gh release view "$version" --repo "$repo" > /dev/null 2>&1; then
gh release create "$version" \
--repo "$repo" \
--generate-notes \
--title "$version"
else
echo "Release $version already exists."
fi
build-windows:
name: Build Windows Release
needs: create-release
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
key: release
- name: Windows environment setup
shell: powershell
run: |
Set-MpPreference -DisableRealtimeMonitoring $true -ErrorAction SilentlyContinue
Write-Host "rustc: $(rustc --version)"
Write-Host "cargo: $(cargo --version)"
- name: Build release binary
run: cargo build --release --locked
- name: Run tests
run: cargo test --workspace -- --test-threads=4
- name: Verify clippy clean
run: cargo clippy --all-targets -- -D warnings
- name: Verify fmt clean
run: cargo fmt --check
- name: Package binary
shell: powershell
run: |
$version = "${{ github.ref_name }}"
$outDir = "devbase-$version-windows-x64"
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
Copy-Item "target\release\devbase.exe" "$outDir\"
Copy-Item "README.md" "$outDir\"
Copy-Item "LICENSE" "$outDir\"
Copy-Item "CHANGELOG.md" "$outDir\"
Compress-Archive -Path $outDir -DestinationPath "$outDir.zip" -Force
Write-Host "Created $outDir.zip"
- name: Upload Windows asset
shell: powershell
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$version = "${{ github.ref_name }}"
$archive = "devbase-$version-windows-x64.zip"
gh release upload $version $archive --repo ${{ github.repository }} --clobber
build-linux:
name: Build Linux Release
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
key: release-linux
- name: Build release binary
run: cargo build --release --locked
- name: Run tests
run: cargo test --workspace -- --test-threads=4
- name: Verify clippy clean
run: cargo clippy --all-targets -- -D warnings
- name: Verify fmt clean
run: cargo fmt --check
- name: Package binary
run: |
version="${{ github.ref_name }}"
outDir="devbase-${version}-linux-x64"
mkdir -p "$outDir"
cp target/release/devbase "$outDir/"
cp README.md "$outDir/"
cp LICENSE "$outDir/"
cp CHANGELOG.md "$outDir/"
tar czf "${outDir}.tar.gz" "$outDir"
echo "Created ${outDir}.tar.gz"
- name: Upload Linux asset
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
version="${{ github.ref_name }}"
archive="devbase-${version}-linux-x64.tar.gz"
gh release upload "$version" "$archive" --repo ${{ github.repository }} --clobber