Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: set up docker image build workflow #89

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/templates/.release_notes.md.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@
## Release Notes
{% include ".changes.j2" %}
{{ "**Full Changelog**: (%s)" | format(prev_version | compare_url(version)) }}

## Installation

You can install this version via pip from [PyPI](https://pypi.org/project/python-re3data/{{ version }}/):

```console
python -m pip install python-re3data=={{ version }}
```

or pull the Docker image from [ghcr.io](https://github.com/afuetterer/python-re3data/pkgs/container/python-re3data):

```console
docker pull ghcr.io/afuetterer/python-re3data:{{ version }}
```
42 changes: 42 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,45 @@ jobs:
path: dist
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14

docker:
name: Publish Docker image to ghcr.io
# disables this workflow from running in a repository that is not part of the indicated organization/user
if: github.repository_owner == 'afuetterer'
runs-on: ubuntu-24.04
needs: build
permissions:
contents: read
packages: write
env:
IMAGE_NAME: ${{ github.repository }}
steps:
- uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
- name: Login to GitHub Container Registry
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Docker image metadata
id: meta
# Ref: https://github.com/docker/metadata-action?tab=readme-ov-file#customizing
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: ghcr.io/${{ env.IMAGE_NAME }}
flavor: latest=true
tags: |
type=pep440,pattern={{version}}
type=pep440,pattern={{major}}.{{minor}}
- name: Build and push image to registry
# Ref: https://github.com/docker/build-push-action?tab=readme-ov-file#customizing
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
with:
push: true
build-args: VERSION=${{ github.event.release.name }}
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Ref: https://docs.docker.com/build/attestations/slsa-provenance/
provenance: false
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ You can install `python-re3data` via pip from [PyPI][pypi-url]:
python -m pip install python-re3data
```

or pull the Docker image from [ghcr.io](https://github.com/afuetterer/python-re3data/pkgs/container/python-re3data):

```console
docker pull ghcr.io/afuetterer/python-re3data:latest
```

## Documentation

The [documentation][docs-url] is made with [Material for MkDocs](https://github.com/squidfunk/mkdocs-material) and is
Expand Down