Skip to content

Commit

Permalink
feat: proper versioning and create a release
Browse files Browse the repository at this point in the history
  • Loading branch information
listlessbird committed Nov 6, 2024
1 parent 4d49549 commit a8f13cf
Showing 1 changed file with 59 additions and 29 deletions.
88 changes: 59 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Build and Publish Docker Images

on:
push:
branches: ["release"]
Expand All @@ -13,65 +15,93 @@ jobs:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
contents: write
id-token: write

steps:
- name: checkout
uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: docker meta
id: meta
- name: Docker meta for renderer
id: meta-renderer
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-renderer
tags: |
type=raw,value=latest
type=sha,prefix={{date 'YYYYMMDD'}}-
type=ref,event=branch
type=ref,event=pr
- name: Docker meta for web-app
id: meta-web
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'release') }}
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-web
tags: |
type=raw,value=latest
type=sha,prefix={{date 'YYYYMMDD'}}-
type=ref,event=branch
type=ref,event=pr
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3

- name: Login to registry
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push renderer
id: push-renderer
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
context: ./renderer
file: ./renderer/dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta-renderer.outputs.tags }}
labels: ${{ steps.meta-renderer.outputs.labels }}
provenance: true

- name: Build and push web-app
id: push-web
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
context: ./web
file: ./web/dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta-web.outputs.tags }}
labels: ${{ steps.meta-web.outputs.labels }}
provenance: true

- name: Generate artifact attestation for renderer
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}-renderer
subject-digest: ${{ steps.push-renderer.outputs.digest }}
push-to-registry: true
- name: Extract version
id: version
run: echo "VERSION=$(date +'%Y%m%d')-${GITHUB_SHA::8}" >> $GITHUB_OUTPUT

- name: Generate artifact attestation for web-app
uses: actions/attest-build-provenance@v1
- name: Create GitHub Release
if: github.event_name == 'push' && github.ref == 'refs/heads/release'
uses: softprops/action-gh-release@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}-web
subject-digest: ${{ steps.push-web.outputs.digest }}
push-to-registry: true
tag_name: v${{ steps.version.outputs.VERSION }}
name: "Release ${{ steps.version.outputs.VERSION }}"
body: |
Automated release generated on $(date +'%Y-%m-%d')
Docker Images:
- Renderer: `${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-renderer:latest`
- Web App: `${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-web:latest`
Image Digests:
- Renderer: `${{ steps.push-renderer.outputs.digest }}`
- Web App: `${{ steps.push-web.outputs.digest }}`
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit a8f13cf

Please sign in to comment.