-
Notifications
You must be signed in to change notification settings - Fork 0
218 lines (185 loc) · 7.1 KB
/
desktop-release.yaml
File metadata and controls
218 lines (185 loc) · 7.1 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
name: Desktop Release
on:
push:
tags:
- 'v*'
- 'desktop-v*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 0.3.0)'
required: true
type: string
env:
APP_NAME: PlexusOne Desktop
BUNDLE_ID: com.plexusone.desktop
jobs:
build-macos:
name: Build macOS
runs-on: macos-14
strategy:
matrix:
include:
- arch: arm64
target: arm64-apple-macosx
- arch: x86_64
target: x86_64-apple-macosx
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Swift
uses: swift-actions/setup-swift@v2
with:
swift-version: '5.9'
- name: Get version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
else
# Extract version from tag (v0.3.0 -> 0.3.0)
VERSION="${GITHUB_REF_NAME#v}"
VERSION="${VERSION#desktop-v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
fi
- name: Build release binary
working-directory: apps/desktop
run: |
swift build -c release --arch ${{ matrix.arch }}
- name: Create app bundle
working-directory: apps/desktop
run: |
APP_DIR="${{ env.APP_NAME }}.app"
mkdir -p "$APP_DIR/Contents/MacOS"
mkdir -p "$APP_DIR/Contents/Resources"
# Copy binary
cp ".build/${{ matrix.target }}/release/PlexusOneDesktop" "$APP_DIR/Contents/MacOS/"
# Copy Info.plist and update version
cp Sources/PlexusOneDesktop/Info.plist "$APP_DIR/Contents/"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${{ steps.version.outputs.version }}" "$APP_DIR/Contents/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${{ steps.version.outputs.version }}" "$APP_DIR/Contents/Info.plist"
# Copy icon if exists
if [ -f "Sources/PlexusOneDesktop/Resources/AppIcon.icns" ]; then
cp Sources/PlexusOneDesktop/Resources/AppIcon.icns "$APP_DIR/Contents/Resources/"
fi
- name: Create DMG
working-directory: apps/desktop
run: |
# Install create-dmg
brew install create-dmg || true
DMG_NAME="PlexusOneDesktop-${{ steps.version.outputs.version }}-macos-${{ matrix.arch }}.dmg"
# Create DMG
create-dmg \
--volname "${{ env.APP_NAME }}" \
--volicon "Sources/PlexusOneDesktop/Resources/AppIcon.icns" \
--window-pos 200 120 \
--window-size 600 400 \
--icon-size 100 \
--icon "${{ env.APP_NAME }}.app" 150 190 \
--app-drop-link 450 185 \
"$DMG_NAME" \
"${{ env.APP_NAME }}.app" || \
# Fallback to hdiutil if create-dmg fails
hdiutil create -volname "${{ env.APP_NAME }}" -srcfolder "${{ env.APP_NAME }}.app" -ov -format UDZO "$DMG_NAME"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: PlexusOneDesktop-macos-${{ matrix.arch }}
path: apps/desktop/PlexusOneDesktop-*.dmg
build-universal:
name: Build macOS Universal
runs-on: macos-14
needs: []
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Swift
uses: swift-actions/setup-swift@v2
with:
swift-version: '5.9'
- name: Get version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
else
VERSION="${GITHUB_REF_NAME#v}"
VERSION="${VERSION#desktop-v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
fi
- name: Build universal binary
working-directory: apps/desktop
run: |
# Build for both architectures
swift build -c release --arch arm64
swift build -c release --arch x86_64
# Create universal binary with lipo
mkdir -p .build/universal/release
lipo -create \
.build/arm64-apple-macosx/release/PlexusOneDesktop \
.build/x86_64-apple-macosx/release/PlexusOneDesktop \
-output .build/universal/release/PlexusOneDesktop
- name: Create app bundle
working-directory: apps/desktop
run: |
APP_DIR="${{ env.APP_NAME }}.app"
mkdir -p "$APP_DIR/Contents/MacOS"
mkdir -p "$APP_DIR/Contents/Resources"
# Copy universal binary
cp .build/universal/release/PlexusOneDesktop "$APP_DIR/Contents/MacOS/"
# Copy Info.plist and update version
cp Sources/PlexusOneDesktop/Info.plist "$APP_DIR/Contents/"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${{ steps.version.outputs.version }}" "$APP_DIR/Contents/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${{ steps.version.outputs.version }}" "$APP_DIR/Contents/Info.plist"
# Copy icon if exists
if [ -f "Sources/PlexusOneDesktop/Resources/AppIcon.icns" ]; then
cp Sources/PlexusOneDesktop/Resources/AppIcon.icns "$APP_DIR/Contents/Resources/"
fi
- name: Create DMG
working-directory: apps/desktop
run: |
brew install create-dmg || true
DMG_NAME="PlexusOneDesktop-${{ steps.version.outputs.version }}-macos-universal.dmg"
create-dmg \
--volname "${{ env.APP_NAME }}" \
--volicon "Sources/PlexusOneDesktop/Resources/AppIcon.icns" \
--window-pos 200 120 \
--window-size 600 400 \
--icon-size 100 \
--icon "${{ env.APP_NAME }}.app" 150 190 \
--app-drop-link 450 185 \
"$DMG_NAME" \
"${{ env.APP_NAME }}.app" || \
hdiutil create -volname "${{ env.APP_NAME }}" -srcfolder "${{ env.APP_NAME }}.app" -ov -format UDZO "$DMG_NAME"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: PlexusOneDesktop-macos-universal
path: apps/desktop/PlexusOneDesktop-*.dmg
release:
name: Create Release
runs-on: ubuntu-latest
needs: [build-macos, build-universal]
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Get version
id: version
run: |
VERSION="${GITHUB_REF_NAME#v}"
VERSION="${VERSION#desktop-v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: PlexusOne Desktop v${{ steps.version.outputs.version }}
draft: false
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
generate_release_notes: true
files: |
artifacts/**/*.dmg