Skip to content

Commit 81df42f

Browse files
authored
ci: add ci job for publishing image to ghcr.io (#665)
close #658
1 parent 2c7cf1b commit 81df42f

File tree

4 files changed

+56
-17
lines changed

4 files changed

+56
-17
lines changed

.github/workflows/release.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,53 @@ jobs:
4848
path: dist/
4949
- name: Publish distribution to PyPI
5050
uses: pypa/gh-action-pypi-publish@release/v1
51+
52+
build-and-push-image:
53+
# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#publishing-a-package-using-an-action
54+
runs-on: ubuntu-latest
55+
56+
permissions:
57+
contents: read
58+
packages: write
59+
attestations: write
60+
id-token: write
61+
62+
env:
63+
REGISTRY: ghcr.io
64+
IMAGE_NAME: ${{ github.repository_owner }}/variation-normalizer-api
65+
66+
steps:
67+
- name: Checkout repository
68+
uses: actions/checkout@v6
69+
70+
- name: Log in to GHCR
71+
uses: docker/login-action@v3
72+
with:
73+
registry: ${{ env.REGISTRY }}
74+
username: ${{ github.actor }}
75+
password: ${{ secrets.GITHUB_TOKEN }}
76+
77+
- name: Extract metadata (tags, labels) for Docker
78+
id: meta
79+
uses: docker/metadata-action@v5
80+
with:
81+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
82+
tags: |
83+
type=raw,value=latest,enable=${{ !github.event.release.prerelease }}
84+
type=semver,pattern={{version}}
85+
86+
- name: Build and push Docker image
87+
id: push
88+
uses: docker/build-push-action@v6
89+
with:
90+
context: .
91+
push: true
92+
tags: ${{ steps.meta.outputs.tags }}
93+
labels: ${{ steps.meta.outputs.labels }}
94+
95+
- name: Generate artifact attestation
96+
uses: actions/attest-build-provenance@v3
97+
with:
98+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
99+
subject-digest: ${{ steps.push.outputs.digest }}
100+
push-to-registry: true

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
# Health checks service up every 5m.
44
FROM python:3.12-slim
55

6+
LABEL org.opencontainers.image.source=https://github.com/cancervariants/variation-normalization
7+
LABEL org.opencontainers.image.description="Variation Normalizer API container image"
8+
LABEL org.opencontainers.image.licenses=MIT
9+
610
WORKDIR /app
711

812
ARG VERSION

README.md

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -216,19 +216,4 @@ Note that dev/testing dependencies only need to be updated in `pyproject.toml`.
216216
### Creating a new release
217217

218218
1. Version number must be updated manually. It's declared under `project.version` in `pyproject.toml`. Ensure that the version value for the Docker image in `compose.yaml` is similarly updated.
219-
2. Once a commit with an updated version is merged to the `staging` branch, create a new tag + GitHub release (from the `staging` branch). This triggers the PyPI publishing workflow. Presently, new commits to staging should not be merged to `main`.
220-
3. Pull down all changes (including the latest git tag) to your local environment:
221-
222-
```shell
223-
git fetch -a
224-
```
225-
226-
4. Create a new Docker image on the cancervariants Dockerhub profile:
227-
228-
```shell
229-
export DOCKERHUB_ORG=cancervariants
230-
export VERSION=$(git describe --tags --abbrev=0)
231-
docker build --build-arg VERSION=$VERSION -t $DOCKERHUB_ORG/variation-normalizer-api:$VERSION -t $DOCKERHUB_ORG/variation-normalizer-api:latest .
232-
docker push $DOCKERHUB_ORG/variation-normalizer-api:$VERSION
233-
docker push $DOCKERHUB_ORG/variation-normalizer-api:latest
234-
```
219+
2. Once a commit with an updated version is merged to the `staging` branch, create a new tag + GitHub release (from the `staging` branch). This triggers the PyPI and GHCR publishing workflows. Presently, new commits to staging should not be merged to `main`.

compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
api:
3-
image: cancervariants/variation-normalizer-api:0.15.5
3+
image: ghcr.io/cancervariants/variation-normalizer-api:0.15.5
44
environment:
55
SEQREPO_ROOT_DIR: /usr/local/share/seqrepo/2024-12-20
66
# Dummy AWS credentials, don't need to use real ones

0 commit comments

Comments
 (0)