From 793af379e26b9c0b7a97d6c3a76c3595b789854d Mon Sep 17 00:00:00 2001 From: Chris Streeter Date: Fri, 26 Jun 2026 10:01:04 -0400 Subject: [PATCH] ci: migrate from CircleCI to GitHub Actions --- .circleci/config.yml | 118 --------------------------------------- .github/workflows/ci.yml | 116 ++++++++++++++++++++++++++++++++++++++ README.md | 2 +- setup.py | 3 +- 4 files changed, 119 insertions(+), 120 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/ci.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 8c88b4b..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,118 +0,0 @@ -version: 2.1 - -references: - setup_py2_venv: &setup_py2_venv - run: - name: setup venv - command: | - mkdir -p ./venv - virtualenv venv - setup_py3_venv: &setup_py3_venv - run: - name: setup venv - command: | - python3 -m venv venv - install_deps: &install_deps - run: - name: install python dependencies - command: | - . venv/bin/activate - pip install awscli - pip install -e .[test] - fetch_test_files: &fetch_test_files - run: - name: fetch test files - command: | - . venv/bin/activate - aws s3 cp s3://educreations-secrets/python-iap/ tests/. --recursive - test: &test - run: - name: run tests - command: | - . venv/bin/activate - flake8 - pytest - -workflows: - build_and_deploy: - jobs: - - build_python2: - filters: - tags: - only: /.*/ - - build_python3: - filters: - tags: - only: /.*/ - - deploy: - requires: - - build_python2 - - build_python3 - filters: - tags: - only: /[0-9]+(\.[0-9]+)*/ - branches: - ignore: /.*/ - -jobs: - build_python2: - docker: - - image: circleci/python:2 - steps: - - checkout - - restore_cache: - key: v1-py2-cache-{{ checksum "setup.py" }} - - *setup_py2_venv - - *install_deps - - save_cache: - key: v1-py2-cache-{{ checksum "setup.py" }} - paths: - - "venv" - - *fetch_test_files - - *test - build_python3: - docker: - - image: circleci/python:3 - steps: - - checkout - - restore_cache: - key: v1-py3-cache-{{ checksum "setup.py" }} - - *setup_py3_venv - - *install_deps - - save_cache: - key: v1-py3-cache-{{ checksum "setup.py" }} - paths: - - "venv" - - *fetch_test_files - - *test - deploy: - docker: - - image: circleci/python:3 - steps: - - checkout - - restore_cache: - key: v1-py3-cache-{{ checksum "setup.py" }} - - *setup_py3_venv - - *install_deps - - save_cache: - key: v1-py3-cache-{{ checksum "setup.py" }} - paths: - - "venv" - - run: - name: init .pypirc - command: | - echo -e "[pypi]" >> ~/.pypirc - echo -e "username = streeter" >> ~/.pypirc - echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc - - run: - name: create packages - command: | - . venv/bin/activate - pip install -U setuptools wheel - python setup.py sdist bdist_wheel - - run: - name: upload to pypi - command: | - . venv/bin/activate - pip install twine - twine upload dist/* diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..44bab78 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,116 @@ +name: CI + +on: + pull_request: + branches: + - master + push: + branches: + - master + tags: + - "*" + +permissions: + contents: read + +jobs: + test: + name: Test Python ${{ matrix.python-version }} + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + python-version: + - "3.11" + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: pip + cache-dependency-path: setup.py + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install awscli + python -m pip install -e '.[test]' + + - name: Check AWS credentials + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + run: | + if [ -z "$AWS_ACCESS_KEY_ID" ] || [ -z "$AWS_SECRET_ACCESS_KEY" ]; then + echo "AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY secrets are required to fetch test files." >&2 + exit 1 + fi + + - name: Fetch test files + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: us-east-1 + run: aws s3 cp s3://educreations-secrets/python-iap/ tests/. --recursive + + - name: Run flake8 + run: python -m flake8 + + - name: Run pytest + run: python -m pytest + + publish: + name: Publish to PyPI + runs-on: ubuntu-latest + needs: test + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + cache: pip + cache-dependency-path: setup.py + + - name: Check release tag + id: release_tag + run: | + if [[ "$GITHUB_REF_NAME" =~ ^[0-9]+(\.[0-9]+)*$ ]]; then + echo "publish=true" >> "$GITHUB_OUTPUT" + else + echo "publish=false" >> "$GITHUB_OUTPUT" + echo "Tag $GITHUB_REF_NAME is not a version tag; skipping publish." + fi + + - name: Check PyPI password + if: steps.release_tag.outputs.publish == 'true' + env: + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + if [ -z "$PYPI_PASSWORD" ]; then + echo "PYPI_PASSWORD secret is required to publish to PyPI." >&2 + exit 1 + fi + + - name: Build package + if: steps.release_tag.outputs.publish == 'true' + run: | + python -m pip install --upgrade pip setuptools wheel + python setup.py sdist bdist_wheel + + - name: Publish package + if: steps.release_tag.outputs.publish == 'true' + env: + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python -m pip install --upgrade twine + python -m twine upload --username streeter --password "$PYPI_PASSWORD" dist/* diff --git a/README.md b/README.md index 97abb1f..3278fee 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # python-iap -[![CircleCI](https://circleci.com/gh/educreations/python-iap.svg?style=svg)](https://circleci.com/gh/educreations/python-iap) [![PyPI version](https://badge.fury.io/py/iap.svg)](https://badge.fury.io/py/iap) +[![CI](https://github.com/educreations/python-iap/actions/workflows/ci.yml/badge.svg)](https://github.com/educreations/python-iap/actions/workflows/ci.yml) [![PyPI version](https://badge.fury.io/py/iap.svg)](https://badge.fury.io/py/iap) Python utilities for working with Apple In-App Purchases (IAP) diff --git a/setup.py b/setup.py index 1d8491a..b07b3bd 100644 --- a/setup.py +++ b/setup.py @@ -17,11 +17,12 @@ author_email="engineering@educreations.com", url="https://github.com/educreations/python-iap", classifiers=[ - "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ], + python_requires=">=3", packages=["iap"], package_dir={"iap": "iap"}, install_requires=[