Skip to content

Commit 32f43cf

Browse files
committed
testing workflows
1 parent fcec300 commit 32f43cf

File tree

10 files changed

+1118
-94
lines changed

10 files changed

+1118
-94
lines changed
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
name: Build macOS ARM Installer
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
push:
8+
tags:
9+
- "v*.*.*"
10+
workflow_dispatch:
11+
workflow_call:
12+
13+
jobs:
14+
build-macos-arm-installer:
15+
name: Build macOS ARM Installer
16+
runs-on: macos-14 # ARM runner for Apple Silicon
17+
18+
steps:
19+
- name: Set variables
20+
run: |
21+
repoFullName=${{ github.repository }}
22+
ref=${{ github.ref }}
23+
24+
# Handle both tag events and manual dispatch
25+
if [[ "$ref" =~ ^refs/tags/ ]]; then
26+
releaseVersion=${ref##refs/tags/}
27+
appVersion=${releaseVersion#v}
28+
else
29+
# For manual dispatch, use a default version
30+
releaseVersion="dev-$(date +%Y%m%d-%H%M%S)"
31+
appVersion="0.0.1-dev"
32+
fi
33+
34+
repositoryName=${repoFullName#*/}
35+
36+
echo "githubRepository=${{ github.repository }}" >> $GITHUB_ENV
37+
echo "githubRepositoryName=$repositoryName" >> $GITHUB_ENV
38+
echo "releaseVersion=$releaseVersion" >> $GITHUB_ENV
39+
echo "appVersion=$appVersion" >> $GITHUB_ENV
40+
echo "executableName=Cleanuparr.Api" >> $GITHUB_ENV
41+
42+
- name: Get vault secrets
43+
uses: hashicorp/vault-action@v2
44+
with:
45+
url: ${{ secrets.VAULT_HOST }}
46+
method: approle
47+
roleId: ${{ secrets.VAULT_ROLE_ID }}
48+
secretId: ${{ secrets.VAULT_SECRET_ID }}
49+
secrets:
50+
secrets/data/github repo_readonly_pat | REPO_READONLY_PAT;
51+
secrets/data/github packages_pat | PACKAGES_PAT
52+
53+
- name: Checkout repository
54+
uses: actions/checkout@v4
55+
with:
56+
repository: ${{ env.githubRepository }}
57+
ref: ${{ github.ref_name }}
58+
token: ${{ env.REPO_READONLY_PAT }}
59+
fetch-depth: 0
60+
61+
- name: Setup Node.js for frontend build
62+
uses: actions/setup-node@v4
63+
with:
64+
node-version: '18'
65+
cache: 'npm'
66+
cache-dependency-path: code/frontend/package-lock.json
67+
68+
- name: Build frontend
69+
run: |
70+
cd code/frontend
71+
npm ci
72+
npm run build
73+
74+
- name: Setup .NET
75+
uses: actions/setup-dotnet@v4
76+
with:
77+
dotnet-version: 9.0.x
78+
79+
- name: Restore .NET dependencies
80+
run: |
81+
dotnet nuget add source --username ${{ github.repository_owner }} --password ${{ env.PACKAGES_PAT }} --store-password-in-clear-text --name flmorg https://nuget.pkg.github.com/flmorg/index.json
82+
dotnet restore code/backend/${{ env.executableName }}/${{ env.executableName }}.csproj
83+
84+
- name: Copy frontend to backend wwwroot
85+
run: |
86+
mkdir -p code/backend/${{ env.executableName }}/wwwroot
87+
cp -r code/frontend/dist/ui/browser/* code/backend/${{ env.executableName }}/wwwroot/
88+
89+
- name: Build macOS ARM executable
90+
run: |
91+
dotnet publish code/backend/${{ env.executableName }}/${{ env.executableName }}.csproj \
92+
-c Release \
93+
--runtime osx-arm64 \
94+
--self-contained \
95+
-o dist/Cleanuparr.app/Contents/MacOS \
96+
/p:PublishSingleFile=true \
97+
/p:Version=${{ env.appVersion }}
98+
99+
- name: Verify architecture
100+
run: |
101+
echo "Checking architecture of built binary:"
102+
file dist/Cleanuparr.app/Contents/MacOS/cleanuparr
103+
if command -v lipo >/dev/null 2>&1; then
104+
lipo -info dist/Cleanuparr.app/Contents/MacOS/cleanuparr
105+
fi
106+
107+
- name: Create macOS app bundle structure
108+
run: |
109+
# Create proper app bundle structure
110+
mkdir -p dist/Cleanuparr.app/Contents/{MacOS,Resources}
111+
112+
# Create Info.plist
113+
cat > dist/Cleanuparr.app/Contents/Info.plist << EOF
114+
<?xml version="1.0" encoding="UTF-8"?>
115+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
116+
<plist version="1.0">
117+
<dict>
118+
<key>CFBundleExecutable</key>
119+
<string>cleanuparr</string>
120+
<key>CFBundleIdentifier</key>
121+
<string>org.cleanuparr.app</string>
122+
<key>CFBundleName</key>
123+
<string>Cleanuparr</string>
124+
<key>CFBundleVersion</key>
125+
<string>${{ env.appVersion }}</string>
126+
<key>CFBundleShortVersionString</key>
127+
<string>${{ env.appVersion }}</string>
128+
<key>CFBundleInfoDictionaryVersion</key>
129+
<string>6.0</string>
130+
<key>CFBundlePackageType</key>
131+
<string>APPL</string>
132+
<key>CFBundleSignature</key>
133+
<string>????</string>
134+
<key>NSHighResolutionCapable</key>
135+
<true/>
136+
<key>NSRequiresAquaSystemAppearance</key>
137+
<false/>
138+
<key>LSMinimumSystemVersion</key>
139+
<string>11.0</string>
140+
</dict>
141+
</plist>
142+
EOF
143+
144+
# Create sample configuration
145+
mkdir -p dist/Cleanuparr.app/Contents/Resources
146+
cat > dist/Cleanuparr.app/Contents/Resources/appsettings.json << EOF
147+
{
148+
"Logging": {
149+
"LogLevel": {
150+
"Default": "Information",
151+
"Microsoft.AspNetCore": "Warning"
152+
}
153+
},
154+
"AllowedHosts": "*",
155+
"HTTP_PORTS": "11011"
156+
}
157+
EOF
158+
159+
- name: Create PKG installer
160+
run: |
161+
# Create postinstall script
162+
mkdir -p scripts
163+
cat > scripts/postinstall << 'EOF'
164+
#!/bin/bash
165+
166+
# Create config directory in user's Application Support
167+
mkdir -p "$HOME/Library/Application Support/Cleanuparr"
168+
169+
# Create sample configuration if it doesn't exist
170+
if [ ! -f "$HOME/Library/Application Support/Cleanuparr/appsettings.json" ]; then
171+
cp "/Applications/Cleanuparr.app/Contents/Resources/appsettings.json" "$HOME/Library/Application Support/Cleanuparr/"
172+
fi
173+
174+
# Set permissions
175+
chmod -R 755 "$HOME/Library/Application Support/Cleanuparr"
176+
177+
exit 0
178+
EOF
179+
180+
chmod +x scripts/postinstall
181+
182+
# Determine package name
183+
if [[ "${{ github.ref }}" =~ ^refs/tags/ ]]; then
184+
pkg_name="Cleanuparr-${{ env.appVersion }}-macos-arm64.pkg"
185+
else
186+
pkg_name="Cleanuparr-${{ env.appVersion }}-macos-arm64-dev.pkg"
187+
fi
188+
189+
# Create PKG installer
190+
pkgbuild --root dist/ \
191+
--scripts scripts/ \
192+
--identifier org.cleanuparr.app \
193+
--version ${{ env.appVersion }} \
194+
--install-location /Applications \
195+
${pkg_name}
196+
197+
echo "pkgName=${pkg_name}" >> $GITHUB_ENV
198+
199+
- name: Upload installer as artifact
200+
uses: actions/upload-artifact@v4
201+
with:
202+
name: cleanuparr-macos-arm64-installer
203+
path: '${{ env.pkgName }}'
204+
retention-days: 30
205+
206+
- name: Release
207+
if: startsWith(github.ref, 'refs/tags/')
208+
uses: softprops/action-gh-release@v2
209+
with:
210+
name: ${{ env.releaseVersion }}
211+
tag_name: ${{ env.releaseVersion }}
212+
repository: ${{ env.githubRepository }}
213+
token: ${{ env.REPO_READONLY_PAT }}
214+
make_latest: true
215+
files: |
216+
${{ env.pkgName }}

0 commit comments

Comments
 (0)