Skip to content

Commit 9933ef8

Browse files
Building a self-contained package
The generic-k8s-webhook can now be packaged into a self-contained package, so this package can be executed without the need of installing any extra dependency. To do so, we're leveraging pyinstaller. Now, when we'll build a new release, we'll push this self-contained package as part of the release.
1 parent ed97cc7 commit 9933ef8

File tree

5 files changed

+152
-3
lines changed

5 files changed

+152
-3
lines changed

.github/workflows/publish-artifacts.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,28 @@ on:
66
- '**'
77

88
jobs:
9+
build-release-pkg:
10+
name: Builds and publishes a self-contained package to the release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout main
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Write version
19+
run: ./scripts/insert-version-pyproject.sh ${{github.ref_name}}
20+
21+
- name: Build package
22+
run: |
23+
make pkg
24+
mv ./dist/main ./generic-k8s-webhook-linux-${{github.ref_name}}
25+
26+
- name: Publish package
27+
uses: softprops/action-gh-release@v2
28+
with:
29+
files: generic-k8s-webhook-linux-${{github.ref_name}}
30+
931
build-and-publish-to-ghcr:
1032
# Explicitly grant the `secrets.GITHUB_TOKEN` permissions.
1133
permissions:

.github/workflows/test-pr.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jobs:
2929
- name: Install Python libraries
3030
run: poetry install
3131

32+
- name: Build self-contained package
33+
run: make pkg
34+
3235
- name: Linter
3336
run: make lint
3437

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ check-pyproject:
4141
docker:
4242
docker build -t generic-k8s-webhook:latest .
4343

44+
.PHONY: pkg
45+
pkg: build
46+
poetry run pyinstaller ./generic_k8s_webhook/main.py --onefile --recursive-copy-metadata generic_k8s_webhook
47+
4448
all-tests: check-pyproject lint unittests docker
4549

4650
all-tests-seq: | check-pyproject lint unittests docker

poetry.lock

+121-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ authors = ["jordi <[email protected]>"]
77
license = "Apache License"
88

99
[tool.poetry.dependencies]
10-
python = "^3.11"
10+
python = ">=3.11,<3.13"
1111
PyYAML = "^6.0"
1212
jsonpatch = "^1.33"
1313
requests = "^2.31.0"
@@ -23,6 +23,7 @@ isort = "^5.12.0"
2323
black = "^23.3.0"
2424
pylint = "^2.17.4"
2525
pytest-cov = "^5.0.0"
26+
pyinstaller = "^6.9.0"
2627

2728
[tool.isort]
2829
line_length = 120

0 commit comments

Comments
 (0)