@@ -9,83 +9,171 @@ permissions:
99 contents : read
1010 packages : write
1111
12+ env :
13+ DOCKERHUB_IMAGE : cy01/blackhole
14+ GHCR_IMAGE : ghcr.io/${{ github.repository_owner }}/decypharr
15+
1216jobs :
13- docker :
17+ prepare :
1418 runs-on : ubuntu-latest
19+ outputs :
20+ beta_version : ${{ steps.calculate_version.outputs.beta_version }}
1521 steps :
1622 - name : Checkout repository
1723 uses : actions/checkout@v4
1824 with :
1925 fetch-depth : 0
2026
21- - name : Set up Go
22- uses : actions/setup-go@v5
23- with :
24- go-version : ' 1.25'
25- cache : true
26-
2727 - name : Calculate beta version
2828 id : calculate_version
2929 run : |
3030 LATEST_TAG=$(git tag | grep -v 'beta' | sort -V | tail -n1)
3131 echo "Found latest tag: ${LATEST_TAG}"
32-
32+
3333 IFS='.' read -r -a VERSION_PARTS <<< "$LATEST_TAG"
3434 MAJOR="${VERSION_PARTS[0]}"
3535 MINOR="${VERSION_PARTS[1]}"
3636 PATCH="${VERSION_PARTS[2]}"
37-
37+
3838 NEW_PATCH=$((PATCH + 1))
3939 BETA_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
40-
40+
4141 echo "Calculated beta version: ${BETA_VERSION}"
42- echo "beta_version=${BETA_VERSION}" >> $GITHUB_ENV
42+ echo "beta_version=${BETA_VERSION}" >> $GITHUB_OUTPUT
43+
44+ build :
45+ needs : prepare
46+ runs-on : ubuntu-latest
47+ strategy :
48+ matrix :
49+ platform :
50+ - linux/amd64
51+ - linux/arm64
52+ steps :
53+ - name : Prepare platform pair
54+ run : |
55+ platform=${{ matrix.platform }}
56+ echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
57+
58+ - name : Checkout repository
59+ uses : actions/checkout@v4
4360
4461 - name : Set up QEMU
4562 uses : docker/setup-qemu-action@v3
4663
4764 - name : Set up Docker Buildx
4865 uses : docker/setup-buildx-action@v3
4966
50- - name : Cache Docker layers
51- uses : actions/cache@v3
52- with :
53- path : /tmp/.buildx-cache
54- key : ${{ runner.os }}-buildx-${{ github.sha }}
55- restore-keys : |
56- ${{ runner.os }}-buildx-
57-
58- # Login to Docker Hub
5967 - name : Login to Docker Hub
6068 uses : docker/login-action@v3
6169 with :
6270 username : ${{ secrets.DOCKERHUB_USERNAME }}
6371 password : ${{ secrets.DOCKERHUB_TOKEN }}
6472
65- # Login to GitHub Container Registry
6673 - name : Login to GitHub Container Registry
6774 uses : docker/login-action@v3
6875 with :
6976 registry : ghcr.io
7077 username : ${{ github.repository_owner }}
7178 password : ${{ secrets.GITHUB_TOKEN }}
7279
73- - name : Build and push beta Docker image
74- uses : docker/build-push-action@v5
80+ - name : Build and push by digest (Docker Hub)
81+ id : build_dockerhub
82+ uses : docker/build-push-action@v6
83+ with :
84+ context : .
85+ platforms : ${{ matrix.platform }}
86+ build-args : |
87+ VERSION=${{ needs.prepare.outputs.beta_version }}
88+ CHANNEL=beta
89+ cache-from : type=gha,scope=build-${{ env.PLATFORM_PAIR }}
90+ cache-to : type=gha,scope=build-${{ env.PLATFORM_PAIR }},mode=max
91+ outputs : type=image,name=${{ env.DOCKERHUB_IMAGE }},push-by-digest=true,name-canonical=true,push=true
92+
93+ - name : Build and push by digest (GHCR)
94+ id : build_ghcr
95+ uses : docker/build-push-action@v6
7596 with :
7697 context : .
77- platforms : linux/amd64,linux/arm64
78- push : true
79- tags : |
80- cy01/blackhole:beta
81- ghcr.io/${{ github.repository_owner }}/decypharr:beta
82- cache-from : type=local,src=/tmp/.buildx-cache
83- cache-to : type=local,dest=/tmp/.buildx-cache-new,mode=max
98+ platforms : ${{ matrix.platform }}
8499 build-args : |
85- VERSION=${{ env .beta_version }}
100+ VERSION=${{ needs.prepare.outputs .beta_version }}
86101 CHANNEL=beta
102+ cache-from : type=gha,scope=build-${{ env.PLATFORM_PAIR }}
103+ outputs : type=image,name=${{ env.GHCR_IMAGE }},push-by-digest=true,name-canonical=true,push=true
104+
105+ - name : Export digests
106+ run : |
107+ mkdir -p /tmp/digests/dockerhub /tmp/digests/ghcr
108+
109+ dockerhub_digest="${{ steps.build_dockerhub.outputs.digest }}"
110+ echo "Docker Hub digest: ${dockerhub_digest}"
111+ touch "/tmp/digests/dockerhub/${dockerhub_digest#sha256:}"
112+
113+ ghcr_digest="${{ steps.build_ghcr.outputs.digest }}"
114+ echo "GHCR digest: ${ghcr_digest}"
115+ touch "/tmp/digests/ghcr/${ghcr_digest#sha256:}"
116+
117+ - name : Upload Docker Hub digest
118+ uses : actions/upload-artifact@v4
119+ with :
120+ name : digests-dockerhub-${{ env.PLATFORM_PAIR }}
121+ path : /tmp/digests/dockerhub/*
122+ if-no-files-found : error
123+ retention-days : 1
124+
125+ - name : Upload GHCR digest
126+ uses : actions/upload-artifact@v4
127+ with :
128+ name : digests-ghcr-${{ env.PLATFORM_PAIR }}
129+ path : /tmp/digests/ghcr/*
130+ if-no-files-found : error
131+ retention-days : 1
132+
133+ merge :
134+ needs : build
135+ runs-on : ubuntu-latest
136+ steps :
137+ - name : Download Docker Hub digests
138+ uses : actions/download-artifact@v4
139+ with :
140+ path : /tmp/digests/dockerhub
141+ pattern : digests-dockerhub-*
142+ merge-multiple : true
143+
144+ - name : Download GHCR digests
145+ uses : actions/download-artifact@v4
146+ with :
147+ path : /tmp/digests/ghcr
148+ pattern : digests-ghcr-*
149+ merge-multiple : true
150+
151+ - name : Set up Docker Buildx
152+ uses : docker/setup-buildx-action@v3
153+
154+ - name : Login to Docker Hub
155+ uses : docker/login-action@v3
156+ with :
157+ username : ${{ secrets.DOCKERHUB_USERNAME }}
158+ password : ${{ secrets.DOCKERHUB_TOKEN }}
159+
160+ - name : Login to GitHub Container Registry
161+ uses : docker/login-action@v3
162+ with :
163+ registry : ghcr.io
164+ username : ${{ github.repository_owner }}
165+ password : ${{ secrets.GITHUB_TOKEN }}
166+
167+ - name : Create Docker Hub manifest and push
168+ working-directory : /tmp/digests/dockerhub
169+ run : |
170+ docker buildx imagetools create \
171+ --tag ${{ env.DOCKERHUB_IMAGE }}:beta \
172+ $(printf '${{ env.DOCKERHUB_IMAGE }}@sha256:%s ' *)
87173
88- - name : Move cache
174+ - name : Create GHCR manifest and push
175+ working-directory : /tmp/digests/ghcr
89176 run : |
90- rm -rf /tmp/.buildx-cache
91- mv /tmp/.buildx-cache-new /tmp/.buildx-cache
177+ docker buildx imagetools create \
178+ --tag ${{ env.GHCR_IMAGE }}:beta \
179+ $(printf '${{ env.GHCR_IMAGE }}@sha256:%s ' *)
0 commit comments