Skip to content

Commit 836b5ef

Browse files
committed
feat(ci): add GitHub Actions workflows for CI and automated releases
1 parent a53867d commit 836b5ef

2 files changed

Lines changed: 153 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build-and-test:
11+
runs-on: macos-14
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Swift
18+
uses: swift-actions/setup-swift@v1
19+
with:
20+
swift-version: '5.9'
21+
22+
- name: Cache Swift packages
23+
uses: actions/cache@v3
24+
with:
25+
path: .build
26+
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
27+
restore-keys: |
28+
${{ runner.os }}-spm-
29+
30+
- name: Build
31+
run: swift build
32+
33+
- name: Run tests
34+
run: swift test
35+
36+
- name: Build release
37+
run: swift build -c release
38+
39+
- name: Upload build artifacts
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: Zero-app
43+
path: .build/release/Zero
44+
retention-days: 7

.github/workflows/release.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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

Comments
 (0)