From 2b0502babdb1950d34e8e2ff855d928d3c0763bf Mon Sep 17 00:00:00 2001 From: CoderDeltaLan Date: Tue, 16 Sep 2025 07:36:44 +0100 Subject: [PATCH 1/2] ci(release): publish to PyPI and GHCR on tag --- .github/workflows/release.yml | 44 +++++++++++++++++++++++++++++++++++ Dockerfile | 5 ++++ 2 files changed, 49 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 Dockerfile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a59599a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,44 @@ +name: release +on: + push: + tags: ['v*'] +permissions: + contents: write + packages: write +jobs: + build-publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: { python-version: '3.12' } + - name: Build + run: | + python -m pip install -U pip build + python -m build + - uses: actions/upload-artifact@v4 + with: { name: dist, path: dist/* } + - name: Publish to PyPI + if: startsWith(github.ref, 'refs/tags/v') + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} + publish-ghcr: + needs: build-publish + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:${{ github.ref_name }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..457e7bc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM python:3.12-slim +WORKDIR /app +COPY . /app +RUN pip install --no-cache-dir . +ENTRYPOINT ["python","-m","diff_risk_dashboard"] From eb32b73913806dd1576014493be84ac9b6587f52 Mon Sep 17 00:00:00 2001 From: CoderDeltaLan Date: Tue, 16 Sep 2025 08:05:40 +0100 Subject: [PATCH 2/2] ci(release): guard PyPI when no PYPI_API_TOKEN --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a59599a..405f6cb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/upload-artifact@v4 with: { name: dist, path: dist/* } - name: Publish to PyPI - if: startsWith(github.ref, 'refs/tags/v') + if: startsWith(github.ref, 'refs/tags/v') && secrets.PYPI_API_TOKEN != '' uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__