-
Notifications
You must be signed in to change notification settings - Fork 0
176 lines (152 loc) · 4.81 KB
/
Copy pathrelease.yml
File metadata and controls
176 lines (152 loc) · 4.81 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Release
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write
jobs:
# Extract version from tag and update Cargo.toml, commit back to main
version:
name: Bump version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.tag.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version from tag
id: tag
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Update Cargo.toml version
run: |
sed -i 's/^version = ".*"/version = "${{ steps.tag.outputs.version }}"/' Cargo.toml
- name: Update Cargo.lock
uses: dtolnay/rust-toolchain@stable
- run: cargo update --workspace
- name: Commit version bump
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Cargo.toml Cargo.lock
git commit -m "chore: bump version to ${{ steps.tag.outputs.version }}"
git push origin main
build:
name: Build — ${{ matrix.name }}
needs: version
strategy:
fail-fast: false
matrix:
include:
- name: macOS
os: macos-latest
target: aarch64-apple-darwin
artifact: gregory
archive: gregory-macos.tar.gz
- name: Linux
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact: gregory
archive: gregory-linux.tar.gz
- name: Windows
os: windows-latest
target: x86_64-pc-windows-msvc
artifact: gregory.exe
archive: gregory-windows.zip
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: main
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
# Linux — ALSA and other audio/GUI deps
- name: Install Linux dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y \
libasound2-dev \
libudev-dev \
pkg-config \
libxkbcommon-dev \
libwayland-dev \
libssl-dev
- name: Cache cargo registry
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ matrix.os }}-cargo-
- name: Build
run: cargo build --release --bin gregory --target ${{ matrix.target }}
# macOS / Linux — tar.gz
- name: Package (Unix)
if: matrix.os != 'windows-latest'
run: |
cp target/${{ matrix.target }}/release/${{ matrix.artifact }} .
tar czf ${{ matrix.archive }} ${{ matrix.artifact }} README.md LICENSE-MIT LICENSE-APACHE
shell: bash
# Windows — zip
- name: Package (Windows)
if: matrix.os == 'windows-latest'
run: |
Copy-Item "target\${{ matrix.target }}\release\${{ matrix.artifact }}" .
Compress-Archive -Path ${{ matrix.artifact }},README.md -DestinationPath ${{ matrix.archive }}
shell: pwsh
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.archive }}
path: ${{ matrix.archive }}
release:
name: Publish release
needs: [version, build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: main
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
merge-multiple: true
- name: Generate changelog
id: changelog
run: |
PREV_TAG=$(git tag --sort=-version:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sed -n '2p')
if [ -z "$PREV_TAG" ]; then
LOG=$(git log --pretty=format:"- %s" HEAD)
else
LOG=$(git log --pretty=format:"- %s" "${PREV_TAG}..HEAD")
fi
{
echo "changelog<<EOF"
echo "$LOG"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: Gregory ${{ github.ref_name }}
body: |
## What's changed
${{ steps.changelog.outputs.changelog }}
files: |
gregory-macos.tar.gz
gregory-linux.tar.gz
gregory-windows.zip
draft: false
prerelease: false