-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (66 loc) · 2.27 KB
/
swift.yml
File metadata and controls
80 lines (66 loc) · 2.27 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
name: Build & Release
on:
workflow_dispatch:
inputs:
version:
description: "Release version (e.g. 1.0.0)"
required: true
default: "1.0.0"
push:
tags:
- "v*"
jobs:
build:
runs-on: macos-15
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Set version from tag or input
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
VERSION="${GITHUB_REF_NAME#v}"
else
VERSION="${{ github.event.inputs.version }}"
fi
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Build release binary
run: swift build -c release
- name: Create app bundle
run: |
APP_NAME="Dispres"
BUNDLE_DIR="$APP_NAME.app"
CONTENTS="$BUNDLE_DIR/Contents"
MACOS="$CONTENTS/MacOS"
RESOURCES="$CONTENTS/Resources"
mkdir -p "$MACOS" "$RESOURCES"
cp ".build/release/$APP_NAME" "$MACOS/$APP_NAME"
cp "Sources/Dispres/Resources/Info.plist" "$CONTENTS/Info.plist"
# Stamp version into Info.plist
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $VERSION" "$CONTENTS/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $VERSION" "$CONTENTS/Info.plist"
if [ -f "AppIcon.icns" ]; then
cp "AppIcon.icns" "$RESOURCES/AppIcon.icns"
fi
codesign --force --sign - "$BUNDLE_DIR"
- name: Create DMG
run: |
hdiutil create -volname "Dispres" \
-srcfolder Dispres.app \
-ov -format UDZO \
"Dispres-$VERSION-macOS.dmg"
- name: Create ZIP
run: |
ditto -c -k --sequesterRsrc --keepParent Dispres.app "Dispres-$VERSION-macOS.zip"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_type == 'tag' && github.ref_name || format('v{0}', env.VERSION) }}
name: Dispres v${{ env.VERSION }}
draft: false
generate_release_notes: true
files: |
Dispres-${{ env.VERSION }}-macOS.dmg
Dispres-${{ env.VERSION }}-macOS.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}