-
Notifications
You must be signed in to change notification settings - Fork 0
284 lines (234 loc) · 9.3 KB
/
release.yml
File metadata and controls
284 lines (234 loc) · 9.3 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
name: Build and Release
on:
push:
branches: [ main ]
# Add explicit permissions for the workflow
permissions:
contents: write
packages: read
actions: read
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libasound2-dev pkg-config libdbus-1-dev libxss-dev
- name: Install Rust
uses: dtolnay/rust-toolchain@nightly
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Run tests
run: cargo test --verbose
- name: Check binaries
run: |
cargo check --bin auto-beeper-service
cargo check --bin auto-beeper-configurator
build:
name: Build for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: test
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
suffix: ""
- os: windows-latest
target: x86_64-pc-windows-msvc
suffix: ".exe"
- os: windows-latest
target: x86_64-pc-windows-gnu
suffix: ".exe"
- os: macos-latest
target: x86_64-apple-darwin
suffix: ""
- os: macos-latest
target: aarch64-apple-darwin
suffix: ""
steps:
- uses: actions/checkout@v4
- name: Install system dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libasound2-dev pkg-config libdbus-1-dev libxss-dev
- name: Install Rust
uses: dtolnay/rust-toolchain@nightly
with:
targets: ${{ matrix.target }}
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-${{ matrix.target }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Build binaries
run: |
cargo build --release --target ${{ matrix.target }} --bin auto-beeper-service
cargo build --release --target ${{ matrix.target }} --bin auto-beeper-configurator
shell: bash
- name: Build Windows service binary (Windows only)
if: matrix.os == 'windows-latest'
run: |
cargo build --release --target ${{ matrix.target }} --bin auto-beeper-windows-service
shell: bash
- name: Create release directory
run: mkdir -p release
- name: Copy binaries
run: |
cp target/${{ matrix.target }}/release/auto-beeper-service${{ matrix.suffix }} release/auto-beeper-service-${{ matrix.target }}${{ matrix.suffix }}
cp target/${{ matrix.target }}/release/auto-beeper-configurator${{ matrix.suffix }} release/auto-beeper-configurator-${{ matrix.target }}${{ matrix.suffix }}
shell: bash
- name: Copy Windows service binary (Windows only)
if: matrix.os == 'windows-latest'
run: |
cp target/${{ matrix.target }}/release/auto-beeper-windows-service${{ matrix.suffix }} release/auto-beeper-windows-service-${{ matrix.target }}${{ matrix.suffix }}
shell: bash
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: beeper-automations-${{ matrix.target }}
path: release/*
create-dev-release:
name: Create Development Release
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
# Add explicit permissions for this job
permissions:
contents: write
packages: read
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create release directory
run: mkdir -p release
- name: Organize artifacts
run: |
# Copy all binaries from artifacts directories
find artifacts -name "auto-beeper-*" -type f -exec cp {} release/ \;
# Copy install scripts
cp scripts/install.sh release/install.sh
cp scripts/install.ps1 release/install.ps1
chmod +x release/install.sh
ls -la release/
- name: Generate release tag
id: tag
run: |
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
TAG="dev-$(date +'%Y%m%d-%H%M%S')"
BUILD_DATE="$(date +'%B %d, %Y at %H:%M:%S UTC')"
else
TAG="dev-${GITHUB_REF_NAME}-$(date +'%Y%m%d-%H%M%S')"
BUILD_DATE="$(date +'%B %d, %Y at %H:%M:%S UTC')"
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "build_date=$BUILD_DATE" >> $GITHUB_OUTPUT
echo "Generated tag: $TAG"
echo "Build date: $BUILD_DATE"
- name: Create development release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.tag }}
name: "Development Release ${{ steps.tag.outputs.tag }}"
body: |
🚀 **Beeper Automations - Development Release**
This is an automated development release built from the latest code.
**Binaries included:**
- `auto-beeper-service` - Background service for automation execution
- `auto-beeper-configurator` - TUI for configuration management
- `install.sh` - Installation script for Linux and macOS
- `install.ps1` - Installation script for Windows
**Quick Install:**
**Linux/macOS:**
```bash
curl -sSL https://github.com/${{ github.repository }}/releases/download/${{ steps.tag.outputs.tag }}/install.sh | bash
```
Or download and run manually:
```bash
wget https://github.com/${{ github.repository }}/releases/download/${{ steps.tag.outputs.tag }}/install.sh
chmod +x install.sh
./install.sh
```
**Windows (PowerShell as Administrator):**
```powershell
powershell -c "irm https://github.com/${{ github.repository }}/releases/download/${{ steps.tag.outputs.tag }}/install.ps1 | iex"
```
Or run directly in PowerShell:
```powershell
irm https://github.com/${{ github.repository }}/releases/download/${{ steps.tag.outputs.tag }}/install.ps1 | iex
```
Or download and run manually:
```powershell
Invoke-WebRequest -Uri "https://github.com/${{ github.repository }}/releases/download/${{ steps.tag.outputs.tag }}/install.ps1" -OutFile install.ps1
.\install.ps1
```
**Branch:** ${{ github.ref_name }}
**Commit:** ${{ github.sha }}
**Build Date:** ${{ steps.tag.outputs.build_date }}
**Note:** This is a development release and may contain bugs. Use stable releases for production.
**Setup:** After downloading, make the binaries executable (`chmod +x`) and ensure you have the Beeper Desktop API running.
files: release/*
draft: false
prerelease: false
cleanup-old-dev-releases:
name: Cleanup Old Dev Releases
runs-on: ubuntu-latest
needs: create-dev-release
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
# Add explicit permissions for this job
permissions:
contents: write
steps:
- name: Delete old development releases
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const releases = await github.rest.repos.listReleases({ owner, repo });
const devReleases = releases.data.filter(release =>
release.tag_name.startsWith('dev-')
);
const toDelete = devReleases.slice(3);
console.log(`Found ${devReleases.length}/${releases.data.length} development releases, deleting ${toDelete.length} old releases.`);
for (const release of toDelete) {
console.log(`Deleting old dev release: ${release.tag_name}`);
await github.rest.repos.deleteRelease({ owner, repo, release_id: release.id });
// Also delete the tag
try {
await github.rest.git.deleteRef({ owner, repo, ref: `tags/${release.tag_name}` });
} catch (error) {
console.log(`Could not delete tag ${release.tag_name}: ${error.message}`);
}
}