-
Notifications
You must be signed in to change notification settings - Fork 0
195 lines (166 loc) Β· 6.52 KB
/
Copy pathrelease.yml
File metadata and controls
195 lines (166 loc) Β· 6.52 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
name: Release
# Fires on every push to main.
# Creates a GitHub Release only when CFBundleShortVersionString in Info.plist
# is newer than the latest published tag β no manual tagging needed.
on:
push:
branches: [main]
permissions:
contents: write
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
release:
runs-on: macos-15
outputs:
skip: ${{ steps.check.outputs.skip }}
version: ${{ steps.ver.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Read version from Info.plist
id: ver
run: |
VERSION=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" Info.plist)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
- name: Check whether this version was already released
id: check
run: |
TAG="${{ steps.ver.outputs.tag }}"
if gh release view "$TAG" > /dev/null 2>&1; then
echo "Version $TAG already released β skipping."
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "New version $TAG β will build and release."
echo "skip=false" >> $GITHUB_OUTPUT
fi
# ββ Everything below only runs for new versions βββββββββββββββββββββββββ
- name: Install tools
if: steps.check.outputs.skip == 'false'
run: brew install xcodegen create-dmg
- name: Generate Xcode project
if: steps.check.outputs.skip == 'false'
run: xcodegen generate
- name: Stamp build number
if: steps.check.outputs.skip == 'false'
run: |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${{ github.run_number }}" Info.plist
- name: Build Release archive
if: steps.check.outputs.skip == 'false'
run: |
xcodebuild \
-project OnekoMac.xcodeproj \
-scheme OnekoMac \
-configuration Release \
-archivePath "$RUNNER_TEMP/OnekoMac.xcarchive" \
archive \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO
- name: Package artifacts
if: steps.check.outputs.skip == 'false'
run: |
APP_DIR="$RUNNER_TEMP/OnekoMac.xcarchive/Products/Applications"
TAG="${{ steps.ver.outputs.tag }}"
ICNS="$APP_DIR/OnekoMac.app/Contents/Resources/AppIcon.icns"
DMG="$RUNNER_TEMP/OnekoMac-${TAG}.dmg"
ZIP="$RUNNER_TEMP/OnekoMac-${TAG}.zip"
# Try with background image; if it fails (missing asset), retry without.
rm -f "$DMG"
create-dmg \
--volname "OnekoMac" \
--volicon "$ICNS" \
--window-size 540 360 \
--background ".github/assets/dmg-bg.png" \
--icon-size 128 \
--icon "OnekoMac.app" 135 170 \
--app-drop-link 405 170 \
--hide-extension "OnekoMac.app" \
--no-internet-enable \
"$DMG" "$APP_DIR" \
|| {
rm -f "$DMG"
create-dmg \
--volname "OnekoMac" \
--volicon "$ICNS" \
--window-size 540 360 \
--icon-size 128 \
--icon "OnekoMac.app" 135 170 \
--app-drop-link 405 170 \
--hide-extension "OnekoMac.app" \
--no-internet-enable \
"$DMG" "$APP_DIR"
}
# ZIP of the .app
( cd "$APP_DIR" && zip -r --symlinks "$ZIP" OnekoMac.app )
echo "DMG=$DMG" >> $GITHUB_ENV
echo "ZIP=$ZIP" >> $GITHUB_ENV
- name: Create GitHub Release
if: steps.check.outputs.skip == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.ver.outputs.tag }}
name: "OnekoMac ${{ steps.ver.outputs.tag }}"
files: |
${{ env.DMG }}
${{ env.ZIP }}
body: |
## Install
**Recommended β DMG**
1. Download **OnekoMac-${{ steps.ver.outputs.tag }}.dmg**
2. Open the DMG and drag **OnekoMac.app** to Applications
3. First launch: right-click β **Open**
**Alternative β ZIP**
Download **OnekoMac-${{ steps.ver.outputs.tag }}.zip**, unzip, drag to Applications.
> **"damaged and can't be opened"?**
> Run in Terminal: `xattr -cr /Applications/OnekoMac.app`
---
generate_release_notes: true
update-tap:
needs: release
# Only run when: the release job actually succeeded AND a new version was built.
if: needs.release.result == 'success' && needs.release.outputs.skip == 'false'
runs-on: ubuntu-latest
steps:
- name: Checkout homebrew-tap
uses: actions/checkout@v4
with:
repository: hellov3an/homebrew-tap
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
- name: Compute SHA256 of DMG
id: sha
run: |
VERSION="${{ needs.release.outputs.version }}"
URL="https://github.com/hellov3an/OnekoMac/releases/download/v${VERSION}/OnekoMac-v${VERSION}.dmg"
echo "Target: $URL"
# Retry up to 6 times (GitHub CDN can take ~30s to propagate a new asset).
for i in 1 2 3 4 5 6; do
HTTP=$(curl -sL --write-out "%{http_code}" -o /tmp/release.dmg "$URL")
if [ "$HTTP" = "200" ]; then
SHA=$(shasum -a 256 /tmp/release.dmg | awk '{print $1}')
echo "sha256=$SHA" >> $GITHUB_OUTPUT
echo "SHA256: $SHA"
exit 0
fi
echo "Attempt $i: HTTP $HTTP β waiting 15s before retryβ¦"
sleep 15
done
echo "ERROR: DMG not available after 6 attempts"
exit 1
- name: Update cask version and sha256
run: |
VERSION="${{ needs.release.outputs.version }}"
SHA="${{ steps.sha.outputs.sha256 }}"
sed -i "s/version \".*\"/version \"${VERSION}\"/" Casks/onekomac.rb
sed -i "s/sha256 \".*\"/sha256 \"${SHA}\"/" Casks/onekomac.rb
cat Casks/onekomac.rb
- name: Commit and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Casks/onekomac.rb
git commit -m "update onekomac cask to v${{ needs.release.outputs.version }}"
git push