Skip to content

Commit

Permalink
Building a self-contained package
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jordipiqueselles committed Jul 22, 2024
1 parent ed97cc7 commit 9933ef8
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 3 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/publish-artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,28 @@ on:
- '**'

jobs:
build-release-pkg:
name: Builds and publishes a self-contained package to the release
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Write version
run: ./scripts/insert-version-pyproject.sh ${{github.ref_name}}

- name: Build package
run: |
make pkg
mv ./dist/main ./generic-k8s-webhook-linux-${{github.ref_name}}
- name: Publish package
uses: softprops/action-gh-release@v2
with:
files: generic-k8s-webhook-linux-${{github.ref_name}}

build-and-publish-to-ghcr:
# Explicitly grant the `secrets.GITHUB_TOKEN` permissions.
permissions:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- name: Install Python libraries
run: poetry install

- name: Build self-contained package
run: make pkg

- name: Linter
run: make lint

Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ check-pyproject:
docker:
docker build -t generic-k8s-webhook:latest .

.PHONY: pkg
pkg: build
poetry run pyinstaller ./generic_k8s_webhook/main.py --onefile --recursive-copy-metadata generic_k8s_webhook

all-tests: check-pyproject lint unittests docker

all-tests-seq: | check-pyproject lint unittests docker
123 changes: 121 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = ["jordi <[email protected]>"]
license = "Apache License"

[tool.poetry.dependencies]
python = "^3.11"
python = ">=3.11,<3.13"
PyYAML = "^6.0"
jsonpatch = "^1.33"
requests = "^2.31.0"
Expand All @@ -23,6 +23,7 @@ isort = "^5.12.0"
black = "^23.3.0"
pylint = "^2.17.4"
pytest-cov = "^5.0.0"
pyinstaller = "^6.9.0"

[tool.isort]
line_length = 120
Expand Down

0 comments on commit 9933ef8

Please sign in to comment.