Skip to content

Commit 9e8f710

Browse files
committed
Added workflows for the GTK package
1 parent 4569182 commit 9e8f710

File tree

4 files changed

+159
-2
lines changed

4 files changed

+159
-2
lines changed

.github/workflows/deploy_commit.yaml

+15-1
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,27 @@ jobs:
3131
fetch-depth: 0
3232

3333
- name: Generate PKGBUILDs
34-
run: python ./ci/gen_daemon_pkgbuild_git.py
34+
run: |
35+
python ./ci/gen_daemon_pkgbuild_git.py
36+
python ./ci/gen_gtk_pkgbuild_git.py
3537
3638
- name: Publish power-options-daemon-git to the AUR
3739
uses: KSXGitHub/[email protected]
3840
with:
3941
pkgname: power-options-daemon-git
4042
pkgbuild: ./pkgbuilds/daemon-git/PKGBUILD
43+
updpkgsums: true
44+
commit_username: ${{ secrets.AUR_USERNAME }}
45+
commit_email: ${{ secrets.AUR_EMAIL }}
46+
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
47+
commit_message: "Automated update on GitHub commit"
48+
force_push: 'true'
49+
- name: Publish power-options-gtk-git to the AUR
50+
uses: KSXGitHub/[email protected]
51+
with:
52+
pkgname: power-options-gtk-git
53+
pkgbuild: ./pkgbuilds/gtk-git/PKGBUILD
54+
updpkgsums: true
4155
commit_username: ${{ secrets.AUR_USERNAME }}
4256
commit_email: ${{ secrets.AUR_EMAIL }}
4357
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}

.github/workflows/deploy_release.yaml

+15-1
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,27 @@ jobs:
3131
fetch-depth: 0
3232

3333
- name: Generate PKGBUILDs
34-
run: python ./ci/gen_daemon_pkgbuild.py
34+
run: |
35+
python ./ci/gen_daemon_pkgbuild.py
36+
python ./ci/gen_gtk_pkgbuild.py
3537
3638
- name: Publish power-options-daemon to the AUR
3739
uses: KSXGitHub/[email protected]
3840
with:
3941
pkgname: power-options-daemon
4042
pkgbuild: ./pkgbuilds/daemon/PKGBUILD
43+
updpkgsums: true
44+
commit_username: ${{ secrets.AUR_USERNAME }}
45+
commit_email: ${{ secrets.AUR_EMAIL }}
46+
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
47+
commit_message: "Automated update on GitHub release"
48+
force_push: 'true'
49+
- name: Publish power-options-gtk to the AUR
50+
uses: KSXGitHub/[email protected]
51+
with:
52+
pkgname: power-options-gtk
53+
pkgbuild: ./pkgbuilds/gtk/PKGBUILD
54+
updpkgsums: true
4155
commit_username: ${{ secrets.AUR_USERNAME }}
4256
commit_email: ${{ secrets.AUR_EMAIL }}
4357
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}

