mirror of
https://github.com/simonw/datasette.git
synced 2026-09-23 10:24:07 +02:00
123 lines
3.7 KiB
YAML
123 lines
3.7 KiB
YAML
name: Publish Python Package
|
|
|
|
on:
|
|
release:
|
|
types: [created]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v7
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
- uses: actions/cache@v6
|
|
name: Configure pip caching
|
|
with:
|
|
path: ~/.cache/pip
|
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pip-
|
|
- name: Install dependencies
|
|
run: |
|
|
pip install -e '.[test]'
|
|
- name: Run tests
|
|
run: |
|
|
pytest -n auto -m "not serial"
|
|
pytest -m "serial"
|
|
# And the test that exceeds a localhost HTTPS server
|
|
tests/test_datasette_https_server.sh
|
|
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
needs: [test]
|
|
environment: release
|
|
permissions:
|
|
id-token: write
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v7
|
|
with:
|
|
python-version: '3.11'
|
|
- uses: actions/cache@v6
|
|
name: Configure pip caching
|
|
with:
|
|
path: ~/.cache/pip
|
|
key: ${{ runner.os }}-publish-pip-${{ hashFiles('**/setup.py') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-publish-pip-
|
|
- name: Install dependencies
|
|
run: |
|
|
pip install setuptools wheel build
|
|
- name: Build
|
|
run: |
|
|
python -m build
|
|
- name: Publish
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
|
|
# After the first non-prerelease 1.0 release, disable this job on 0.65.x,
|
|
# even for later 0.65 releases, so they cannot overwrite the 1.0 stable docs.
|
|
deploy_static_docs:
|
|
runs-on: ubuntu-latest
|
|
needs: [deploy]
|
|
if: "!github.event.release.prerelease"
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v7
|
|
with:
|
|
python-version: '3.10'
|
|
- uses: actions/cache@v6
|
|
name: Configure pip caching
|
|
with:
|
|
path: ~/.cache/pip
|
|
key: ${{ runner.os }}-publish-pip-${{ hashFiles('**/setup.py') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-publish-pip-
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install -e .[docs]
|
|
python -m pip install sphinx-to-sqlite==0.1a1 "s3-credentials>=0.17"
|
|
- name: Build docs.db
|
|
run: |-
|
|
cd docs
|
|
sphinx-build -b xml . _build
|
|
sphinx-to-sqlite ../docs.db _build
|
|
cd ..
|
|
- name: Upload stable documentation database to S3
|
|
env:
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.S3_DATASETTE_DOCS_ACCESS_KEY }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_DATASETTE_DOCS_SECRET_KEY }}
|
|
run: |-
|
|
s3-credentials put-object datasette-docs docs.db docs.db \
|
|
--content-type application/octet-stream
|
|
|
|
deploy_docker:
|
|
runs-on: ubuntu-latest
|
|
needs: [deploy]
|
|
if: "!github.event.release.prerelease"
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- name: Build and push to Docker Hub
|
|
env:
|
|
DOCKER_USER: ${{ secrets.DOCKER_USER }}
|
|
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
|
|
run: |-
|
|
sleep 60 # Give PyPI time to make the new release available
|
|
docker login -u $DOCKER_USER -p $DOCKER_PASS
|
|
export REPO=datasetteproject/datasette
|
|
docker build -f Dockerfile \
|
|
-t $REPO:${GITHUB_REF#refs/tags/} \
|
|
--build-arg VERSION=${GITHUB_REF#refs/tags/} .
|
|
docker tag $REPO:${GITHUB_REF#refs/tags/} $REPO:latest
|
|
docker push $REPO:${GITHUB_REF#refs/tags/}
|
|
docker push $REPO:latest
|