| 1 |
name: Publish Python Package |
| 2 |
|
| 3 |
on: |
| 4 |
release: |
| 5 |
types: [published] |
| 6 |
|
| 7 |
permissions: |
| 8 |
contents: read |
| 9 |
|
| 10 |
jobs: |
| 11 |
test: |
| 12 |
runs-on: ubuntu-latest |
| 13 |
strategy: |
| 14 |
matrix: |
| 15 |
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] |
| 16 |
steps: |
| 17 |
- uses: actions/checkout@v7 |
| 18 |
- name: Set up Python ${{ matrix.python-version }} |
| 19 |
uses: actions/setup-python@v7 |
| 20 |
with: |
| 21 |
python-version: ${{ matrix.python-version }} |
| 22 |
- uses: actions/cache@v6 |
| 23 |
name: Configure pip caching |
| 24 |
with: |
| 25 |
path: ~/.cache/pip |
| 26 |
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} |
| 27 |
restore-keys: | |
| 28 |
${{ runner.os }}-pip- |
| 29 |
- name: Install dependencies |
| 30 |
run: | |
| 31 |
pip install -e '.[test]' |
| 32 |
- name: Run tests |
| 33 |
run: | |
| 34 |
pytest -n auto -m "not serial" |
| 35 |
pytest -m "serial" |
| 36 |
# And the test that exceeds a localhost HTTPS server |
| 37 |
tests/test_datasette_https_server.sh |
| 38 |
|
| 39 |
deploy: |
| 40 |
runs-on: ubuntu-latest |
| 41 |
needs: [test] |
| 42 |
environment: release |
| 43 |
permissions: |
| 44 |
id-token: write |
| 45 |
steps: |
| 46 |
- uses: actions/checkout@v7 |
| 47 |
- name: Set up Python |
| 48 |
uses: actions/setup-python@v7 |
| 49 |
with: |
| 50 |
python-version: '3.11' |
| 51 |
- uses: actions/cache@v6 |
| 52 |
name: Configure pip caching |
| 53 |
with: |
| 54 |
path: ~/.cache/pip |
| 55 |
key: ${{ runner.os }}-publish-pip-${{ hashFiles('**/setup.py') }} |
| 56 |
restore-keys: | |
| 57 |
${{ runner.os }}-publish-pip- |
| 58 |
- name: Install dependencies |
| 59 |
run: | |
| 60 |
pip install setuptools wheel build |
| 61 |
- name: Build |
| 62 |
run: | |
| 63 |
python -m build |
| 64 |
- name: Publish |
| 65 |
uses: pypa/gh-action-pypi-publish@release/v1 |
| 66 |
|
| 67 |
# After the first non-prerelease 1.0 release, disable this job on 0.65.x, |
| 68 |
# even for later 0.65 releases, so they cannot overwrite the 1.0 stable docs. |
| 69 |
deploy_static_docs: |
| 70 |
runs-on: ubuntu-latest |
| 71 |
needs: [deploy] |
| 72 |
if: "!github.event.release.prerelease" |
| 73 |
steps: |
| 74 |
- uses: actions/checkout@v7 |
| 75 |
- name: Set up Python |
| 76 |
uses: actions/setup-python@v7 |
| 77 |
with: |
| 78 |
python-version: '3.10' |
| 79 |
- uses: actions/cache@v6 |
| 80 |
name: Configure pip caching |
| 81 |
with: |
| 82 |
path: ~/.cache/pip |
| 83 |
key: ${{ runner.os }}-publish-pip-${{ hashFiles('**/setup.py') }} |
| 84 |
restore-keys: | |
| 85 |
${{ runner.os }}-publish-pip- |
| 86 |
- name: Install dependencies |
| 87 |
run: | |
| 88 |
python -m pip install -e .[docs] |
| 89 |
python -m pip install sphinx-to-sqlite==0.1a1 "s3-credentials>=0.17" |
| 90 |
- name: Build docs.db |
| 91 |
run: |- |
| 92 |
cd docs |
| 93 |
sphinx-build -b xml . _build |
| 94 |
sphinx-to-sqlite ../docs.db _build |
| 95 |
cd .. |
| 96 |
- name: Upload stable documentation database to S3 |
| 97 |
env: |
| 98 |
AWS_ACCESS_KEY_ID: ${{ secrets.S3_DATASETTE_DOCS_ACCESS_KEY }} |
| 99 |
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_DATASETTE_DOCS_SECRET_KEY }} |
| 100 |
run: |- |
| 101 |
s3-credentials put-object datasette-docs docs.db docs.db \ |
| 102 |
--content-type application/octet-stream |
| 103 |
|
| 104 |
deploy_docker: |
| 105 |
runs-on: ubuntu-latest |
| 106 |
needs: [deploy] |
| 107 |
if: "!github.event.release.prerelease" |
| 108 |
steps: |
| 109 |
- uses: actions/checkout@v7 |
| 110 |
- name: Build and push to Docker Hub |
| 111 |
env: |
| 112 |
DOCKER_USER: ${{ secrets.DOCKER_USER }} |
| 113 |
DOCKER_PASS: ${{ secrets.DOCKER_PASS }} |
| 114 |
run: |- |
| 115 |
sleep 60 # Give PyPI time to make the new release available |
| 116 |
docker login -u $DOCKER_USER -p $DOCKER_PASS |
| 117 |
export REPO=datasetteproject/datasette |
| 118 |
docker build -f Dockerfile \ |
| 119 |
-t $REPO:${GITHUB_REF#refs/tags/} \ |
| 120 |
--build-arg VERSION=${GITHUB_REF#refs/tags/} . |
| 121 |
docker tag $REPO:${GITHUB_REF#refs/tags/} $REPO:latest |
| 122 |
docker push $REPO:${GITHUB_REF#refs/tags/} |
| 123 |
docker push $REPO:latest |