From a9524b5cf47424efe813125ad3b74e310c409af0 Mon Sep 17 00:00:00 2001 From: Christoph Stahl Date: Sun, 6 Oct 2024 15:24:10 +0200 Subject: [PATCH] Automatically build and publish docker files (hopefully) --- ...yinstaller.yaml => build-and-publish.yaml} | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) rename .github/workflows/{windows-pyinstaller.yaml => build-and-publish.yaml} (65%) diff --git a/.github/workflows/windows-pyinstaller.yaml b/.github/workflows/build-and-publish.yaml similarity index 65% rename from .github/workflows/windows-pyinstaller.yaml rename to .github/workflows/build-and-publish.yaml index e30fa88..b4a2342 100644 --- a/.github/workflows/windows-pyinstaller.yaml +++ b/.github/workflows/build-and-publish.yaml @@ -1,4 +1,4 @@ -name: Build for windows +name: Build for windows and docker and create a release # Controls when the workflow will run on: @@ -11,10 +11,14 @@ on: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: # This workflow contains a single job called "build" - build: + build-windows: # The type of runner that the job will run on runs-on: windows-latest @@ -75,3 +79,45 @@ jobs: with: name: Syng Version ${{ env.VERSION }} path: work/dist/syng-${{ env.VERSION }}.exe + docker: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + attestations: write + id-token: write + + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + repository: christofsteel/syng + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Build and push Docker image + id: push + uses: docker/build-push-action@v3 + with: + context: . + file: ./resources/docker/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v1 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true + +