Skip to content

Unify log location and skip stdout in service mode #32

Unify log location and skip stdout in service mode

Unify log location and skip stdout in service mode #32

Workflow file for this run

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: 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