Skip to content

Commit 473dfd7

Browse files
committed
Add publish workflow to publish to PyPI and GHCR
1 parent 92fa7e1 commit 473dfd7

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!dist/*.whl

.github/workflows/publish.yaml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Publish to PyPI and GHCR
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
jobs:
7+
build-and-publish:
8+
runs-on: ubuntu-latest
9+
environment:
10+
name: pypi
11+
url: 'https://pypi.org/p/pypi-browser-webapp'
12+
permissions:
13+
attestations: write
14+
id-token: write
15+
packages: write
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.13'
21+
- name: Install dependencies
22+
run: pip install build
23+
- name: Build Python artifacts
24+
run: python -m build --sdist --wheel --outdir dist
25+
- name: Publish to PyPI
26+
uses: pypa/gh-action-pypi-publish@release/v1
27+
with:
28+
skip-existing: true
29+
- name: Login to GitHub Container Registry
30+
uses: docker/login-action@v3
31+
with:
32+
registry: ghcr.io
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
- name: Retrieve wheel name
36+
id: wheel
37+
run: echo "WHEEL=$(ls dist/*.whl)" >> $GITHUB_OUTPUT
38+
- name: Build and push Docker image
39+
uses: docker/build-push-action@v6
40+
with:
41+
context: .
42+
build-args: |
43+
WHEEL=${{ steps.wheel.outputs.WHEEL }}
44+
tags: |
45+
ghcr.io/chriskuehl/pypi-browser:latest
46+
ghcr.io/chriskuehl/pypi-browser:${{ github.ref_name }}
47+
push: true

Dockerfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM public.ecr.aws/docker/library/python:3.13
2+
RUN apt-get update && apt-get install -y dumb-init && apt-get clean
3+
ARG WHEEL
4+
COPY "$WHEEL" /tmp/
5+
USER nobody
6+
RUN python -m venv /tmp/venv
7+
RUN /tmp/venv/bin/pip install /tmp/*.whl uvicorn
8+
VOLUME /cache
9+
ENV PYPI_BROWSER_PACKAGE_CACHE_PATH=/cache
10+
CMD ["/usr/bin/dumb-init", "/tmp/venv/bin/uvicorn", "--forwarded-allow-ips=*", "--host", "0.0.0.0", "pypi_browser.app:app"]

0 commit comments

Comments
 (0)