diff --git a/.github/actions/build-package/action.yaml b/.github/actions/build-package/action.yaml new file mode 100644 index 0000000..fd6a4ce --- /dev/null +++ b/.github/actions/build-package/action.yaml @@ -0,0 +1,31 @@ +name: 'Build Python Package' +description: 'Sets up Python, builds package, and validates it' +inputs: + python-version: + description: 'Python version to use' + required: false + default: '3.8' + +runs: + using: "composite" + steps: + - name: Set up Python ${{ inputs.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.python-version }} + + - name: Upgrade pip and setuptools + shell: bash + run: python -m pip install --upgrade pip setuptools + + - name: Install dependencies + shell: bash + run: pip install twine wheel + + - name: Setup deployment + shell: bash + run: python setup.py sdist bdist_wheel + + - name: Validate deployment + shell: bash + run: twine check dist/* \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..e8b1dca --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,47 @@ +name: release + +on: + push: + tags: + - '*' + +jobs: + release-test: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/actions/build-package + + - name: Set up a fresh environment and run tests + run: | + python -m venv venv + source venv/bin/activate + pip install dist/*.tar.gz + pip install dist/*.whl + pip install -e .[test] + pytest + + release: + runs-on: ubuntu-22.04 + needs: release-test + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python 3.8 + uses: actions/setup-python@v5 + with: + python-version: 3.8 + + - name: Compare tags + run: | + PKG_VERSION=`grep '__version__' mapbox_tilesets/__init__.py | sed -E "s/^.*['\"](.*)['\"].*$/\1/"` + echo "Checking that package version [v$PKG_VERSION] matches release tag [${{ github.ref_name }}]" + [ "${{ github.ref_type }}" = "tag" ] && [ "${{ github.ref_name }}" = "v$PKG_VERSION" ] + + - uses: ./.github/actions/build-package + + - name: Run deployment + run: + twine upload dist/* -r pypi -u __token__ -p ${{ secrets.PYPI_PASSWORD }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..f1c0ff0 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,53 @@ +name: Unit test + +on: + push: + branches: ["**"] + pull_request: + +jobs: + test: + strategy: + matrix: + include: + - python-version: 3.8 + os: ubuntu-22.04 + - python-version: 3.9 + os: ubuntu-22.04 + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools + pip install "importlib-metadata==4.8.3" + pip install -r requirements.txt -e .[test] + + - name: Show Python and pytest versions + run: | + python --version + pytest --version + + - name: Run pre-commit checks + run: pre-commit run --all-files + + - name: Run tests with coverage + run: pytest --cov --cov-config=.coveragerc --cov-report=xml + + - name: List all files in current directory + run: ls -la + + - name: Upload coverage to GitHub (optional, internal) + if: matrix.python-version == '3.8' + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage.xml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3901882..0000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: python -dist: bionic -python: - - '3.6' - - '3.7' - - '3.8' - -install: - - pip install -U setuptools "importlib-metadata==4.8.3" - - pip install -r requirements.txt -e .[test] -script: - - python --version - - pytest --version - - pre-commit run --all-files - - pytest --cov --cov-config=.coveragerc -after_script: - - python -m codecov -deploy: - provider: pypi - user: __token__ - password: $PYPI_PASSWORD - distributions: "sdist bdist_wheel" - on: - python: 3.8 - tags: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c4025cd..b537031 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -54,7 +54,7 @@ After which you can add these changes and commit again. Note that failing pre-co ## Release process -Releases to PyPi are handled via TravisCI and GitHub tags. Once changes have been merged to master: +Releases to PyPi are handled via Github Actions and GitHub tags. Once changes have been merged to master: 1. Update the version in mapbox_tilesets/__init__.py 2. Update the changelog @@ -62,8 +62,8 @@ Releases to PyPi are handled via TravisCI and GitHub tags. Once changes have bee 4. Get a review and merge your changes to master. 5. Get the latest changes locally from master `git checkout master && git pull origin master` 6. Tag on GitHub with `git tag` and push tags. For example `git tag -a v0.2.0 -m 'v0.2.0' && git push --tags` -7. Watch for tag build on travis at https://travis-ci.com/github/mapbox/tilesets-cli/builds -8. Once travis completes successfully, look for the release at https://pypi.org/project/mapbox-tilesets/#history +7. Watch for tag build on Github Actions at https://github.com/mapbox/tilesets-cli/actions +8. Once Github Actions completes successfully, look for the release at https://pypi.org/project/mapbox-tilesets/#history ## Tests diff --git a/README.md b/README.md index b86bf3c..e0cb9ab 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # tilesets-cli -[![Build Status](https://travis-ci.com/mapbox/tilesets-cli.svg?token=wqR3RcWUEprcQ1ttsgiP&branch=master)](https://travis-ci.com/mapbox/tilesets-cli) [![codecov](https://codecov.io/gh/mapbox/tilesets-cli/branch/master/graph/badge.svg?token=YBTKyc2o3j)](https://codecov.io/gh/mapbox/tilesets-cli) +[![Build Status](https://github.com/mapbox/tilesets-cli/actions/workflows/release.yaml/badge.svg)](https://github.com/mapbox/tilesets-cli/actions/workflows/release.yaml) [![codecov](https://codecov.io/gh/mapbox/tilesets-cli/branch/master/graph/badge.svg?token=YBTKyc2o3j)](https://codecov.io/gh/mapbox/tilesets-cli) CLI for interacting with and preparing data for the [Mapbox Tiling Service](https://docs.mapbox.com/mapbox-tiling-service/overview/).