Repository navigation
refactor: Streamline CycleTLS client initialization by removing expli… #64
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Main | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*.*.*' | |
| env: | |
| # Change this to invalidate existing cache. | |
| CACHE_PREFIX: v0 | |
| PYTHON_PATH: ./ | |
| jobs: | |
| checks: | |
| name: Python ${{ matrix.python }} - ${{ matrix.task.name }} | |
| runs-on: [ubuntu-latest] | |
| timeout-minutes: 30 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] | |
| task: | |
| - name: Test | |
| run: | | |
| pytest -v --color=yes tests/ | |
| include: | |
| - python: '3.12' | |
| task: | |
| name: Lint | |
| run: flake8 cycletls setup.py | |
| - python: '3.12' | |
| task: | |
| name: Type check | |
| run: mypy cycletls | |
| - python: '3.12' | |
| task: | |
| name: Build | |
| run: | | |
| python setup.py check | |
| python setup.py bdist_wheel sdist | |
| - python: '3.12' | |
| task: | |
| name: Style | |
| run: black --check cycletls setup.py docs/source/conf.py | |
| - python: '3.12' | |
| task: | |
| name: Docs | |
| run: cd docs && make html | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.23' | |
| cache-dependency-path: | | |
| go.sum | |
| golang/go.sum | |
| - name: Build CycleTLS shared library | |
| run: | | |
| chmod +x build_shared_lib.sh | |
| ./build_shared_lib.sh | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - name: Install prerequisites | |
| run: | | |
| pip install --upgrade pip setuptools wheel virtualenv | |
| - name: Set build variables | |
| shell: bash | |
| run: | | |
| # Get the exact Python version to use in the cache key. | |
| echo "PYTHON_VERSION=$(python --version)" >> $GITHUB_ENV | |
| echo "RUNNER_ARCH=$(uname -m)" >> $GITHUB_ENV | |
| # Use week number in cache key so we can refresh the cache weekly. | |
| echo "WEEK_NUMBER=$(date +%V)" >> $GITHUB_ENV | |
| - uses: actions/cache@v4 | |
| id: virtualenv-cache | |
| with: | |
| path: .venv | |
| key: ${{ env.CACHE_PREFIX }}-${{ env.WEEK_NUMBER }}-${{ runner.os }}-${{ env.RUNNER_ARCH }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('dev-requirements.txt') }} | |
| restore-keys: | | |
| ${{ env.CACHE_PREFIX }}-${{ env.WEEK_NUMBER }}-${{ runner.os }}-${{ env.RUNNER_ARCH }}-${{ env.PYTHON_VERSION }}- | |
| - name: Setup virtual environment (no cache hit) | |
| if: steps.virtualenv-cache.outputs.cache-hit != 'true' | |
| run: | | |
| test -d .venv || virtualenv -p $(which python) --copies --reset-app-data .venv | |
| . .venv/bin/activate | |
| pip install setuptools>=45 wheel | |
| pip install -e .[dev] | |
| - name: Install editable (cache hit) | |
| if: steps.virtualenv-cache.outputs.cache-hit == 'true' | |
| run: | | |
| . .venv/bin/activate | |
| pip install --no-deps -e .[dev] | |
| - name: Install docs dependencies | |
| if: matrix.task.name == 'Docs' | |
| run: | | |
| . .venv/bin/activate | |
| pip install -e .[docs] | |
| - name: Show environment info | |
| run: | | |
| . .venv/bin/activate | |
| which python | |
| python --version | |
| pip freeze | |
| - name: ${{ matrix.task.name }} | |
| run: | | |
| . .venv/bin/activate | |
| ${{ matrix.task.run }} | |
| - name: Upload package distribution files | |
| if: matrix.task.name == 'Build' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: package | |
| path: dist | |
| - name: Clean up | |
| if: always() | |
| run: | | |
| . .venv/bin/activate | |
| pip uninstall -y my-package | |
| build-wheels: | |
| name: Build wheels on ${{ matrix.os }} (${{ matrix.arch }}) | |
| runs-on: ${{ matrix.os }} | |
| if: startsWith(github.ref, 'refs/tags/') | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Linux x86_64 | |
| - os: ubuntu-latest | |
| arch: x64 | |
| platform: linux | |
| go-arch: amd64 | |
| # Linux ARM64 (cross-compile) | |
| - os: ubuntu-latest | |
| arch: arm64 | |
| platform: linux | |
| go-arch: arm64 | |
| # macOS Intel | |
| - os: macos-13 | |
| arch: x64 | |
| platform: darwin | |
| go-arch: amd64 | |
| # macOS Apple Silicon | |
| - os: macos-14 | |
| arch: arm64 | |
| platform: darwin | |
| go-arch: arm64 | |
| # Windows x86_64 | |
| - os: windows-latest | |
| arch: x64 | |
| platform: windows | |
| go-arch: amd64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.23' | |
| # Linux ARM64 cross-compilation setup | |
| - name: Install cross-compilation tools (Linux ARM64) | |
| if: matrix.platform == 'linux' && matrix.arch == 'arm64' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
| - name: Build shared library (Linux ARM64) | |
| if: matrix.platform == 'linux' && matrix.arch == 'arm64' | |
| env: | |
| CGO_ENABLED: 1 | |
| GOOS: linux | |
| GOARCH: arm64 | |
| CC: aarch64-linux-gnu-gcc | |
| CXX: aarch64-linux-gnu-g++ | |
| run: | | |
| mkdir -p dist | |
| cd golang | |
| go build -buildmode=c-shared -o ../dist/libcycletls-linux-arm64.so . | |
| - name: Build shared library (Native) | |
| if: "!(matrix.platform == 'linux' && matrix.arch == 'arm64')" | |
| run: | | |
| chmod +x build_shared_lib.sh | |
| ./build_shared_lib.sh | |
| shell: bash | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install build tools | |
| run: | | |
| pip install --upgrade pip build wheel setuptools | |
| - name: Copy library to package dist | |
| run: | | |
| mkdir -p cycletls/dist | |
| cp dist/* cycletls/dist/ | |
| shell: bash | |
| - name: Build wheel | |
| run: python -m build --wheel | |
| - name: Upload wheel | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheel-${{ matrix.platform }}-${{ matrix.arch }} | |
| path: dist/*.whl | |
| test-pypi-release: | |
| name: Test PyPI Release | |
| runs-on: ubuntu-latest | |
| needs: [checks, build-wheels] | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install requirements | |
| run: | | |
| pip install --upgrade pip setuptools wheel twine | |
| - name: Prepare environment | |
| run: | | |
| echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV | |
| echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
| # Download all platform wheels | |
| - name: Download wheels | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: wheel-* | |
| path: dist | |
| merge-multiple: true | |
| - name: List distribution files | |
| run: ls -lh dist/ | |
| - name: Publish to Test PyPI | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} | |
| run: | | |
| twine upload --repository testpypi dist/*.whl --verbose || echo "Upload failed (possibly version exists)" | |
| pypi-release: | |
| name: Production PyPI Release | |
| runs-on: ubuntu-latest | |
| needs: [test-pypi-release] | |
| if: startsWith(github.ref, 'refs/tags/') | |
| environment: | |
| name: pypi-production | |
| url: https://pypi.org/p/cycletls | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install requirements | |
| run: | | |
| pip install --upgrade pip setuptools wheel twine | |
| - name: Prepare environment | |
| run: | | |
| echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV | |
| echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
| # Download all platform wheels | |
| - name: Download wheels | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: wheel-* | |
| path: dist | |
| merge-multiple: true | |
| - name: List distribution files | |
| run: ls -lh dist/ | |
| - name: Publish to PyPI | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
| run: | | |
| twine upload dist/*.whl --verbose | |
| - name: Generate release notes | |
| run: | | |
| echo "# CycleTLS ${{ env.RELEASE_VERSION }}" > ${{ github.workspace }}-RELEASE_NOTES.md | |
| echo "" >> ${{ github.workspace }}-RELEASE_NOTES.md | |
| echo "Released to PyPI: https://pypi.org/project/cycletls/${{ env.RELEASE_VERSION }}/" >> ${{ github.workspace }}-RELEASE_NOTES.md | |
| - name: Publish GitHub release | |
| uses: softprops/action-gh-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| body_path: ${{ github.workspace }}-RELEASE_NOTES.md | |
| prerelease: ${{ contains(env.TAG, 'rc') }} | |
| files: | | |
| dist/*.whl |