-
Notifications
You must be signed in to change notification settings - Fork 121
222 lines (188 loc) · 9.2 KB
/
main.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
name: CI
on:
- push
- pull_request
- workflow_dispatch
jobs:
CI:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: build/SourcePackages
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-
- name: Install Dependencies
run: |
brew install create-dmg swiftlint
python -m pip install pycountry
env:
HOMEBREW_NO_INSTALL_CLEANUP: 1
HOMEBREW_NO_AUTO_UPDATE: 1
- name: Manage Version
if: (github.event_name == 'push' && github.ref_name == 'master') || github.event_name == 'workflow_dispatch'
run: |
git fetch --prune --unshallow --tags
GIT_SHA="$(git rev-parse --short HEAD)"
CUR_TAG="$(git tag -l | grep -i 'alpha' | tail -1)"
eval $(grep -m 1 "MARKETING_VERSION =" HeliPort.xcodeproj/project.pbxproj | tr -d ';' | tr -d '\t' | tr -d " ")
if [[ "$GITHUB_EVENT_NAME" != 'workflow_dispatch' ]]; then
sed -i '' -e "s/CURRENT_PROJECT_VERSION =.*/CURRENT_PROJECT_VERSION = \"\$(MARKETING_VERSION)-alpha-${GIT_SHA}\";/g" HeliPort.xcodeproj/project.pbxproj
else
sed -i '' -e "s/CURRENT_PROJECT_VERSION =.*/CURRENT_PROJECT_VERSION = \"\$(MARKETING_VERSION)-stable-${GIT_SHA}\";/g" HeliPort.xcodeproj/project.pbxproj
fi
echo "VER=$MARKETING_VERSION" >> $GITHUB_ENV
echo "SHORT_SHA=$GIT_SHA" >> $GITHUB_ENV
if [[ -z $CUR_TAG ]]; then
echo "OLD_PRE_TAG=NULL" >> $GITHUB_ENV
else
echo "OLD_PRE_TAG=$CUR_TAG">> $GITHUB_ENV
fi
shell: zsh {0}
- name: Lint
run: swiftlint lint --reporter github-actions-logging
- name: i18n Stats
run: |
import os, sys, json
from pycountry import languages
from collections import defaultdict
def get_lang_name(code):
if '-' in code:
code = code.split('-')[0]
lang = languages.get(alpha_2=code)
return lang.name if lang else code
def write_stats(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
data = json.load(file)
if data["version"] != "1.0":
raise ValueError(f"Unsupported version: {data['version']}")
strings = data["strings"]
localizations = defaultdict(int)
for string in strings.values():
for lang_code in string["localizations"].keys():
localizations[lang_code] += 1
summary = ["## i18n Stats", "",
"| Language | Code | Completion |",
"| :-- | :-- | --: |"]
for lang_code, count in localizations.items():
summary.append(f"| {get_lang_name(lang_code)} | {lang_code} | {(count / len(strings) * 100):.2f}% |")
summary.extend(["",
f"- **Total Languages**: {len(localizations)}",
f"- **Total Strings**: {len(strings)}"])
with open(os.environ['GITHUB_STEP_SUMMARY'], 'a') as f:
f.write('\n'.join(summary) + '\n')
try:
write_stats("HeliPort/Appearance/Localizable.xcstrings")
except Exception as e:
print(f"::error::{str(e)}")
sys.exit(1)
shell: python
- name: Debug Build
if: github.event_name != 'workflow_dispatch'
run: |
set -o pipefail && xcodebuild ARCHS=x86_64 ONLY_ACTIVE_ARCH=NO -scheme HeliPort -configuration Debug -derivedDataPath build -disableAutomaticPackageResolution CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcbeautify --renderer terminal
- name: Release Build
run: |
set -o pipefail && xcodebuild ARCHS=x86_64 ONLY_ACTIVE_ARCH=NO -scheme HeliPort -configuration Release -derivedDataPath build -disableAutomaticPackageResolution CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcbeautify
- name: Create Disk Image
if: (github.event_name == 'push' && github.ref_name == 'master') || github.event_name == 'workflow_dispatch'
run: |
XCBUILD_PATH="build/Build/Products/Release"
cp LICENSE $XCBUILD_PATH
cd $XCBUILD_PATH
curl -sLO https://openintelwireless.github.io/HeliPort/dmg/VolumeIcon.icns
curl -sLO https://openintelwireless.github.io/HeliPort/dmg/dmg-background.tiff
create-dmg \
--volname "HeliPort" \
--volicon "VolumeIcon.icns" \
--background "dmg-background.tiff" \
--window-pos 200 120 \
--window-size 660 420 \
--text-size 12 \
--eula "LICENSE" \
--icon-size 160 \
--icon "HeliPort.app" 180 170 \
--hide-extension "HeliPort.app" \
--app-drop-link 480 170 \
"HeliPort.dmg" \
"./HeliPort.app"
cd -
mkdir Artifacts
cp -R ${XCBUILD_PATH}/*.dmg Artifacts
- name: Setup Prerelease Variables
if: github.event_name == 'push' && github.ref_name == 'master'
run: |
echo "REL_TAG=v${VER}-alpha" >> $GITHUB_ENV
echo "IS_PRE=true" >> $GITHUB_ENV
echo '### Disclaimer:' >> ReleaseNotes.md
echo '***This alpha version is for testing only.***' >> ReleaseNotes.md
echo 'It is not ready for daily use and we do not guarantee its usability.' >> ReleaseNotes.md
echo 'If you discovered an issue and you do not have debugging skills, please check with the [Gitter Chat Room](https://gitter.im/OpenIntelWireless/itlwm) in advance before opening an Issue.' >> ReleaseNotes.md
- name: Setup Release Variables
if: github.event_name == 'workflow_dispatch'
run: |
echo "REL_TAG=v${VER}" >> $GITHUB_ENV
echo "IS_PRE=false" >> $GITHUB_ENV
- name: Generate Release Notes
if: (github.event_name == 'push' && github.ref_name == 'master') || github.event_name == 'workflow_dispatch'
run: |
echo '### The latest updates are:' >> ReleaseNotes.md
git log -"$(git rev-list --count $(git rev-list -1 "$(git tag -l | grep -v 'alpha' | tail -1)")..HEAD)" --format="- %H %s" | grep -v '.git\|Merge\|yml\|CI' | sed '/^$/d' >> ReleaseNotes.md
- name: Delete Old Prerelease
if: (github.event_name == 'push' && github.ref_name == 'master') || github.event_name == 'workflow_dispatch'
run: gh release delete ${{ env.OLD_PRE_TAG }} --cleanup-tag
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Sparkle Appcast
if: github.event_name == 'workflow_dispatch'
run: |
REPO_COMMIT_URL='https://github.com/OpenIntelWireless/HeliPort/commit/'
INDENT=' '
PART1="${INDENT}<li><a class=\"commit-link\" data-hovercard-type=\"commit\" data-hovercard-url=\"${REPO_COMMIT_URL}"
PART2="/hovercard\" href=\"${REPO_COMMIT_URL}"
PART3="\"><tt>"
PART4='</tt></a> '
PART5='</li>'
CHANGELOG="$(git log -"$(git rev-list --count $(git rev-list -1 "$(git tag -l | grep -v 'alpha' | tail -1)")..HEAD)" --format="${PART1}%H${PART2}%H${PART3}%h${PART4}%s${PART5}" | cat)"
SPARKLE_BIN='./build/SourcePackages/artifacts/sparkle/Sparkle/bin'
PUBDATE="$(date +"%a, %d %b %Y %T %z")"
APPCAST=(
'<?xml version="1.0" standalone="yes"?>'
'<rss xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" version="2.0">'
' <channel>'
' <title>HeliPort</title>'
' <item>'
" <title>${VER}</title>"
" <pubDate>${PUBDATE}</pubDate>"
' <description><![CDATA['
' <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Primer/19.4.0/primer.min.css"><meta charset="UTF-8"><div class="markdown-body"><h3>The latest updates are:</h3><ul>'
"${CHANGELOG}"
' </ul></div>'
' ]]>'
' </description>'
' <sparkle:minimumSystemVersion>10.12</sparkle:minimumSystemVersion>'
" <enclosure url=\"https://github.com/OpenIntelWireless/HeliPort/releases/latest/download/HeliPort.dmg\" sparkle:version=\"${VER}-stable-${SHORT_SHA}\" sparkle:shortVersionString=\"${VER}\" type=\"application/octet-stream\" $($SPARKLE_BIN/sign_update -s ${SPARKLE_KEY} ./Artifacts/HeliPort.dmg)/>"
' </item>'
' </channel>'
'</rss>'
)
for appcast in "${APPCAST[@]}"; do
echo "${appcast}" >> ./Artifacts/appcast.xml
done
shell: zsh {0}
env:
SPARKLE_KEY: ${{ secrets.SPARKLE_KEY }}
- name: Publish GitHub Release
if: ((github.event_name == 'push' && github.ref_name == 'master') || github.event_name == 'workflow_dispatch') && contains(github.event.head_commit.message, 'Bump version') == false
uses: ncipollo/release-action@v1
with:
allowUpdates: true
replacesArtifacts: true
prerelease: ${{ env.IS_PRE }}
bodyFile: ReleaseNotes.md
artifacts: "./Artifacts/*"
tag: ${{ env.REL_TAG }}
token: ${{ secrets.GITHUB_TOKEN }}