This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
178 lines (156 loc) · 7.22 KB
/
build.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: CI - Build Application
on:
push:
branches:
- 'main'
paths-ignore:
- 'LICENSE'
- '**.md'
pull_request:
release:
types: [created]
workflow_dispatch:
permissions:
write-all
jobs:
build-mac:
name: Build for macOS (Universal)
runs-on: macOS-13
steps:
- name: Checkout
uses: actions/checkout@v4
# - name: Set node
# uses: actions/setup-node@v4
# with:
# node-version: 20.x
# - name: Set up Homebrew
# id: set-up-homebrew
# uses: Homebrew/actions/setup-homebrew@master
# - name: Install dependencies
# run: |
# brew install graphicsmagick imagemagick
- name: Set up env.APP_CONF to Debug
if: github.event_name != 'release'
run: |
echo "APP_CONF=Debug" >> $GITHUB_ENV
- name: Set up env.APP_CONF to Release
if: github.event_name == 'release'
run: |
echo "APP_CONF=Release" >> $GITHUB_ENV
APP_VERSION=$(xcrun agvtool mvers -terse1)
APP_BUILD=$(xcrun agvtool vers -terse)
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
echo "APP_BUILD=$APP_BUILD" >> $GITHUB_ENV
- name: Build for macOS (Universal)
shell: bash
run: |
xcodebuild -project 'InjectGUI.xcodeproj' -scheme 'InjectGUI' -configuration '${{ env.APP_CONF }}' -destination 'platform=macOS' build -derivedDataPath 'build'
- name: Create DMG
shell: bash
run: |
hdiutil create -volname "InjectGUI" -srcfolder "build/Build/Products/${{ env.APP_CONF }}/InjectGUI.app" -ov -format UDZO "InjectGUI.dmg"
cp "InjectGUI.dmg" "$RUNNER_TEMP/InjectGUI.dmg"
- name: Upload DMG Artifact
id: upload-artifact
uses: actions/upload-artifact@v4
with:
name: InjectGUI
path: InjectGUI.dmg
- name: Upload DMG to GitHub Release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v2
with:
files: InjectGUI.dmg
############################
# Sparkle Appcast
############################
- name: Update Sparkle appcast
if: github.event_name == 'release'
env:
# SPARKLE_KEY: Sparkle EdDSA key exported from `generate_keys -x` as plain text
# SPARKLE_CHANNEL: Seperate dev builds from default channel, to be specified in [SPUUpdaterDelegate allowedChannelsForUpdater:]
# SPARKLE_DL_PREFIX: Prefix for the URL from where updates will be downloaded
# SPARKLE_LINK: CodeEdit Website
# https://github.com/wibus-wee/InjectGUI/releases/download/0.0.1-alpha.11/CodeEdit-9113dc5.dmg
# RELEASE_NOTES_PREFIX: The URL to prefix before an update link:
# https://codeedit.app/whats-new/raw/{v0.1.0} -- data in {} is inserted by sparkle
# RELEASE_NOTES_URL: The URL of the entire release notes page: https://codeedit.app/whats-new
SPARKLE_KEY: ${{ secrets.SPARKLE_KEY }}
# SPARKLE_CHANNEL: dev
SPARKLE_DL_PREFIX: "https://github.com/wibus-wee/InjectGUI/releases/download"
SPARKLE_LINK: "https://github.com/wibus-wee/InjectGUI"
APP_VERSION: ${{ env.APP_VERSION }}
APP_BUILD: ${{ env.APP_BUILD }}
# RELEASE_NOTES_URL: "https://codeedit.app/whats-new/"
# RELEASE_NOTES_PREFIX: "https://codeedit.app/sparkle/"
run: |
SPARKLE_BIN="$RUNNER_TEMP/build/SourcePackages/artifacts/sparkle/Sparkle/bin"
SPARKLE_ARCHIVE="$RUNNER_TEMP/Sparkle_Archive"
echo -n "$SPARKLE_KEY" | tee "$RUNNER_TEMP/sparkle_key"
mkdir "$SPARKLE_ARCHIVE"
cp "$RUNNER_TEMP/InjectGUI.dmg" "$SPARKLE_ARCHIVE"
SPARKLE_SIG=$("$SPARKLE_BIN/sign_update" --ed-key-file "$RUNNER_TEMP/sparkle_key" "$SPARKLE_ARCHIVE/InjectGUI.dmg" | cut -d\" -f2)
echo "<!DOCTYPE>" > "$SPARKLE_ARCHIVE/InjectGUI.html" # Need a blank html doc with the DOCTYPE tag to trick sparkle into loading our remote release notes.
"$SPARKLE_BIN/generate_appcast" --ed-key-file "$RUNNER_TEMP/sparkle_key" --download-url-prefix "${{ env.SPARKLE_DL_PREFIX }}/v${{ env.APP_VERSION }}/" --link "$SPARKLE_LINK" --maximum-deltas 0 "$SPARKLE_ARCHIVE"
- name: Upload Sparkle Appcast
if: github.event_name == 'release'
uses: softprops/action-gh-release@v2
with:
files: "${{ RUNNER.TEMP }}/Sparkle_Archive/appcast.xml"
- name: Upload Sparkle Artifact
if: github.event_name == 'release'
uses: actions/upload-artifact@v4
with:
name: appcast.xml
path: "${{ RUNNER.TEMP }}/Sparkle_Archive/appcast.xml"
- name: Find Comment
if: github.event_name == 'pull_request'
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'InjectGUI'
- name: Gen Previous Builds List
if: github.event_name == 'pull_request'
run: |
shas_and_links=$(echo "${{ steps.fc.outputs.comment-body }}" | sed -n 's/.*\[\([^!][^]]*\)\].*/\1/p')
result_list=""
IFS=',' # 设置内部字段分隔符为逗号
for entry in $shas_and_links; do
sha=$(echo "$entry" | cut -d';' -f1)
link=$(echo "$entry" | cut -d';' -f2)
result_list+="<sup><li><a href='${link}'>${sha}</a></li></sup>"
done
echo "PREVIOUS_BUILDS=${result_list}" >> $GITHUB_ENV
- name: Add new build to Previous Builds List
if: github.event_name == 'pull_request'
run: |
new_sha="${{github.sha}}"
new_link="${{ steps.upload-artifact.outputs.artifact-id }}"
new_link="https://github.com/wibus-wee/InjectGUI/actions/runs/${{ github.run_id }}/artifacts/${new_link}"
comment_body="${{ steps.fc.outputs.comment-body }}"
if [ -z "$new_link" ]; then
echo "Artifact URL is empty. Skipping update."
else
shas_and_links=$(echo "$comment_body" | sed -n 's/.*\[\([^!][^]]*\)\].*/\1/p')
shas_and_links="${shas_and_links},[${new_sha};${new_link}]"
echo "NEW_COMMENT_LIST=${shas_and_links}" >> $GITHUB_ENV
fi
- name: Create Pull Request Comment
if: github.event_name == 'pull_request'
uses: peter-evans/create-or-update-comment@v4
with:
edit-mode: replace
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Hi, thanks for your contribution!
**InjectGUI** (${{ github.sha }}) has been built and is available for download to test. (Based on PR ${{ github.event.pull_request.number }})
You can download the latest artifact from here: https://github.com/wibus-wee/InjectGUI/actions/runs/${{ github.run_id }}/artifacts/${{ steps.upload-artifact.outputs.artifact-id }}
> [!WARNING]
> This is a PR build and may not be stable. It's only for testing purposes.
---
<!--${{ env.NEW_COMMENT_LIST }}-->
<sup>Previous builds:</sup>
${{ env.PREVIOUS_BUILDS }}