Skip to content

Commit 7e2ebf8

Browse files
committed
publish docker on release
1 parent 4f7a160 commit 7e2ebf8

File tree

4 files changed

+39
-176
lines changed

4 files changed

+39
-176
lines changed

.github/workflows/binder.yaml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/docker.yaml

Lines changed: 0 additions & 61 deletions
This file was deleted.

.github/workflows/wheels.yaml

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,11 @@ jobs:
230230
fi
231231
done
232232
233-
upload-test-pypi:
234-
name: Upload wheels to Test PyPI
233+
upload-pypi:
234+
name: Upload wheels to PyPI
235235
needs: [sdist, wheels, check-wheels-size]
236236
runs-on: ubuntu-latest
237-
if:
238-
(github.event_name == 'release' && github.event.action == 'published') ||
239-
github.event.inputs.publish_to_test_pypi == 'true'
237+
if: github.event_name == 'release' && github.event.action == 'published'
240238

241239
steps:
242240
- name: Setup Python
@@ -250,31 +248,47 @@ jobs:
250248
name: dist
251249
path: dist
252250

253-
- name: Publish to Test PyPI
251+
- name: Publish to PyPI
254252
uses: pypa/[email protected]
255253
with:
256-
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
257-
repository-url: https://test.pypi.org/legacy/
254+
password: ${{ secrets.PYPI_API_TOKEN }}
258255

259-
upload-pypi:
260-
name: Upload wheels to PyPI
261-
needs: [sdist, wheels, check-wheels-size]
256+
publish-docker:
257+
name: Publish Docker image
258+
needs: [upload-pypi]
262259
runs-on: ubuntu-latest
263-
if: github.event_name == 'release' && github.event.action == 'published'
260+
permissions:
261+
contents: read
262+
packages: write
264263

265264
steps:
266-
- name: Setup Python
267-
uses: actions/setup-python@v5
268-
with:
269-
python-version: 3.11
265+
- uses: actions/checkout@v4
270266

271-
- name: Download wheels
272-
uses: actions/download-artifact@v3
267+
- name: Log in to the GitHub Container registry
268+
uses: docker/login-action@v3
273269
with:
274-
name: dist
275-
path: dist
270+
registry: ghcr.io
271+
username: ${{ github.actor }}
272+
password: ${{ secrets.CONTAINER_REGISTRY_GITHUB_TOKEN }}
276273

277-
- name: Publish to PyPI
278-
uses: pypa/[email protected]
274+
- name: Build Docker image
275+
uses: docker/build-push-action@v5
279276
with:
280-
password: ${{ secrets.PYPI_API_TOKEN }}
277+
context: .
278+
push: false
279+
tags: |
280+
ghcr.io/lobis/geant4-python-application:latest
281+
ghcr.io/lobis/geant4-python-application:${{ github.event.release.tag_name }}
282+
283+
labels: |
284+
maintainer.name=Luis Antonio Obis Aparicio
285+
286+
org.opencontainers.image.source=${{ github.repository }}
287+
288+
- name: Test image
289+
run: |
290+
docker run --rm ghcr.io/lobis/geant4-python-application:latest -c 'import geant4_python_application; app = geant4_python_application.Application()'
291+
292+
- name: Publish
293+
run: |
294+
docker push ghcr.io/lobis/geant4-python-application:latest

Dockerfile

Lines changed: 2 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,5 @@
1-
FROM python:3.11-slim-bullseye as builder
1+
FROM python:3.12-slim-bullseye as builder
22

3-
RUN apt-get update -qq && apt-get install -q -y --no-install-recommends \
4-
build-essential ninja-build git \
5-
&& apt-get clean \
6-
&& rm -rf /var/lib/apt/lists/*
7-
8-
# Install a more recent CMake version
9-
RUN pip install cmake
10-
11-
ARG CMAKE_CXX_STANDARD=20
12-
ARG GEANT4_VERSION=11.1.3
13-
ARG XERCES_VERSION=3.2.4
14-
15-
RUN git clone https://github.com/apache/xerces-c.git /tmp/xerces \
16-
&& git -C /tmp/xerces checkout tags/v${XERCES_VERSION} \
17-
&& cmake -G Ninja -B /tmp/xerces/build -S /tmp/xerces \
18-
-DCMAKE_INSTALL_PREFIX=/opt/xerces \
19-
-DCMAKE_CXX_STANDARD=20 \
20-
-DCMAKE_BUILD_TYPE=Release \
21-
-DBUILD_SHARED_LIBS=OFF \
22-
-Dnetwork-accessor=socket \
23-
-Dtranscoder=iconv \
24-
-DCMAKE_CXX_FLAGS=-fPIC \
25-
-DCMAKE_C_FLAGS=-fPIC \
26-
&& cmake --build /tmp/xerces/build -j$(nproc) --target install \
27-
&& rm -rf /tmp/xerces
28-
29-
RUN git clone https://github.com/Geant4/geant4.git /tmp/geant4 --branch=v${GEANT4_VERSION} --depth=1 \
30-
&& cmake -G Ninja -B /tmp/geant4/build -S /tmp/geant4 \
31-
-DCMAKE_INSTALL_PREFIX=/opt/geant4 \
32-
-DXERCESC_ROOT_DIR=/opt/xerces \
33-
-DCMAKE_CXX_STANDARD=20 \
34-
-DCMAKE_BUILD_TYPE=Release \
35-
-DGEANT4_USE_GDML=ON \
36-
-DGEANT4_INSTALL_EXAMPLES=OFF \
37-
-DGEANT4_INSTALL_DATA=OFF \
38-
-DGEANT4_BUILD_TLS_MODEL=global-dynamic \
39-
-DCMAKE_CXX_FLAGS=-fPIC \
40-
-DCMAKE_C_FLAGS=-fPIC \
41-
-DGEANT4_USE_SYSTEM_EXPAT=OFF \
42-
-DBUILD_STATIC_LIBS=ON \
43-
-DBUILD_SHARED_LIBS=OFF \
44-
&& cmake --build /tmp/geant4/build -j$(nproc) --target install \
45-
&& rm -rf /tmp/geant4
46-
47-
COPY . /source
48-
49-
# Build and install
50-
RUN bash /opt/geant4/bin/geant4.sh \
51-
&& pip install /source \
52-
&& rm -rf /source
53-
54-
# Create the final image
55-
FROM python:3.11-slim-bullseye
56-
57-
# Copy installed Python package from the builder image
58-
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
3+
RUN python -m pip install --no-cache-dir geant4-python-application
594

605
ENTRYPOINT ["python"]

0 commit comments

Comments
 (0)