-
-
Notifications
You must be signed in to change notification settings - Fork 3
155 lines (131 loc) · 5.4 KB
/
release.yml
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Build and Release XCFramework
on:
push:
branches:
- main
# Add permissions block to allow writing
permissions:
contents: write
pull-requests: write
jobs:
check-version:
runs-on: ubuntu-latest
outputs:
current: ${{ steps.semver.outputs.current }}
next: ${{ steps.semver.outputs.next }}
should_build: ${{ steps.check.outputs.should_build }}
steps:
- name: Get Next Version
id: semver
uses: ietf-tools/semver-action@v1
with:
token: ${{ secrets.GH_PAT }}
prefix: 'v'
branch: main
patchList: chore
noVersionBumpBehavior: silent
- name: Check Version Bump
id: check
run: |
if [ "${{ steps.semver.outputs.next }}" = "${{ steps.semver.outputs.current }}" ]; then
echo "No version bump needed. Current version: ${{ steps.semver.outputs.current }}"
echo "should_build=false" >> $GITHUB_OUTPUT
else
echo "Version bump needed from ${{ steps.semver.outputs.current }} to ${{ steps.semver.outputs.next }}"
echo "should_build=true" >> $GITHUB_OUTPUT
fi
build-and-release:
needs: check-version
if: needs.check-version.outputs.should_build == 'true'
runs-on: macos-latest
steps:
- name: Create parent directory
run: |
mkdir bugsplat-workspace
cd bugsplat-workspace
- name: Install the Apple certificate
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
- name: Clone repositories
working-directory: bugsplat-workspace
run: |
# Clone bugsplat-apple with token for push access
git clone https://${{ secrets.GH_PAT }}@github.com/BugSplat-Git/bugsplat-apple.git
git clone /~https://github.com/BugSplat-Git/HockeySDK-Mac
git clone /~https://github.com/BugSplat-Git/HockeySDK-iOS
git clone /~https://github.com/BugSplat-Git/plCrashReporter
- name: Set up Xcode 15.4
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'
- name: Build PlCrashReporter
working-directory: bugsplat-workspace/plCrashReporter
run: |
./makeXCFramework.sh
- name: Build HockeySDK-Mac
working-directory: bugsplat-workspace/HockeySDK-Mac
run: |
./makeXCFramework.sh
- name: Build HockeySDK-iOS
working-directory: bugsplat-workspace/HockeySDK-iOS
run: |
./makeXCFramework.sh
- name: Build BugSplat
working-directory: bugsplat-workspace/bugsplat-apple
run: |
./makeXCFramework.sh
# Create zip archive of the framework
cd xcframeworks
zip -r BugSplat.xcframework.zip BugSplat.xcframework
- name: Update Package.swift
working-directory: bugsplat-workspace/bugsplat-apple
run: |
# Calculate checksum
CHECKSUM=$(swift package compute-checksum xcframeworks/BugSplat.xcframework.zip)
# Create a temporary file with the new content
sed "s|url: \".*\"|url: \"/~https://github.com/BugSplat-Git/bugsplat-apple/releases/download/${{ needs.check-version.outputs.next }}/BugSplat.xcframework.zip\"|" Package.swift > Package.swift.tmp
sed "s|checksum: \".*\"|checksum: \"${CHECKSUM}\"|" Package.swift.tmp > Package.swift
rm Package.swift.tmp
# Commit and push the updated Package.swift
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add Package.swift
git commit -m "chore: release ${{ needs.check-version.outputs.next }}"
git push origin HEAD:main
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: bugsplat-workspace/bugsplat-apple/xcframeworks/BugSplat.xcframework.zip
name: Release ${{ needs.check-version.outputs.next }}
body: |
Release of BugSplat.xcframework version ${{ needs.check-version.outputs.next }}
This release contains:
- iOS framework
- iOS Simulator framework
- macOS framework
Swift Package Manager:
```swift
dependencies: [
.package(url: "/~https://github.com/BugSplat-Git/bugsplat-apple.git", from: "${{ needs.check-version.outputs.next }}")
]
```
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}