Publish Python Package #91
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Python Package | |
on: | |
release: | |
types: [created] | |
permissions: | |
contents: read | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: pip | |
cache-dependency-path: setup.py | |
- name: Install dependencies | |
run: | | |
pip install -e '.[test]' | |
- name: Run tests | |
run: | | |
pytest | |
deploy: | |
runs-on: ubuntu-latest | |
needs: [test] | |
environment: release | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
cache: pip | |
cache-dependency-path: setup.py | |
- 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 | |
deploy_static_docs: | |
runs-on: ubuntu-latest | |
needs: [deploy] | |
if: "!github.event.release.prerelease" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.9' | |
cache: pip | |
cache-dependency-path: setup.py | |
- name: Install dependencies | |
run: | | |
python -m pip install -e .[docs] | |
python -m pip install sphinx-to-sqlite==0.1a1 | |
- name: Build docs.db | |
run: |- | |
cd docs | |
DISABLE_SPHINX_INLINE_TABS=1 sphinx-build -b xml . _build | |
sphinx-to-sqlite ../docs.db _build | |
cd .. | |
- name: Set up Cloud Run | |
uses: google-github-actions/setup-gcloud@v0 | |
with: | |
version: '318.0.0' | |
service_account_email: ${{ secrets.GCP_SA_EMAIL }} | |
service_account_key: ${{ secrets.GCP_SA_KEY }} | |
- name: Deploy stable-docs.datasette.io to Cloud Run | |
run: |- | |
gcloud config set run/region us-central1 | |
gcloud config set project datasette-222320 | |
datasette publish cloudrun docs.db \ | |
--service=datasette-docs-stable | |
deploy_docker: | |
runs-on: ubuntu-latest | |
needs: [deploy] | |
if: "!github.event.release.prerelease" | |
steps: | |
- uses: actions/checkout@v4 | |
- 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 |