Skip to content

Commit 0347b81

Browse files
committed
feat: add release workflow and homebrew formula
Adds GitHub Actions workflow to automate releases with source tarballs and Homebrew formula updates. When a version tag is pushed, the workflow creates a GitHub release, updates the formula, and syncs to homebrew-bucket.
1 parent d7fcef4 commit 0347b81

3 files changed

Lines changed: 161 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v6
17+
with:
18+
fetch-depth: 0
19+
fetch-tags: true
20+
21+
- name: Install dependencies
22+
run: |
23+
sudo apt-get update
24+
sudo apt-get install -y meson ninja-build gettext appstream desktop-file-utils libglib2.0-dev
25+
26+
- name: Get version from tag
27+
id: version
28+
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
29+
30+
- name: Create source tarball
31+
run: |
32+
meson setup build
33+
meson dist -C build --no-tests --include-subprojects
34+
35+
# Find the generated tarball
36+
TARBALL=$(ls build/meson-dist/*.tar.xz)
37+
38+
# Rename to standard format
39+
mv "$TARBALL" "awakeonlan-${{ steps.version.outputs.version }}.tar.xz"
40+
41+
- name: Calculate SHA256
42+
id: sha256
43+
run: |
44+
HASH=$(sha256sum awakeonlan-${{ steps.version.outputs.version }}.tar.xz | awk '{print $1}')
45+
echo "hash=$HASH" >> $GITHUB_OUTPUT
46+
echo "SHA256: $HASH"
47+
48+
- name: Generate release notes
49+
id: release_notes
50+
run: |
51+
PREVIOUS_TAG=$(git tag --sort=-version:refname | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | head -2 | tail -1)
52+
53+
if [ -z "$PREVIOUS_TAG" ]; then
54+
PREVIOUS_TAG=$(git rev-list --max-parents=0 HEAD)
55+
fi
56+
57+
echo "Comparing $PREVIOUS_TAG..HEAD"
58+
59+
{
60+
echo 'notes<<EOF'
61+
git log --oneline --no-decorate "$PREVIOUS_TAG..HEAD" \
62+
| grep -v '^[a-f0-9]\+ chore' \
63+
| sed 's/^\([a-f0-9]\+\) \(.*\)/- \2 (\1)/' \
64+
|| echo "- Initial release"
65+
echo 'EOF'
66+
} >> $GITHUB_OUTPUT
67+
68+
- name: Create GitHub release
69+
env:
70+
GH_TOKEN: ${{ github.token }}
71+
run: |
72+
gh release create ${{ steps.version.outputs.version }} \
73+
awakeonlan-${{ steps.version.outputs.version }}.tar.xz \
74+
--title "Awake on LAN ${{ steps.version.outputs.version }}" \
75+
--notes "${{ steps.release_notes.outputs.notes }}"
76+
77+
- name: Update Homebrew formula
78+
run: |
79+
sed -i "s/version \".*\"/version \"${{ steps.version.outputs.version }}\"/" Formula/awakeonlan.rb
80+
sed -i "s/sha256 \".*\"/sha256 \"${{ steps.sha256.outputs.hash }}\"/" Formula/awakeonlan.rb
81+
CONTENT=$(base64 -w 0 < Formula/awakeonlan.rb)
82+
MAIN_OID=$(gh api graphql -f query='{ repository(owner:"logonoff", name:"awake-on-lan") { ref(qualifiedName:"refs/heads/main") { target { oid } } } }' --jq '.data.repository.ref.target.oid')
83+
jq -n \
84+
--arg oid "$MAIN_OID" \
85+
--arg content "$CONTENT" \
86+
--arg version "${{ steps.version.outputs.version }}" \
87+
'{
88+
query: "mutation($input: CreateCommitOnBranchInput!) { createCommitOnBranch(input: $input) { commit { oid } } }",
89+
variables: {
90+
input: {
91+
branch: { repositoryNameWithOwner: "logonoff/awake-on-lan", branchName: "main" },
92+
expectedHeadOid: $oid,
93+
message: { headline: ("chore: update formula to " + $version) },
94+
fileChanges: { additions: [{ path: "Formula/awakeonlan.rb", contents: $content }] }
95+
}
96+
}
97+
}' | gh api graphql --input -
98+
git checkout -- Formula/awakeonlan.rb
99+
git pull --ff-only origin main
100+
env:
101+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102+
103+
- name: Sync homebrew-bucket
104+
run: |
105+
gh api repos/logonoff/homebrew-bucket/dispatches \
106+
-f event_type=sync
107+
env:
108+
GH_TOKEN: ${{ secrets.BUCKET_PAT }}
109+
110+
- name: Check if next branch can be fast-forwarded
111+
id: check-next
112+
run: |
113+
if git ls-remote --exit-code origin next &>/dev/null; then
114+
git fetch origin next
115+
if git merge-base --is-ancestor origin/next HEAD; then
116+
echo "can_ff=true" >> "$GITHUB_OUTPUT"
117+
fi
118+
fi
119+
120+
- name: Fast-forward next branch
121+
if: steps.check-next.outputs.can_ff == 'true'
122+
run: git push origin HEAD:next
123+
env:
124+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Formula/awakeonlan.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
class Awakeonlan < Formula
2+
desc "Simple libadwaita-based Wake on LAN application for waking computers remotely"
3+
homepage "https://github.com/logonoff/awake-on-lan"
4+
version "0.0.0"
5+
url "https://github.com/logonoff/awake-on-lan/releases/download/#{version}/awakeonlan-#{version}.tar.xz"
6+
sha256 "0000000000000000000000000000000000000000000000000000000000000000"
7+
license "GPL-3.0-or-later"
8+
9+
depends_on "desktop-file-utils" => :build
10+
depends_on "gettext" => :build
11+
depends_on "meson" => :build
12+
depends_on "ninja" => :build
13+
depends_on "pkgconf" => :build
14+
15+
depends_on "adwaita-icon-theme"
16+
depends_on "glib"
17+
depends_on "gtk4"
18+
depends_on "libadwaita"
19+
depends_on "python@3.13"
20+
21+
def install
22+
system "meson", "setup", "build", *std_meson_args
23+
system "meson", "compile", "-C", "build", "--verbose"
24+
system "meson", "install", "-C", "build"
25+
rm share/"glib-2.0/schemas/gschemas.compiled"
26+
end
27+
28+
def post_install
29+
system Formula["glib"].opt_bin/"glib-compile-schemas", HOMEBREW_PREFIX/"share/glib-2.0/schemas"
30+
system Formula["gtk4"].opt_bin/"gtk4-update-icon-cache", "-f", "-t", HOMEBREW_PREFIX/"share/icons/hicolor"
31+
end
32+
33+
test do
34+
assert_predicate bin/"awakeonlan", :executable?
35+
end
36+
end

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project('awakeonlan',
2-
version: '0.5.1',
2+
version: '0.5.2',
33
meson_version: '>= 0.62.0',
44
default_options: [ 'warning_level=2', 'werror=false', ],
55
)

0 commit comments

Comments
 (0)