1+ name : Release
2+
3+ on :
4+ push :
5+ tags :
6+ - ' v*'
7+
8+ jobs :
9+ release :
10+ runs-on : macos-14
11+
12+ steps :
13+ - name : Checkout
14+ uses : actions/checkout@v4
15+
16+ - name : Setup Swift
17+ uses : swift-actions/setup-swift@v1
18+ with :
19+ swift-version : ' 5.9'
20+
21+ - name : Get version
22+ id : get_version
23+ run : echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
24+
25+ - name : Build release
26+ run : swift build -c release
27+
28+ - name : Create app bundle
29+ run : |
30+ VERSION=${{ steps.get_version.outputs.VERSION }}
31+ APP_NAME="Zero"
32+ BUILD_DIR=".build/release"
33+ RELEASE_DIR="releases"
34+
35+ mkdir -p ${RELEASE_DIR}
36+
37+ # Create app bundle
38+ APP_BUNDLE="${RELEASE_DIR}/${APP_NAME}.app"
39+ mkdir -p "${APP_BUNDLE}/Contents/MacOS"
40+ mkdir -p "${APP_BUNDLE}/Contents/Resources"
41+
42+ # Copy executable
43+ cp "${BUILD_DIR}/${APP_NAME}" "${APP_BUNDLE}/Contents/MacOS/"
44+
45+ # Copy resources
46+ cp -R "Sources/Zero/Resources/" "${APP_BUNDLE}/Contents/Resources/" || true
47+
48+ # Generate Info.plist
49+ cat > "${APP_BUNDLE}/Contents/Info.plist" << EOF
50+ <?xml version="1.0" encoding="UTF-8"?>
51+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
52+ <plist version="1.0">
53+ <dict>
54+ <key>CFBundleDevelopmentRegion</key>
55+ <string>en</string>
56+ <key>CFBundleExecutable</key>
57+ <string>${APP_NAME}</string>
58+ <key>CFBundleIdentifier</key>
59+ <string>com.zero.ide</string>
60+ <key>CFBundleInfoDictionaryVersion</key>
61+ <string>6.0</string>
62+ <key>CFBundleName</key>
63+ <string>${APP_NAME}</string>
64+ <key>CFBundlePackageType</key>
65+ <string>APPL</string>
66+ <key>CFBundleShortVersionString</key>
67+ <string>${VERSION}</string>
68+ <key>CFBundleVersion</key>
69+ <string>1</string>
70+ <key>LSMinimumSystemVersion</key>
71+ <string>14.0</string>
72+ <key>NSHighResolutionCapable</key>
73+ <true/>
74+ </dict>
75+ </plist>
76+ EOF
77+
78+ # Sign app (ad-hoc)
79+ codesign --force --deep --sign - "${APP_BUNDLE}" 2>/dev/null || true
80+
81+ # Create DMG
82+ DMG_TEMP=$(mktemp -d)
83+ cp -R "${APP_BUNDLE}" "${DMG_TEMP}/"
84+ ln -s /Applications "${DMG_TEMP}/Applications"
85+
86+ hdiutil create \
87+ -volname "${APP_NAME} ${VERSION}" \
88+ -srcfolder "${DMG_TEMP}" \
89+ -ov \
90+ -format UDZO \
91+ "${RELEASE_DIR}/${APP_NAME}-${VERSION}.dmg"
92+
93+ rm -rf "${DMG_TEMP}"
94+
95+ # Generate checksum
96+ cd ${RELEASE_DIR}
97+ shasum -a 256 "${APP_NAME}-${VERSION}.dmg" > "${APP_NAME}-${VERSION}.dmg.sha256"
98+
99+ - name : Create Release
100+ uses : softprops/action-gh-release@v1
101+ with :
102+ files : |
103+ releases/Zero-*.dmg
104+ releases/Zero-*.dmg.sha256
105+ draft : true
106+ prerelease : false
107+ generate_release_notes : true
108+ env :
109+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments