Skip to content

Commit e93e907

Browse files
committed
Publish the docker image to Docker Hub + GHCR on release
Same pattern as sigennut (built and debugged there first): a workflow_call target release.yml invokes directly as a second job in the same run, not via the release event (GITHUB_TOKEN-authored events don't trigger other workflows), plus workflow_dispatch for backfilling already-tagged versions. Multi-arch (linux/amd64,linux/arm64) -- python:3.12-slim and every dependency in requirements.txt already ship aarch64 wheels, so this should build meaningfully faster than sigennut's autotools-from-source image did under QEMU. Needs the DOCKERHUB_USERNAME/DOCKERHUB_TOKEN repo secrets (already added). GHCR needs no secret -- uses GITHUB_TOKEN.
1 parent 16939c7 commit e93e907

2 files changed

Lines changed: 78 additions & 0 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Docker publish
2+
3+
# Called directly from release.yml as a second job in the *same*
4+
# workflow run (workflow_call), not triggered by the release event
5+
# itself -- GitHub's anti-recursion rule means events performed with
6+
# the default GITHUB_TOKEN (which release.yml uses to create the
7+
# release) never trigger other workflows, confirmed empirically in
8+
# sigennut before this repo got the same fix.
9+
#
10+
# workflow_dispatch lets this be re-run by hand for any already-tagged
11+
# version, e.g. to backfill a release that predates this workflow:
12+
# gh workflow run docker-publish.yml -f version=0.1.0
13+
14+
on:
15+
workflow_call:
16+
inputs:
17+
version:
18+
required: true
19+
type: string
20+
workflow_dispatch:
21+
inputs:
22+
version:
23+
description: "Version to build and push (must match an existing git tag)"
24+
required: true
25+
type: string
26+
27+
permissions:
28+
contents: read
29+
packages: write
30+
31+
jobs:
32+
build-and-push:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v4
36+
with:
37+
ref: ${{ inputs.version }}
38+
39+
- uses: docker/setup-qemu-action@v3
40+
- uses: docker/setup-buildx-action@v3
41+
42+
- name: Log in to Docker Hub
43+
uses: docker/login-action@v3
44+
with:
45+
username: ${{ secrets.DOCKERHUB_USERNAME }}
46+
password: ${{ secrets.DOCKERHUB_TOKEN }}
47+
48+
- name: Log in to GHCR
49+
uses: docker/login-action@v3
50+
with:
51+
registry: ghcr.io
52+
username: ${{ github.actor }}
53+
password: ${{ secrets.GITHUB_TOKEN }}
54+
55+
- name: Build and push
56+
uses: docker/build-push-action@v6
57+
with:
58+
context: .
59+
file: Dockerfile
60+
platforms: linux/amd64,linux/arm64
61+
push: true
62+
tags: |
63+
miklosbagi/invforge:${{ inputs.version }}
64+
miklosbagi/invforge:latest
65+
ghcr.io/miklosbagi/invforge:${{ inputs.version }}
66+
ghcr.io/miklosbagi/invforge:latest

‎.github/workflows/release.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ on:
1616

1717
permissions:
1818
contents: write
19+
packages: write
1920

2021
jobs:
2122
tag-and-release:
2223
if: github.event.pull_request.merged == true
2324
runs-on: ubuntu-latest
25+
outputs:
26+
new_version: ${{ steps.version.outputs.new_version }}
27+
skip: ${{ steps.bump.outputs.skip }}
2428
steps:
2529
- uses: actions/checkout@v4
2630
with:
@@ -81,3 +85,11 @@ jobs:
8185
--target "${{ github.event.pull_request.merge_commit_sha }}" \
8286
--title "${{ steps.version.outputs.new_version }}" \
8387
--generate-notes
88+
89+
docker-publish:
90+
needs: tag-and-release
91+
if: needs.tag-and-release.outputs.skip != 'true'
92+
uses: ./.github/workflows/docker-publish.yml
93+
with:
94+
version: ${{ needs.tag-and-release.outputs.new_version }}
95+
secrets: inherit

0 commit comments

Comments
 (0)