-
Notifications
You must be signed in to change notification settings - Fork 0
226 lines (199 loc) · 8.48 KB
/
Copy pathrelease.yml
File metadata and controls
226 lines (199 loc) · 8.48 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
name: Release
on:
push:
branches:
- main
permissions:
contents: write
actions: write
jobs:
# ── Check if the version in Cargo.toml is new ──────────────────────────────
check-version:
name: Check version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
should_release: ${{ steps.check.outputs.should_release }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Extract version from Cargo.toml
id: version
run: |
VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Detected version: $VERSION"
- name: Check if tag v${{ steps.version.outputs.version }} already exists
id: check
run: |
if git tag | grep -qx "v${{ steps.version.outputs.version }}"; then
echo "should_release=false" >> $GITHUB_OUTPUT
echo "Tag already exists — skipping release"
else
echo "should_release=true" >> $GITHUB_OUTPUT
echo "New version — will build and release"
fi
# ── Build on all platforms ─────────────────────────────────────────────────
build:
name: Build — ${{ matrix.os }}
needs: check-version
if: needs.check-version.outputs.should_release == 'true'
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-latest
asset_name: quackify-macos-universal.tar.gz
- os: ubuntu-latest
asset_name: quackify-linux-x86_64.tar.gz
- os: windows-latest
asset_name: quackify-windows-x86_64.zip
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
# ── macOS: universal binary (Apple Silicon + Intel) ──────────────────
- name: Add macOS cross-compilation targets
if: matrix.os == 'macos-latest'
run: rustup target add x86_64-apple-darwin aarch64-apple-darwin
- name: Build (macOS universal)
if: matrix.os == 'macos-latest'
run: |
cargo build --release --target x86_64-apple-darwin
cargo build --release --target aarch64-apple-darwin
lipo -create -output target/release/quackify \
target/x86_64-apple-darwin/release/quackify \
target/aarch64-apple-darwin/release/quackify
- name: Package macOS .app
if: matrix.os == 'macos-latest'
run: |
mkdir -p "Quackify.app/Contents/MacOS"
mkdir -p "Quackify.app/Contents/Resources"
cp target/release/quackify "Quackify.app/Contents/MacOS/"
cp assets/Info.plist "Quackify.app/Contents/"
cp assets/icon.icns "Quackify.app/Contents/Resources/"
tar czf quackify-macos-universal.tar.gz "Quackify.app"
# ── Linux ─────────────────────────────────────────────────────────────
- name: Install Linux system dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y \
libxcb-render0-dev \
libxcb-shape0-dev \
libxcb-xfixes0-dev \
libxkbcommon-dev \
libwayland-dev \
libegl1-mesa-dev \
pkg-config \
libssl-dev
- name: Build (Linux)
if: matrix.os == 'ubuntu-latest'
run: cargo build --release
- name: Package Linux
if: matrix.os == 'ubuntu-latest'
run: tar czf quackify-linux-x86_64.tar.gz -C target/release quackify
# ── Windows ───────────────────────────────────────────────────────────
- name: Build (Windows)
if: matrix.os == 'windows-latest'
run: cargo build --release
- name: Package Windows
if: matrix.os == 'windows-latest'
shell: pwsh
run: Compress-Archive -Path target/release/quackify.exe -DestinationPath quackify-windows-x86_64.zip
# ── Upload artifact for release job (auto-expires after 1 day) ──────
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: ${{ matrix.asset_name }}
retention-days: 1
# ── Create GitHub Release ──────────────────────────────────────────────────
release:
name: Create GitHub Release
needs: [check-version, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Create tag v${{ needs.check-version.outputs.version }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "v${{ needs.check-version.outputs.version }}"
git push origin "v${{ needs.check-version.outputs.version }}"
- uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.check-version.outputs.version }}
generate_release_notes: true
files: |
quackify-macos-universal.tar.gz
quackify-linux-x86_64.tar.gz
quackify-windows-x86_64.zip
# ── Update Homebrew Tap ────────────────────────────────────────────────────
update-tap:
name: Update Homebrew Tap
needs: [check-version, release]
runs-on: ubuntu-latest
steps:
- name: Download macOS release asset
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release download "v${{ needs.check-version.outputs.version }}" \
--repo draugvar/Duckify \
--pattern "quackify-macos-universal.tar.gz"
- name: Compute SHA256
id: sha256
run: |
SHA256=$(shasum -a 256 quackify-macos-universal.tar.gz | awk '{print $1}')
echo "value=$SHA256" >> $GITHUB_OUTPUT
- name: Update tap formula
env:
TAP_TOKEN: ${{ secrets.TAP_TOKEN }}
VERSION: ${{ needs.check-version.outputs.version }}
SHA256: ${{ steps.sha256.outputs.value }}
run: |
git clone "https://x-access-token:${TAP_TOKEN}@github.com/draugvar/homebrew-quackify.git" tap
mkdir -p tap/Casks
{
echo 'cask "quackify" do'
echo " version \"${VERSION}\""
echo " sha256 \"${SHA256}\""
echo ''
echo ' url "https://github.com/draugvar/Duckify/releases/download/v#{version}/quackify-macos-universal.tar.gz"'
echo ''
echo ' name "Quackify"'
echo ' desc "DuckDuckGo Email Converter"'
echo ' homepage "https://github.com/draugvar/Duckify"'
echo ''
echo ' app "Quackify.app"'
echo ''
echo ' zap trash: ['
echo ' "~/Library/Application Support/Quackify",'
echo ' "~/Library/Preferences/com.draugvar.quackify.plist",'
echo ' ]'
echo 'end'
} > tap/Casks/quackify.rb
cd tap
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Casks/quackify.rb
git diff --cached --quiet || git commit -m "Update quackify to v${VERSION}"
git push
# ── Delete artifacts ───────────────────────────────────────────────────────
cleanup:
name: Delete artifacts
needs: [release, update-tap]
if: always()
runs-on: ubuntu-latest
steps:
- name: Delete build artifacts
uses: geekyeggo/delete-artifact@v6
with:
name: |
quackify-macos-universal.tar.gz
quackify-linux-x86_64.tar.gz
quackify-windows-x86_64.zip
failOnError: false