-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (138 loc) · 5.69 KB
/
release.yml
File metadata and controls
154 lines (138 loc) · 5.69 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
148
149
150
151
152
153
154
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Set version from tag
env:
TAG: ${{ github.ref_name }}
run: |
VERSION="${TAG#v}"
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $VERSION" TickerBar/Info.plist
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $VERSION" TickerBar/Info.plist
- name: Build Release
run: |
xcodebuild -project TickerBar.xcodeproj \
-scheme TickerBar \
-configuration Release \
-derivedDataPath build \
CODE_SIGN_IDENTITY="-"
- name: Codesign app
run: |
codesign --force --deep --sign - \
build/Build/Products/Release/TickerBar.app
- name: Package app
run: |
cd build/Build/Products/Release
zip -r -y TickerBar.zip TickerBar.app
- name: Sign update with Sparkle
env:
SPARKLE_PRIVATE_KEY: ${{ secrets.SPARKLE_PRIVATE_KEY }}
run: |
SPARKLE_BIN="build/SourcePackages/artifacts/sparkle/Sparkle/bin"
if [ ! -f "$SPARKLE_BIN/sign_update" ]; then
xcodebuild -project TickerBar.xcodeproj \
-scheme TickerBar \
-configuration Release \
-derivedDataPath build \
-resolvePackageDependencies
SPARKLE_BIN="build/SourcePackages/artifacts/sparkle/Sparkle/bin"
fi
SIGNATURE=$("$SPARKLE_BIN/sign_update" \
build/Build/Products/Release/TickerBar.zip \
--ed-key-file <(echo "$SPARKLE_PRIVATE_KEY") \
| grep "sparkle:edSignature" | sed 's/.*sparkle:edSignature="\([^"]*\)".*/\1/')
echo "SPARKLE_SIGNATURE=$SIGNATURE" >> "$GITHUB_ENV"
ZIP_SIZE=$(stat -f%z build/Build/Products/Release/TickerBar.zip)
echo "ZIP_SIZE=$ZIP_SIZE" >> "$GITHUB_ENV"
- name: Generate appcast.xml
env:
TAG: ${{ github.ref_name }}
run: |
VERSION="${TAG#v}"
cat > appcast.xml << XMLEOF
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>TickerBar Updates</title>
<item>
<title>Version $VERSION</title>
<sparkle:version>$VERSION</sparkle:version>
<sparkle:shortVersionString>$VERSION</sparkle:shortVersionString>
<pubDate>$(date -R)</pubDate>
<enclosure
url="https://github.com/TerrifiedBug/TickerBar/releases/download/$TAG/TickerBar.zip"
sparkle:edSignature="$SPARKLE_SIGNATURE"
length="$ZIP_SIZE"
type="application/octet-stream" />
</item>
</channel>
</rss>
XMLEOF
- name: Extract release notes from CHANGELOG
env:
TAG: ${{ github.ref_name }}
run: |
VERSION="${TAG#v}"
# Extract the section for this version from CHANGELOG.md
# Falls back to auto-generated notes if version not found
awk "/^## \\[${VERSION}\\]/{found=1; next} /^## \\[/{if(found) exit} found{print}" CHANGELOG.md > release_notes.md
if [ ! -s release_notes.md ]; then
echo "See [CHANGELOG.md](https://github.com/TerrifiedBug/TickerBar/blob/master/CHANGELOG.md) for details." > release_notes.md
fi
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: build/Build/Products/Release/TickerBar.zip
body_path: release_notes.md
- name: Commit appcast.xml
env:
TAG: ${{ github.ref_name }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
cp appcast.xml /tmp/appcast.xml
git fetch origin master
git checkout -f master
cp /tmp/appcast.xml appcast.xml
git add appcast.xml
git commit -m "Update appcast.xml for $TAG" || echo "No changes to commit"
git push origin master
- name: Update Homebrew cask
continue-on-error: true
env:
TAG: ${{ github.ref_name }}
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
VERSION="${TAG#v}"
SHA256=$(shasum -a 256 build/Build/Products/Release/TickerBar.zip | awk '{print $1}')
git clone https://x-access-token:${GH_TOKEN}@github.com/TerrifiedBug/homebrew-tickerbar.git /tmp/homebrew-tap
cd /tmp/homebrew-tap
cat > Casks/tickerbar.rb << 'CASKEOF'
cask "tickerbar" do
version "REPLACE_VERSION"
sha256 "REPLACE_SHA256"
url "https://github.com/TerrifiedBug/TickerBar/releases/download/v#{version}/TickerBar.zip"
name "TickerBar"
desc "Lightweight macOS menu bar stock ticker"
homepage "https://github.com/TerrifiedBug/TickerBar"
app "TickerBar.app"
zap trash: [
"~/Library/Preferences/com.tickerbar.app.plist",
]
end
CASKEOF
sed -i '' "s/REPLACE_VERSION/$VERSION/" Casks/tickerbar.rb
sed -i '' "s/REPLACE_SHA256/$SHA256/" Casks/tickerbar.rb
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Casks/tickerbar.rb
git commit -m "Update TickerBar to $VERSION" || echo "No changes"
git push