-
Notifications
You must be signed in to change notification settings - Fork 0
225 lines (186 loc) · 8.78 KB
/
Copy pathrelease.yml
File metadata and controls
225 lines (186 loc) · 8.78 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
name: Release
on:
push:
tags:
- "v*.*.*"
env:
TARGET: DockMasterPro
BUNDLE_NAME: "DockMaster Pro.app"
PUBLIC_REPO: devlive-community/DockMaster-Pro
PRIVATE_REPO: devlive-community/DockMasterPro
jobs:
# ──────────────────────────────────────────────────────────────────────────
# Job 1: Build universal + arm64 + x86_64 binaries, generate release notes
# ──────────────────────────────────────────────────────────────────────────
build:
name: Build Release Binaries
runs-on: macos-15
outputs:
version: ${{ steps.meta.outputs.version }}
tag: ${{ steps.meta.outputs.tag }}
steps:
- name: Checkout (full history for release notes)
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version metadata
id: meta
run: |
TAG="${GITHUB_REF_NAME}"
VERSION="${TAG#v}"
echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Cache SPM dependencies
uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-spm-release-${{ hashFiles('Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-release-
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode.app
- name: Build arm64
run: swift build -c release --arch arm64
- name: Build x86_64
run: swift build -c release --arch x86_64
- name: Create universal binary
run: |
mkdir -p .build/universal
lipo -create \
.build/arm64-apple-macosx/release/${{ env.TARGET }} \
.build/x86_64-apple-macosx/release/${{ env.TARGET }} \
-output .build/universal/${{ env.TARGET }}
lipo -info .build/universal/${{ env.TARGET }}
- name: Assemble and sign .app bundles
run: |
TAG="${{ steps.meta.outputs.tag }}"
ARTIFACTS="${GITHUB_WORKSPACE}/artifacts"
RESOURCES_DIR=".build/arm64-apple-macosx/release"
assemble_app() {
local BIN_SRC="$1"
local APP_PATH="$2"
rm -rf "$APP_PATH"
mkdir -p "$APP_PATH/Contents/MacOS"
mkdir -p "$APP_PATH/Contents/Resources"
cp "$BIN_SRC" "$APP_PATH/Contents/MacOS/${{ env.TARGET }}"
cp "${{ env.TARGET }}/App/Info.plist" "$APP_PATH/Contents/Info.plist"
# SPM resource bundles (localizations, assets)
for bundle in "${RESOURCES_DIR}"/*.bundle; do
[ -e "$bundle" ] && cp -r "$bundle" "$APP_PATH/Contents/Resources/"
done
# App icon
ICNS="${{ env.TARGET }}/Resources/AppIcon.icns"
[ -f "$ICNS" ] && cp "$ICNS" "$APP_PATH/Contents/Resources/AppIcon.icns"
# Ad-hoc code sign (deep, hardened runtime)
codesign --force --deep --options runtime --sign - "$APP_PATH"
}
mkdir -p "$ARTIFACTS/arm64" "$ARTIFACTS/x86_64" "$ARTIFACTS/universal"
assemble_app \
".build/arm64-apple-macosx/release/${{ env.TARGET }}" \
"$ARTIFACTS/arm64/${{ env.BUNDLE_NAME }}"
assemble_app \
".build/x86_64-apple-macosx/release/${{ env.TARGET }}" \
"$ARTIFACTS/x86_64/${{ env.BUNDLE_NAME }}"
assemble_app \
".build/universal/${{ env.TARGET }}" \
"$ARTIFACTS/universal/${{ env.BUNDLE_NAME }}"
# Package each variant as a zip
(cd "$ARTIFACTS/arm64" && zip -qr "../${{ env.TARGET }}_${TAG}_arm64.zip" "${{ env.BUNDLE_NAME }}")
(cd "$ARTIFACTS/x86_64" && zip -qr "../${{ env.TARGET }}_${TAG}_x86_64.zip" "${{ env.BUNDLE_NAME }}")
(cd "$ARTIFACTS/universal" && zip -qr "../${{ env.TARGET }}_${TAG}_universal.zip" "${{ env.BUNDLE_NAME }}")
echo "=== Artifact sizes ==="
ls -lh "$ARTIFACTS"/*.zip
- name: Generate release notes
run: |
TAG="${{ steps.meta.outputs.tag }}"
# Find previous tag; fall back to first commit if this is the first release
PREV_TAG=$(git describe --tags --abbrev=0 "${TAG}^" 2>/dev/null || git rev-list --max-parents=0 HEAD)
RANGE="${PREV_TAG}..${TAG}"
echo "Generating notes for range: ${RANGE}"
section() {
local EMOJI="$1"
local TITLE="$2"
local PATTERN="$3"
local ITEMS
ITEMS=$(git log "$RANGE" --no-merges --pretty=format:"%s" \
| grep -E "^${PATTERN}" \
| sed -E "s/^${PATTERN}(\([^)]*\))?: //" \
| sed 's/^/- /' || true)
if [ -n "$ITEMS" ]; then
printf "\n## %s %s\n%s\n" "$EMOJI" "$TITLE" "$ITEMS"
fi
}
{
section "🚀" "New Features" "feat"
section "🐛" "Bug Fixes" "fix"
section "⚡" "Performance" "perf"
section "🌍" "Internationalization" "i18n"
section "🔧" "Refactoring" "refactor"
# Remaining commits (chore, style, docs, ci, etc.) — exclude merges and above categories
OTHER=$(git log "$RANGE" --no-merges --pretty=format:"%s" \
| grep -vE "^(feat|fix|perf|i18n|refactor|Merge)" \
| sed 's/^/- /' || true)
if [ -n "$OTHER" ]; then
printf "\n## 📝 Other Changes\n%s\n" "$OTHER"
fi
printf "\n---\n"
printf "**Full Changelog**: https://github.com/%s/compare/%s...%s\n" \
"${{ env.PRIVATE_REPO }}" "$PREV_TAG" "$TAG"
} > "${GITHUB_WORKSPACE}/artifacts/release_notes.md"
echo "=== Release Notes Preview ==="
cat "${GITHUB_WORKSPACE}/artifacts/release_notes.md"
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: release-artifacts
path: artifacts/
retention-days: 1
# ──────────────────────────────────────────────────────────────────────────
# Job 2: Publish to PUBLIC repo (with compiled binaries)
# ──────────────────────────────────────────────────────────────────────────
publish-public:
name: Publish to Public Repo (with binaries)
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: release-artifacts
path: artifacts/
- name: Create GitHub Release on public repo
env:
GH_TOKEN: ${{ secrets.PUBLIC_REPO_TOKEN }}
TAG: ${{ needs.build.outputs.tag }}
VERSION: ${{ needs.build.outputs.version }}
run: |
gh release create "$TAG" \
--repo "${{ env.PUBLIC_REPO }}" \
--title "DockMaster Pro ${VERSION}" \
--notes-file "artifacts/release_notes.md" \
"artifacts/${{ env.TARGET }}_${TAG}_arm64.zip" \
"artifacts/${{ env.TARGET }}_${TAG}_x86_64.zip" \
"artifacts/${{ env.TARGET }}_${TAG}_universal.zip"
# ──────────────────────────────────────────────────────────────────────────
# Job 3: Publish to PRIVATE source repo (release notes only, no binaries)
# ──────────────────────────────────────────────────────────────────────────
publish-private:
name: Publish to Private Repo (source only)
needs: build
runs-on: ubuntu-latest
steps:
- name: Download release notes
uses: actions/download-artifact@v4
with:
name: release-artifacts
path: artifacts/
- name: Create GitHub Release on private repo
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ needs.build.outputs.tag }}
VERSION: ${{ needs.build.outputs.version }}
run: |
gh release create "$TAG" \
--repo "${{ env.PRIVATE_REPO }}" \
--title "DockMaster Pro ${VERSION}" \
--notes-file "artifacts/release_notes.md"