Skip to content

Commit 6f39c4a

Browse files
feat(publish): build with github actions
1 parent ece7917 commit 6f39c4a

4 files changed

Lines changed: 67 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Build and Release DEB
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
build:
10+
name: Build and Release
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.10'
23+
24+
- name: Install dependencies
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y dpkg-dev
28+
29+
- name: Build DEB package
30+
run: |
31+
chmod +x build.sh
32+
./build.sh
33+
34+
- name: Get version
35+
id: get_version
36+
run: echo "VERSION=$(cat VERSION)" >> $GITHUB_OUTPUT
37+
38+
- name: Create Release
39+
id: create_release
40+
uses: softprops/action-gh-release@v2
41+
with:
42+
files: upk-${{ steps.get_version.outputs.VERSION }}.deb
43+
name: Release ${{ steps.get_version.outputs.VERSION }}
44+
draft: false
45+
prerelease: false
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.0
1+
1.0.1

build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ cp display.py "$TEMP_DIR/usr/lib/python3/dist-packages/upk/"
5353
cp search.py "$TEMP_DIR/usr/lib/python3/dist-packages/upk/"
5454
cp utils.py "$TEMP_DIR/usr/lib/python3/dist-packages/upk/"
5555
cp upk.py "$TEMP_DIR/usr/lib/python3/dist-packages/upk/"
56+
cp VERSION "$TEMP_DIR/usr/lib/python3/dist-packages/upk/"
5657

5758
# Create wrapper script
5859
print_status "Creating wrapper script..."

upk.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,21 @@
88
from search import search_all_backends
99

1010

11-
@click.group()
12-
@click.version_option(version="0.1.0")
11+
import os
12+
13+
def get_version():
14+
"""Read version from VERSION file."""
15+
try:
16+
version_file = os.path.join(os.path.dirname(__file__), 'VERSION')
17+
if os.path.exists(version_file):
18+
with open(version_file, 'r') as f:
19+
return f.read().strip()
20+
except Exception:
21+
pass
22+
return "0.1.0"
23+
24+
@click.group(context_settings=dict(help_option_names=['-h', '--help']), name="upk")
25+
@click.version_option(get_version(), '-v', '--version', message="upk version %(version)s")
1326
def cli():
1427
"""UPK - Ubuntu Package Kit
1528
@@ -306,11 +319,11 @@ def install(package: str, exact: bool, extra_args: tuple):
306319
if parsed_url.scheme in ('http', 'https'):
307320
# Remote file
308321
console.print(f"Installing remote file: [bold cyan]{package}[/bold cyan]")
309-
success = install_remote_file(package, exact=exact, extra_args=extra)
322+
success = install_remote_file(package, extra_args=extra)
310323
elif is_local_file(package):
311324
# Local file
312325
console.print(f"Installing local file: [bold cyan]{package}[/bold cyan]")
313-
success = install_local_file(package, exact=exact, extra_args=extra)
326+
success = install_local_file(package, extra_args=extra)
314327
else:
315328
# Package name
316329
console.print(f"Installing package: [bold cyan]{package}[/bold cyan]")
@@ -538,4 +551,4 @@ def config(action: str, key: str, value: str):
538551

539552

540553
if __name__ == "__main__":
541-
cli()
554+
cli(prog_name="upk")

0 commit comments

Comments
 (0)