Skip to content

Commit 882fa68

Browse files
authored
Merge pull request #7 from 6C656C65/feature/python_packages
Build and release a python packages
2 parents 899e1ab + 021ea7a commit 882fa68

46 files changed

Lines changed: 1012 additions & 663 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.bumpversion.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[bumpversion]
2-
current_version = 0.3.2
2+
current_version = 0.4.0
33
commit = True
44
tag = True
55

6-
[bumpversion:file:pyproxy/utils/version.py]
6+
[bumpversion:file:pyproxy/__init__.py]

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ benchmark/
1919
.gitignore
2020
.git
2121
.gitattributes
22-
.pylintrc
22+
.flake8
2323
.readthedocs.yaml
2424
CHANGELOG.md
2525
CONTRIBUTING.md

.flake8

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
ignore = E203, W503
3+
max-line-length = 100

.github/workflows/code-scan.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/docker-images.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
name: cicd
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "*"
9+
pull_request:
10+
11+
jobs:
12+
code-scan:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
strategy:
17+
matrix:
18+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
28+
- name: Install dependencies
29+
run: pip install --no-cache-dir -U pip black flake8 bandit
30+
31+
- name: Lint with flake8
32+
run: flake8 pyproxy tests benchmark
33+
34+
- name: Check with black
35+
run: black --check pyproxy tests benchmark
36+
37+
- name: Check with bandit
38+
run: bandit -r pyproxy tests benchmark
39+
40+
unittest:
41+
needs: code-scan
42+
runs-on: ubuntu-latest
43+
permissions:
44+
contents: read
45+
46+
steps:
47+
- uses: actions/checkout@v4
48+
49+
- name: Set up Python
50+
uses: actions/setup-python@v5
51+
with:
52+
python-version: 3.13
53+
54+
- name: Install build dependencies
55+
run: pip install --no-cache-dir -r requirements.txt
56+
57+
- name: Run tests
58+
run: python -m unittest discover -s tests
59+
60+
build-docker:
61+
needs: unittest
62+
if: github.event_name == 'push'
63+
runs-on: ubuntu-latest
64+
permissions:
65+
contents: write
66+
id-token: write
67+
68+
steps:
69+
- uses: actions/checkout@v4
70+
with:
71+
fetch-depth: 0
72+
73+
- name: Set up Docker Buildx
74+
uses: docker/setup-buildx-action@v2
75+
76+
- name: Log in to GitHub Container Registry
77+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
78+
79+
- name: Get version
80+
id: get_version
81+
run: |
82+
version=$(grep '^__version__' pyproxy/__init__.py | cut -d'"' -f2)
83+
echo "version=${version}" >> $GITHUB_ENV
84+
85+
- name: Convert repository owner to lowercase
86+
run: echo "REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
87+
88+
- name: Build Docker image
89+
run: docker build -t ghcr.io/${{ env.REPO_OWNER }}/pyproxy:${{ env.VERSION }} -t ghcr.io/${{ env.REPO_OWNER }}/pyproxy:latest .
90+
91+
- name: Build Docker slim image
92+
run: docker build -f Dockerfile.slim -t ghcr.io/${{ env.REPO_OWNER }}/pyproxy:${{ env.VERSION }}-slim -t ghcr.io/${{ env.REPO_OWNER }}/pyproxy:latest-slim .
93+
94+
- name: Push Docker image
95+
run: |
96+
docker push ghcr.io/${{ env.REPO_OWNER }}/pyproxy:${{ env.VERSION }}-slim
97+
docker push ghcr.io/${{ env.REPO_OWNER }}/pyproxy:latest-slim
98+
docker push ghcr.io/${{ env.REPO_OWNER }}/pyproxy:${{ env.VERSION }}
99+
docker push ghcr.io/${{ env.REPO_OWNER }}/pyproxy:latest
100+
101+
build-packages:
102+
needs: unittest
103+
if: github.event_name == 'push'
104+
runs-on: ubuntu-latest
105+
permissions:
106+
contents: read
107+
id-token: write
108+
109+
steps:
110+
- uses: actions/checkout@v4
111+
112+
- name: Set up Python
113+
uses: actions/setup-python@v5
114+
with:
115+
python-version: 3.13
116+
117+
- name: Get version
118+
id: get_version
119+
run: |
120+
version=$(grep '^__version__' pyproxy/__init__.py | cut -d'"' -f2)
121+
echo "version=${version}" >> $GITHUB_OUTPUT
122+
123+
- name: Create Tag
124+
run: |
125+
git config user.name "github-actions[bot]"
126+
git config user.email "github-actions[bot]@users.noreply.github.com"
127+
git tag v${{ steps.get_version.outputs.version }}
128+
git push origin v${{ steps.get_version.outputs.version }}
129+
130+
- name: Create GitHub Release
131+
id: create_release
132+
uses: actions/create-release@v1
133+
with:
134+
tag_name: v${{ steps.get_version.outputs.version }}
135+
release_name: Release v${{ steps.get_version.outputs.version }}
136+
draft: false
137+
prerelease: false
138+
env:
139+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140+
141+
- name: Install build dependencies
142+
run: pip install --no-cache-dir -U pip . build
143+
144+
- name: Build package
145+
run: python -m build --sdist --wheel
146+
- name: Upload built distributions
147+
uses: actions/upload-artifact@v4
148+
with:
149+
name: dist
150+
path: dist
151+
152+
- name: Install release dependencies
153+
run: pip install --no-cache-dir -U pip . twine packaging
154+
155+
- name: Upload to PyPI
156+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/unittest.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,6 @@ config/*
177177
# Certs folder
178178
certs/*.key
179179
certs/*.pem
180-
certs/ca/*.pem
180+
certs/ca/*.pem
181+
182+
.vscode

.pylintrc

Lines changed: 0 additions & 2 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
## [0.3.3] - 2025-05-30
2+
### Added
3+
- Change pylint to flake8
4+
- Black scan
5+
- Build and release python package
6+
7+
## [0.3.2] - 2025-05-13
8+
### Added
9+
- Proxy chaining
10+
- List of authorized IPs
11+
## Patch
12+
- Boolean in config ini
13+
114
## [0.3.1] - 2025-04-26
215
### Added
316
- Add slim image

0 commit comments

Comments
 (0)