Skip to content

Commit

Permalink
πŸ› Fix CI buid tagging
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDanniCraft committed Oct 30, 2024
1 parent 4834656 commit f129707
Showing 1 changed file with 70 additions and 18 deletions.
88 changes: 70 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,21 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
architecture: [amd64, arm64]
architecture: [linux/amd64, linux/arm64]

steps:
- name: πŸ”‘ Set lowercase repository name
id: repoLower
run: echo "REPO_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: πŸ”‘ Prepare env
id: prepareEnv
run: |
echo "REPO_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: 🐳 Docker Meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REPO_NAME }}

- name: πŸ“₯ Check out the repository
uses: actions/checkout@v4
Expand All @@ -38,27 +47,70 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: πŸš€ Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.tag }}
name: Release ${{ github.event.inputs.tag }}
body: ${{ github.event.inputs.release_description }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: πŸ” Verify Dockerfile exists
run: test -f Dockerfile

- name: πŸ”§ Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: πŸ—οΈ Build and push
- name: πŸ“¦ Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
platforms: ${{ matrix.architecture }}
context: .
push: true
tags: |
ghcr.io/${{ env.REPO_NAME }}:${{ github.event.inputs.tag }}
ghcr.io/${{ env.REPO_NAME }}:latest
platforms: linux/${{ matrix.architecture }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=ghcr.io/${{ env.REPO_NAME }},push-by-digest=true,name-canonical=true,push=true

- name: πŸ“œ Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: πŸ“€ Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
needs:
- build-and-push
steps:
- name: πŸ“₯ Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true

- name: πŸ”§ Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: 🐳 Docker Meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ env.REPO_NAME }}

- name: πŸ”‘ Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: πŸ“¦ Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf 'ghcr.io/${{ env.REPO_NAME }}@sha256:%s ' *)
- name: πŸ” Inspect image
run: |
docker buildx imagetools inspect ghcr.io/${{ env.REPO_NAME }}:${{ steps.meta.outputs.version }}

0 comments on commit f129707

Please sign in to comment.