Skip to content

Commit ea70a45

Browse files
authored
Merge pull request #32 from andrewn/chore/xcode-action
Build app using github actions
2 parents 4cb628d + dd12689 commit ea70a45

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

.github/workflows/macos.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Build macOS App
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags:
7+
- "v*" # This will trigger the workflow on push of tags starting with 'v'
8+
pull_request:
9+
branches: [main]
10+
11+
env:
12+
PROJECT_NAME: BrewServicesMenubar
13+
SCHEME_NAME: BrewServicesMenubar
14+
XCODE_VERSION: 15.4
15+
16+
jobs:
17+
build:
18+
runs-on: macos-latest
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Select Xcode
24+
run: sudo xcode-select -s /Applications/Xcode_${XCODE_VERSION}.app
25+
26+
- name: Cache Swift packages
27+
uses: actions/cache@v4
28+
with:
29+
path: .build
30+
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
31+
restore-keys: |
32+
${{ runner.os }}-spm-
33+
34+
- name: Build
35+
run: |
36+
xcodebuild clean build -project ${PROJECT_NAME}.xcodeproj -scheme ${SCHEME_NAME} -destination 'platform=macOS'
37+
38+
- name: Archive app
39+
run: |
40+
xcodebuild -project ${PROJECT_NAME}.xcodeproj -scheme ${SCHEME_NAME} -configuration Release archive -archivePath $PWD/build/${PROJECT_NAME}.xcarchive
41+
42+
- name: Export app
43+
run: |
44+
xcodebuild -exportArchive -archivePath $PWD/build/${PROJECT_NAME}.xcarchive -exportOptionsPlist ExportOptions.plist -exportPath $PWD/build
45+
46+
- name: Get version
47+
id: get_version
48+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
49+
if: startsWith(github.ref, 'refs/tags/')
50+
51+
- name: Zip .app for upload
52+
run: |
53+
cd $PWD/build
54+
if [[ $GITHUB_REF == refs/tags/* ]]; then
55+
zip -r ${{ env.PROJECT_NAME }}-${{ steps.get_version.outputs.VERSION }}.zip ${{ env.PROJECT_NAME }}.app
56+
else
57+
zip -r ${{ env.PROJECT_NAME }}.zip ${{ env.PROJECT_NAME }}.app
58+
fi
59+
echo "ZIP_FILE=${{ env.PROJECT_NAME }}${{ startsWith(github.ref, 'refs/tags/') && format('-{0}', steps.get_version.outputs.VERSION) || '' }}.zip" >> $GITHUB_ENV
60+
ls -la # Debug: List contents of current directory
61+
62+
- name: Debug - List build directory
63+
run: |
64+
echo "Contents of $PWD/build:"
65+
ls -R $PWD/build
66+
67+
- name: Upload artifact
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: ${{ env.PROJECT_NAME }}
71+
path: ${{ github.workspace }}/build/${{ env.ZIP_FILE }}
72+
if: success()
73+
74+
- name: Upload build directory (for debugging)
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: build-directory-contents
78+
path: $PWD/build
79+
if: failure()
80+
81+
- name: Create Release
82+
if: startsWith(github.ref, 'refs/tags/')
83+
uses: softprops/action-gh-release@v2
84+
with:
85+
files: ${{ github.workspace }}/build/${{ env.ZIP_FILE }}
86+
draft: false
87+
prerelease: false

ExportOptions.plist

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>method</key>
6+
<string>mac-application</string>
7+
<key>teamID</key>
8+
<string>PS3M4R7DP9</string>
9+
<key>signingStyle</key>
10+
<string>automatic</string>
11+
<key>stripSwiftSymbols</key>
12+
<true />
13+
<key>uploadSymbols</key>
14+
<true />
15+
<key>uploadBitcode</key>
16+
<false />
17+
</dict>
18+
</plist>

0 commit comments

Comments
 (0)