-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (131 loc) · 5.05 KB
/
Copy pathrelease.yml
File metadata and controls
147 lines (131 loc) · 5.05 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
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
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
release:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
with:
# Full history required so git log PREV_TAG..TAG includes all release commits.
fetch-depth: 0
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
Pods
Carthage/Build
~/Library/Caches/Carthage
key: ${{ runner.os }}-deps-${{ hashFiles('Podfile.lock', 'Cartfile.resolved') }}
restore-keys: |
${{ runner.os }}-deps-
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
bundler-cache: false
- name: Install tools
run: |
gem install cocoapods
brew install carthage
- name: Install dependencies
run: make setup
- name: Import code signing certificate
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
chmod +x scripts/ci-setup-signing.sh
./scripts/ci-setup-signing.sh
- name: Set version from tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $VERSION" ViMac-Swift/Info.plist
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${{ github.run_number }}" ViMac-Swift/Info.plist
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
echo "ZIP_NAME=Vimac-${VERSION}-macOS.zip" >> "$GITHUB_ENV"
- name: Build, sign, and notarize release
env:
CI: "true"
NOTARY_API_KEY_ID: ${{ secrets.NOTARY_API_KEY_ID }}
NOTARY_API_ISSUER_ID: ${{ secrets.NOTARY_API_ISSUER_ID }}
NOTARY_API_KEY_BASE64: ${{ secrets.NOTARY_API_KEY_BASE64 }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
ZIP_NAME: ${{ env.ZIP_NAME }}
run: |
chmod +x scripts/release-package.sh
./scripts/release-package.sh
- name: Package app and generate Sparkle appcast
env:
SPARKLE_PRIVATE_KEY: ${{ secrets.SPARKLE_PRIVATE_KEY }}
run: |
set -euo pipefail
ZIP_PATH="sparkle-releases/${ZIP_NAME}"
test -f "$ZIP_PATH"
PREV_TAG=$(git describe --tags --abbrev=0 "${GITHUB_REF_NAME}^" 2>/dev/null || true)
LOG_RANGE="${GITHUB_REF_NAME}"
if [ -n "$PREV_TAG" ]; then
LOG_RANGE="${PREV_TAG}..${GITHUB_REF_NAME}"
fi
{
echo "## Vimac v${VERSION}"
echo ""
echo "Signed and notarized build for macOS (Apple Silicon and Intel)."
echo ""
echo "Install: unzip, move **Vimac.app** to **Applications**, then open from there."
echo ""
if [ -n "$PREV_TAG" ]; then
echo "Changes since ${PREV_TAG}:"
echo ""
git log "${LOG_RANGE}" --no-merges --pretty=format:"- %s"
else
git log "${LOG_RANGE}" --no-merges --pretty=format:"- %s"
fi
} > release-notes.md
HTML_PATH="sparkle-releases/Vimac-${VERSION}-macOS.html"
{
echo '<!DOCTYPE html>'
echo '<html><head><meta charset="utf-8">'
echo "<title>Vimac v${VERSION}</title></head><body>"
echo "<h2>Vimac v${VERSION}</h2>"
echo "<ul>"
git log "${LOG_RANGE}" --no-merges --pretty=format:"<li>%s</li>"
echo "</ul></body></html>"
} > "$HTML_PATH"
./Pods/Sparkle/bin/generate_appcast \
-s "$SPARKLE_PRIVATE_KEY" \
--download-url-prefix "https://github.com/kaiwen-wang/vimac/releases/download/${GITHUB_REF_NAME}/" \
--release-notes-url-prefix "https://github.com/kaiwen-wang/vimac/releases/download/${GITHUB_REF_NAME}/" \
-o appcast.xml \
sparkle-releases/
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: "v${{ env.VERSION }}"
body_path: release-notes.md
files: |
sparkle-releases/${{ env.ZIP_NAME }}
sparkle-releases/Vimac-${{ env.VERSION }}-macOS.html
draft: false
prerelease: ${{ contains(github.ref_name, '-') }}
- name: Publish appcast to master
run: |
set -euo pipefail
cp appcast.xml /tmp/appcast.xml
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git fetch origin master
git checkout master
cp /tmp/appcast.xml appcast.xml
git add appcast.xml
if git diff --staged --quiet; then
echo "No appcast changes to commit"
exit 0
fi
git commit -m "Update appcast for v${VERSION}"
git push origin master