mirror of
https://github.com/bellingcat/geoclustering.git
synced 2026-06-11 21:18:29 +03:00
feat: auto-deploy to pypi (#8)
This commit is contained in:
committed by
GitHub
parent
f55782d0da
commit
f1053953ba
54
.github/actions/setup-venv/action.yml
vendored
Normal file
54
.github/actions/setup-venv/action.yml
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
name: Python virtualenv
|
||||
description: Set up a Python virtual environment with caching
|
||||
inputs:
|
||||
python-version:
|
||||
description: The Python version to use
|
||||
required: true
|
||||
cache-prefix:
|
||||
description: Update this to invalidate the cache
|
||||
required: true
|
||||
default: v0
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ inputs.python-version }}
|
||||
|
||||
- shell: bash
|
||||
run: |
|
||||
# Install prerequisites.
|
||||
pip install --upgrade pip setuptools wheel virtualenv
|
||||
|
||||
- shell: bash
|
||||
run: |
|
||||
# Get the exact Python version to use in the cache key.
|
||||
echo "PYTHON_VERSION=$(python --version)" >> $GITHUB_ENV
|
||||
|
||||
- uses: actions/cache@v2
|
||||
id: virtualenv-cache
|
||||
with:
|
||||
path: .venv
|
||||
key: ${{ inputs.cache-prefix }}-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('requirements.txt', 'dev-requirements.txt') }}
|
||||
|
||||
- if: steps.virtualenv-cache.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
# Set up virtual environment without cache hit.
|
||||
test -d .venv || virtualenv -p $(which python) --copies --reset-app-data .venv
|
||||
. .venv/bin/activate
|
||||
pip install -e .[dev]
|
||||
|
||||
- if: steps.virtualenv-cache.outputs.cache-hit == 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
# Set up virtual environment from cache hit.
|
||||
. .venv/bin/activate
|
||||
pip install --no-deps -e .[dev]
|
||||
|
||||
- shell: bash
|
||||
run: |
|
||||
# Show environment info.
|
||||
. .venv/bin/activate
|
||||
echo "✓ Installed $(python --version) virtual environment to $(which python)"
|
||||
10
.github/workflows/lint.yml
vendored
10
.github/workflows/lint.yml
vendored
@@ -1,10 +0,0 @@
|
||||
name: Lint
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
black:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: psf/black@stable
|
||||
113
.github/workflows/main.yml
vendored
Normal file
113
.github/workflows/main.yml
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
name: Main
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
# on: [push]
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- "v*.*.*"
|
||||
|
||||
env:
|
||||
# Change this to invalidate existing cache.
|
||||
CACHE_PREFIX: v0
|
||||
PYTHONPATH: ./
|
||||
|
||||
jobs:
|
||||
checks:
|
||||
name: Python ${{ matrix.python }} - ${{ matrix.task.name }}
|
||||
runs-on: [ubuntu-latest]
|
||||
timeout-minutes: 15
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- python: "3.10"
|
||||
task:
|
||||
name: "Build"
|
||||
run: |
|
||||
python setup.py check
|
||||
python setup.py bdist_wheel sdist
|
||||
|
||||
- python: "3.10"
|
||||
task:
|
||||
name: "Style"
|
||||
run: |
|
||||
black --check .
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Python environment
|
||||
uses: ./.github/actions/setup-venv
|
||||
with:
|
||||
python-version: ${{ matrix.python }}
|
||||
cache-prefix: ${{ env.CACHE_PREFIX }}
|
||||
|
||||
- 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@v3
|
||||
with:
|
||||
name: package
|
||||
path: dist
|
||||
|
||||
- name: Clean up
|
||||
if: always()
|
||||
run: |
|
||||
. .venv/bin/activate
|
||||
pip uninstall -y geoclustering
|
||||
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
needs: [checks]
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.10"
|
||||
|
||||
- name: Install requirements
|
||||
run: |
|
||||
pip install --upgrade pip setuptools wheel "twine>=1.11.0"
|
||||
|
||||
- name: Prepare environment
|
||||
run: |
|
||||
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
|
||||
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
||||
|
||||
- name: Download package distribution files
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: package
|
||||
path: dist
|
||||
|
||||
- name: Publish package to PyPI
|
||||
run: |
|
||||
twine upload -u '${{ secrets.PYPI_USERNAME }}' -p '${{ secrets.PYPI_PASSWORD }}' dist/*
|
||||
|
||||
- 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/*
|
||||
Reference in New Issue
Block a user