-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (91 loc) · 3.18 KB
/
release.yml
File metadata and controls
109 lines (91 loc) · 3.18 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
name: Release
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Swift
uses: swift-actions/setup-swift@v1
with:
swift-version: '5.9'
- name: Get version
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Build release
run: swift build -c release
- name: Create app bundle
run: |
VERSION=${{ steps.get_version.outputs.VERSION }}
APP_NAME="Zero"
BUILD_DIR=".build/release"
RELEASE_DIR="releases"
mkdir -p ${RELEASE_DIR}
# Create app bundle
APP_BUNDLE="${RELEASE_DIR}/${APP_NAME}.app"
mkdir -p "${APP_BUNDLE}/Contents/MacOS"
mkdir -p "${APP_BUNDLE}/Contents/Resources"
# Copy executable
cp "${BUILD_DIR}/${APP_NAME}" "${APP_BUNDLE}/Contents/MacOS/"
# Copy resources
cp -R "Sources/Zero/Resources/" "${APP_BUNDLE}/Contents/Resources/" || true
# Generate Info.plist
cat > "${APP_BUNDLE}/Contents/Info.plist" << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${APP_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.zero.ide</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${APP_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${VERSION}</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>14.0</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
EOF
# Sign app (ad-hoc)
codesign --force --deep --sign - "${APP_BUNDLE}" 2>/dev/null || true
# Create DMG
DMG_TEMP=$(mktemp -d)
cp -R "${APP_BUNDLE}" "${DMG_TEMP}/"
ln -s /Applications "${DMG_TEMP}/Applications"
hdiutil create \
-volname "${APP_NAME} ${VERSION}" \
-srcfolder "${DMG_TEMP}" \
-ov \
-format UDZO \
"${RELEASE_DIR}/${APP_NAME}-${VERSION}.dmg"
rm -rf "${DMG_TEMP}"
# Generate checksum
cd ${RELEASE_DIR}
shasum -a 256 "${APP_NAME}-${VERSION}.dmg" > "${APP_NAME}-${VERSION}.dmg.sha256"
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
releases/Zero-*.dmg
releases/Zero-*.dmg.sha256
draft: true
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}