ci/gen_gtk_pkgbuild.py

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import subprocess
2+
import os
3+
4+
def get_latest_tag():
5+
try:
6+
result = subprocess.run(['git', 'describe', '--tags', '--abbrev=0'], capture_output=True, text=True, check=True)
7+
return result.stdout.strip().removeprefix("v")
8+
except subprocess.CalledProcessError:
9+
raise RuntimeError("Failed to get the latest git tag")
10+
11+
def create_pkgbuild(pkgname, pkgver, url):
12+
pkgbuild_content = f"""# Maintainer: Alexander Karpukhin <[email protected]>
13+
14+
pkgname={pkgname}
15+
pkgver={pkgver}
16+
pkgrel=1
17+
pkgdesc="A gtk frontend for Power Options, a blazingly fast power management solution."
18+
arch=('x86_64')
19+
url={url}
20+
license=('MIT')
21+
conflicts=('power-options-gtk-git')
22+
depends=('power-options-daemon-git')
23+
makedepends=('cargo')
24+
source=("$pkgname-$pkgver.tar.gz::{url}/archive/v$pkgver.tar.gz")
25+
sha256sums=('SKIP')
26+
27+
prepare() {{
28+
export RUSTUP_TOOLCHAIN=stable
29+
cd "$srcdir/power-options/crates/frontend-gtk"
30+
cargo fetch --target "$(rustc -vV | sed -n 's/host: //p')"
31+
}}
32+
33+
build() {{
34+
export RUSTUP_TOOLCHAIN=stable
35+
cd "$srcdir/power-options/crates/frontend-gtk"
36+
cargo build --frozen --release
37+
}}
38+
39+
package() {{
40+
cd "$srcdir/power-options"
41+
42+
install -Dm755 "target/release/frontend-gtk" "$pkgdir/usr/bin/power-options-gtk"
43+
install -Dm755 "icon.png" "$pkgdir/usr/share/icons/power-options.png"
44+
install -Dm755 "install/power-options-gtk.desktop" "$pkgdir/usr/share/applications/power-options-gtk.desktop"
45+
}}
46+
"""
47+
return pkgbuild_content
48+
49+
def main():
50+
pkgname = "power-options-gtk"
51+
pkgver = get_latest_tag()
52+
url = "https://github.com/thealexdev23/power-options"
53+
54+
pkgbuild_content = create_pkgbuild(pkgname, pkgver, url)
55+
56+
os.makedirs('./pkgbuilds/gtk', exist_ok=True)
57+
58+
with open('./pkgbuilds/gtk/PKGBUILD', 'w') as file:
59+
file.write(pkgbuild_content)
60+
61+
if __name__ == "__main__":
62+
main()

ci/gen_gtk_pkgbuild_git.py

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import subprocess
2+
import os
3+
4+
def get_version():
5+
try:
6+
result = subprocess.run(
7+
['bash', '-c', 'echo $(git describe --tags --abbrev=0)r$(git rev-list $(git describe --tags --abbrev=0)..HEAD --count).$(git rev-parse --short=6 HEAD)'],
8+
capture_output=True,
9+
text=True, check=True
10+
)
11+
12+
return result.stdout.strip().removeprefix("v")
13+
except subprocess.CalledProcessError:
14+
raise RuntimeError("Failed to get the latest git tag")
15+
16+
def create_pkgbuild(pkgname, pkgver, url):
17+
pkgbuild_content = f"""# Maintainer: Alexander Karpukhin <[email protected]>
18+
19+
pkgname={pkgname}
20+
pkgver={pkgver}
21+
pkgrel=1
22+
pkgdesc="A gtk frontend for Power Options, a blazingly fast power management solution."
23+
arch=('x86_64')
24+
url={url}
25+
license=('MIT')
26+
conflicts=('power-options-gtk')
27+
depends=('power-options-daemon-git')
28+
makedepends=('cargo')
29+
source=("git+https://github.com/thealexdev23/power-options.git")
30+
sha256sums=('SKIP')
31+
32+
prepare() {{
33+
export RUSTUP_TOOLCHAIN=stable
34+
cd "$srcdir/power-options/crates/frontend-gtk"
35+
cargo fetch --target "$(rustc -vV | sed -n 's/host: //p')"
36+
}}
37+
38+
build() {{
39+
export RUSTUP_TOOLCHAIN=stable
40+
cd "$srcdir/power-options/crates/frontend-gtk"
41+
cargo build --frozen --release
42+
}}
43+
44+
package() {{
45+
cd "$srcdir/power-options"
46+
47+
install -Dm755 "target/release/frontend-gtk" "$pkgdir/usr/bin/power-options-gtk"
48+
install -Dm755 "icon.png" "$pkgdir/usr/share/icons/power-options.png"
49+
install -Dm755 "install/power-options-gtk.desktop" "$pkgdir/usr/share/applications/power-options-gtk.desktop"
50+
}}
51+
"""
52+
return pkgbuild_content
53+
54+
def main():
55+
pkgname = "power-options-gtk-git"
56+
pkgver = get_version()
57+
url = "https://github.com/thealexdev23/power-options"
58+
59+
pkgbuild_content = create_pkgbuild(pkgname, pkgver, url)
60+
61+
os.makedirs('./pkgbuilds/gtk-git', exist_ok=True)
62+
63+
with open('./pkgbuilds/gtk-git/PKGBUILD', 'w') as file:
64+
file.write(pkgbuild_content)
65+
66+
if __name__ == "__main__":
67+
main()

0 commit comments

Comments
 (0)