Skip to content

Commit 726042d

Browse files
committed
feat(ci): set daemon version from setuptools-scm
1 parent e366980 commit 726042d

File tree

5 files changed

+26
-44
lines changed

5 files changed

+26
-44
lines changed

.github/workflows/appimage.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ jobs:
4747

4848
steps:
4949
- uses: actions/checkout@v4
50+
with:
51+
fetch-depth: 50
5052
- uses: rlespinasse/github-slug-action@v4
51-
- uses: proudust/gh-describe@v2
52-
id: ghd
5353

5454
- name: Setup qemu for docker
5555
uses: docker/setup-qemu-action@v3
@@ -61,12 +61,12 @@ jobs:
6161
- name: Compile in docker
6262
uses: docker/build-push-action@v5
6363
with:
64+
context: .
6465
platforms: ${{ matrix.target.platform }}
6566
outputs: build
6667
build-args: |
6768
BASE_OS=${{ matrix.base.os }}
6869
BASE_CODENAME=${{ matrix.base.codename }}
69-
GIT_DESCRIPTION=${{ steps.ghd.outputs.describe }}
7070
7171
- name: Prepare environment to build AppImage
7272
env:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ appimage/
2323
dist/
2424
sccontroller.egg-info/
2525
!.github
26+
scc/_version.py

Dockerfile

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ RUN <<EOR
1616
apt-get update
1717
apt-get install -y --no-install-recommends \
1818
gcc \
19+
git \
1920
librsvg2-bin \
2021
linux-headers-generic \
2122
python3-dev \
@@ -39,35 +40,11 @@ EOR
3940
COPY . /work
4041
WORKDIR /work
4142
ARG TARGET=/build
42-
ARG DAEMON_VERSION
43-
ARG GIT_DESCRIPTION
4443

4544
# Build and install
4645
RUN <<EOR
4746
set -eu
4847

49-
##
50-
# Converts the output of `git describe` to a valid python version (PEP 440),
51-
# e.g. `v0.4.9.2` to `0.4.9.2` or `ver0.4.8.11-3-123-g030686f` to `0.4.8.11.3.123+g030686f`
52-
##
53-
convert_git_description_to_pep440() {
54-
description="${1}"
55-
hash="${description##*-g}"
56-
version="$(printf %s "${description%-g*}" | tr -c -s [0-9.] .)"
57-
version="${version#.}"
58-
version="${version%.}"
59-
if [ "${hash}" != "${description}" ]; then
60-
version="${version}+g${hash}"
61-
fi
62-
printf '%s\n' "${version}"
63-
}
64-
if [ -z "${DAEMON_VERSION-}" ] && [ "${GIT_DESCRIPTION-}" ]; then
65-
DAEMON_VERSION="$(convert_git_description_to_pep440 "${GIT_DESCRIPTION}")"
66-
fi
67-
if [ "${DAEMON_VERSION-}" ]; then
68-
sed -i -E "s/^ *DAEMON_VERSION *= *.+/DAEMON_VERSION = \"${DAEMON_VERSION}\"/" scc/constants.py
69-
fi
70-
7148
python -m build --wheel
7249
python -m venv .env
7350
. .env/bin/activate

pyproject.toml

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
# TODO migrate files from setup.py - https://setuptools.pypa.io/en/latest/userguide/miscellaneous.html
55

66
[build-system]
7-
requires = ["setuptools>=60", "wheel"]
7+
requires = ["setuptools>=60", "setuptools-scm>=8.0", "wheel"]
88
build-backend = "setuptools.build_meta"
99

1010
[project]
1111
name = "sccontroller"
12-
version = "0.4.9.5" # Replace with DAEMON_VERSION or vice versa?
12+
dynamic = ["version"]
1313
description = "User-mode driver, mapper and GTK3 based GUI for Steam Controller, DS4 and similar controllers."
1414
authors = [{name = "C0rn3j", email = "[email protected]"}]
1515
license = {text = "GPL-2.0-only"}
@@ -22,6 +22,21 @@ classifiers = [
2222
requires-python = ">=3.8"
2323
#platforms = ["Linux"]
2424

25+
# https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#creating-executable-scripts
26+
[project.gui-scripts]
27+
sc-controller = "scc.bin.sc_controller:main"
28+
29+
[project.scripts]
30+
scc-daemon = "scc.bin.scc_daemon:main"
31+
scc = "scc.bin.scc:main"
32+
scc-osd-dialog = "scc.bin.scc_osd_dialog:main"
33+
scc-osd-keyboard = "scc.bin.scc_osd_keyboard:main"
34+
scc-osd-launcher = "scc.bin.scc_osd_launcher:main"
35+
scc-osd-menu = "scc.bin.scc_osd_menu:main"
36+
scc-osd-message = "scc.bin.scc_osd_message:main"
37+
scc-osd-radial-menu = "scc.bin.scc_osd_radial_menu:main"
38+
scc-osd-show-bindings = "scc.bin.scc_osd_show_bindings:main"
39+
2540
[tool.setuptools]
2641
packages = [
2742
"scc",
@@ -37,20 +52,8 @@ packages = [
3752
"scc.gui.creg"
3853
]
3954

40-
# https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#creating-executable-scripts
41-
[project.gui-scripts]
42-
sc-controller = "scc.bin.sc_controller:main"
43-
44-
[project.scripts]
45-
scc-daemon = "scc.bin.scc_daemon:main"
46-
scc = "scc.bin.scc:main"
47-
scc-osd-dialog = "scc.bin.scc_osd_dialog:main"
48-
scc-osd-keyboard = "scc.bin.scc_osd_keyboard:main"
49-
scc-osd-launcher = "scc.bin.scc_osd_launcher:main"
50-
scc-osd-menu = "scc.bin.scc_osd_menu:main"
51-
scc-osd-message = "scc.bin.scc_osd_message:main"
52-
scc-osd-radial-menu = "scc.bin.scc_osd_radial_menu:main"
53-
scc-osd-show-bindings = "scc.bin.scc_osd_show_bindings:main"
55+
[tool.setuptools_scm]
56+
version_file = "scc/_version.py"
5457

5558
[tool.ruff]
5659
# Target non-EOL releases at minimum, or later if needed

scc/constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@
2121
# THE SOFTWARE.
2222

2323
from enum import IntEnum
24+
from scc._version import __version__
2425

2526
"""
2627
If SC-Controller is updated while daemon is running, DAEMON_VERSION send by
2728
daemon will differ one one expected by UI and daemon will be forcefully restarted.
2829
"""
29-
DAEMON_VERSION = "0.4.9.5"
30+
DAEMON_VERSION = __version__
3031

3132
HPERIOD = 0.02
3233
LPERIOD = 0.5

0 commit comments

Comments
 (0)