Merge branch 'main' of https://github.com/JanisV/release-bot #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and publish Docker image | |
on: | |
push: | |
branches: [ main ] | |
release: | |
types: [published] | |
concurrency: | |
group: ${{ github.workflow }} | |
cancel-in-progress: true | |
env: | |
REGISTRY: ghcr.io | |
REGISTRY_USER: ${{ github.repository_owner }} | |
REGISTRY_PASS: ${{ secrets.GITHUB_TOKEN }} | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build-docker: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
steps: | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Bump commit version | |
if: github.event_name == 'push' | |
shell: bash | |
run: | | |
python -m pip install bump-my-version | |
bump-my-version bump commit --no-commit --verbose --serialize "{major}.{minor}.{patch}-{distance_to_latest_tag}" | |
- name: Login to ${{ env.REGISTRY }} registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ env.REGISTRY_USER }} | |
password: ${{ env.REGISTRY_PASS }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
#type=semver,pattern={{major}}.{{minor}} | |
#type=semver,pattern={{major}} | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |