Skip to content

Commit b5a625b

Browse files
authored
Add CI job to build and push docker images on GHCR for new versions (#423)
Introduces a new GitHub Actions job to build and publish Docker images for tagged releases. The workflow logs in to the GitHub Container Registry, generates metadata, sets up Buildx, and pushes the images with appropriate tags and caching. This change streamlines Docker image distribution for the repository. Refers to #290 Pipeline have been tested in fork and a test image have been built. Can be tested with the following command : ```bash docker run ghcr.io/alphayax/squawk:1.6.1-alpha ``` Test artifact is available in fork here : https://github.com/alphayax/squawk/pkgs/container/squawk/403247135?tag=1.6.1-alpha
1 parent 6056f5f commit b5a625b

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.github/workflows/rust.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,55 @@ jobs:
205205
env:
206206
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
207207

208+
publish-docker:
209+
if: startsWith(github.ref, 'refs/tags/')
210+
needs: [build-linux-x64, build-mac, build-windows]
211+
runs-on: ubuntu-22.04
212+
permissions:
213+
contents: read
214+
packages: write
215+
attestations: write
216+
id-token: write
217+
env:
218+
REGISTRY: ghcr.io
219+
IMAGE_NAME: ${{ github.repository }}
220+
steps:
221+
- name: Checkout
222+
uses: actions/checkout@v4
223+
224+
- name: Log in to the Container registry
225+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
226+
with:
227+
registry: ${{ env.REGISTRY }}
228+
username: ${{ github.actor }}
229+
password: ${{ secrets.GITHUB_TOKEN }}
230+
231+
- name: Extract metadata for Docker
232+
id: meta
233+
uses: docker/metadata-action@v5
234+
with:
235+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
236+
tags: |
237+
type=semver,pattern={{version}}
238+
type=semver,pattern={{major}}.{{minor}}
239+
type=semver,pattern={{major}}
240+
type=raw,value=latest
241+
type=ref,event=branch
242+
type=sha
243+
244+
- name: Set up Docker Buildx
245+
uses: docker/setup-buildx-action@v3
246+
247+
- name: Build and push Docker image
248+
uses: docker/build-push-action@v5
249+
with:
250+
context: .
251+
push: true
252+
tags: ${{ steps.meta.outputs.tags }}
253+
labels: ${{ steps.meta.outputs.labels }}
254+
cache-from: type=gha
255+
cache-to: type=gha,mode=max
256+
208257
lint:
209258
needs: pre_job
210259
if: needs.pre_job.outputs.should_skip != 'true'

0 commit comments

Comments
 (0)