-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (121 loc) · 5.35 KB
/
release.yml
File metadata and controls
147 lines (121 loc) · 5.35 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
permissions:
contents: write
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_16.1.app
- name: Get version
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Run tests
run: swift test
- name: Build and Sign app bundle
run: |
chmod +x build-app.sh
./build-app.sh
- name: Create app archive
run: |
cd .build/release
tar -czf ntfy-macos-${{ steps.version.outputs.VERSION }}.tar.gz ntfy-macos.app
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: .build/release/ntfy-macos-${{ steps.version.outputs.VERSION }}.tar.gz
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update Homebrew tap
env:
TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}
VERSION: ${{ steps.version.outputs.VERSION }}
run: |
if [ -z "$TAP_GITHUB_TOKEN" ]; then
echo "TAP_GITHUB_TOKEN not set, skipping Homebrew tap update"
exit 0
fi
SOURCE_URL="https://github.com/${{ github.repository }}/archive/refs/tags/${VERSION}.tar.gz"
wget -q -O "source.tar.gz" "${SOURCE_URL}"
SHA256=$(shasum -a 256 "source.tar.gz" | awk '{print $1}')
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git clone https://github.com/laurentftech/homebrew-ntfy-macos.git tap
cd tap
cat > Formula/ntfy-macos.rb << 'FORMULA'
class NtfyMacos < Formula
desc "Native macOS CLI notifier and automation agent for ntfy"
homepage "https://github.com/laurentftech/ntfy-macos"
url "SOURCE_URL_PLACEHOLDER"
sha256 "SHA256_PLACEHOLDER"
license "MIT"
version "VERSION_PLACEHOLDER"
head "https://github.com/laurentftech/ntfy-macos.git", branch: "main"
depends_on xcode: ["15.0", :build]
depends_on :macos
def install
system "swift", "build", "-c", "release", "--disable-sandbox"
app_name = "ntfy-macos"
app_bundle = "#{app_name}.app"
build_dir = ".build/release"
mkdir_p "#{build_dir}/#{app_bundle}/Contents/MacOS"
mkdir_p "#{build_dir}/#{app_bundle}/Contents/Resources"
cp "#{build_dir}/#{app_name}", "#{build_dir}/#{app_bundle}/Contents/MacOS/"
cp "Resources/Info.plist", "#{build_dir}/#{app_bundle}/Contents/"
cp "Resources/ntfy-macos.icns", "#{build_dir}/#{app_bundle}/Contents/Resources/"
system "codesign", "--force", "--deep", "--sign", "-", "#{build_dir}/#{app_bundle}"
prefix.install "#{build_dir}/#{app_bundle}"
bin.install_symlink prefix/"#{app_bundle}/Contents/MacOS/#{app_name}"
end
service do
run [opt_prefix/"ntfy-macos.app/Contents/MacOS/ntfy-macos", "serve"]
keep_alive crashed: true
log_path var/"log/ntfy-macos/stdout.log"
error_log_path var/"log/ntfy-macos/stderr.log"
end
def caveats
<<~EOS
To add ntfy-macos to Launchpad:
sudo ln -sf #{opt_prefix}/ntfy-macos.app /Applications/
EOS
end
test do
system bin/"ntfy-macos", "help"
end
end
FORMULA
sed -i '' "s|SOURCE_URL_PLACEHOLDER|${SOURCE_URL}|g" Formula/ntfy-macos.rb
sed -i '' "s|SHA256_PLACEHOLDER|${SHA256}|g" Formula/ntfy-macos.rb
sed -i '' "s|VERSION_PLACEHOLDER|${VERSION}|g" Formula/ntfy-macos.rb
git add Formula/ntfy-macos.rb
git commit -m "Update ntfy-macos to ${VERSION}"
git push https://x-access-token:${TAP_GITHUB_TOKEN}@github.com/laurentftech/homebrew-ntfy-macos.git main
- name: Notify via ntfy
if: always()
env:
NTFY_TOPIC: ${{ secrets.NTFY_RELEASE_TOPIC }}
VERSION: ${{ steps.version.outputs.VERSION }}
run: |
if [ -z "$NTFY_TOPIC" ]; then
echo "NTFY_RELEASE_TOPIC not set, skipping notification"
exit 0
fi
if [ "${{ job.status }}" = "success" ]; then
curl -s -X POST "https://ntfy.sh/$NTFY_TOPIC" \
-H "Title: ntfy-macos ${VERSION} released" \
-H "Priority: 3" \
-H "Tags: tada,rocket" \
-d "Release ${VERSION} published successfully. Homebrew tap updated."
else
curl -s -X POST "https://ntfy.sh/$NTFY_TOPIC" \
-H "Title: ntfy-macos ${VERSION} release failed" \
-H "Priority: 4" \
-H "Tags: x,warning" \
-d "Release workflow failed for ${VERSION}. Check: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
fi