Skip to content

Commit 8c48983

Browse files
committed
Allow builds outside of a release
1 parent e06b340 commit 8c48983

File tree

1 file changed

+14
-121
lines changed

1 file changed

+14
-121
lines changed

.github/workflows/release.yml

Lines changed: 14 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: release
22

33
on:
4+
workflow_dispatch:
45
release:
56
types:
67
- created
@@ -17,7 +18,7 @@ jobs:
1718
permissions:
1819
contents: read
1920
packages: write
20-
id-token: write # needed for the Vault authentication
21+
id-token: write
2122
steps:
2223
- name: Checkout
2324
uses: actions/checkout@v4
@@ -40,45 +41,13 @@ jobs:
4041
name: helm-controller-amd64
4142
path: ./dist/artifacts/*
4243

43-
- name: Set DOCKERHUB_REPO
44-
run: |
45-
if [ "${{ github.repository_owner }}" == "k3s-io" ]; then
46-
echo "DOCKERHUB_REPO=rancher/helm-controller" >> $GITHUB_ENV
47-
else
48-
echo "DOCKERHUB_REPO=${{ secrets.DOCKER_USERNAME }}/helm-controller" >> $GITHUB_ENV
49-
fi
50-
5144
- name: Docker source meta
5245
id: meta
5346
uses: docker/metadata-action@v5
5447
with:
5548
images: |
56-
${{ env.DOCKERHUB_REPO }}
5749
${{ env.GHCR_REPO }}
5850
59-
- name: "Read Vault secrets"
60-
if: github.repository_owner == 'k3s-io'
61-
uses: rancher-eio/read-vault-secrets@main
62-
with:
63-
secrets: |
64-
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ;
65-
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_TOKEN ;
66-
67-
- name: Login to DockerHub with Rancher Secrets
68-
if: github.repository_owner == 'k3s-io'
69-
uses: docker/login-action@v3
70-
with:
71-
username: ${{ env.DOCKER_USERNAME }}
72-
password: ${{ env.DOCKER_TOKEN }}
73-
74-
# For forks, setup DockerHub login with GHA secrets
75-
- name: Login to DockerHub with GHA Secrets
76-
if: github.repository_owner != 'k3s-io'
77-
uses: docker/login-action@v3
78-
with:
79-
username: ${{ secrets.DOCKER_USERNAME }}
80-
password: ${{ secrets.DOCKER_TOKEN }}
81-
8251
- name: Login to GitHub Container Registry
8352
uses: docker/login-action@v3
8453
with:
@@ -92,7 +61,7 @@ jobs:
9261
with:
9362
platforms: linux/amd64
9463
context: . # Required to see the new binary file we just built
95-
outputs: type=image,"name=${{ env.DOCKERHUB_REPO }},${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true
64+
outputs: type=image,"name=${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true
9665
target: production
9766

9867
- name: Export digest
@@ -118,11 +87,11 @@ jobs:
11887
permissions:
11988
contents: read
12089
packages: write
121-
id-token: write # needed for the Vault authentication
90+
id-token: write
12291
steps:
12392
- name: Checkout
12493
uses: actions/checkout@v4
125-
94+
12695
- name: Set ARCH
12796
run: |
12897
if [ ${{ matrix.platform }} = 'arm/v7' ]; then
@@ -141,66 +110,34 @@ jobs:
141110
run: |
142111
docker buildx build --platform linux/${{ matrix.platform }} --target binary --output type=local,dest=. .
143112
cp ./bin/helm-controller ./bin/helm-controller-${{ env.ARCH }}
144-
113+
145114
- name: Upload binary
146115
uses: actions/upload-artifact@v4
147116
with:
148117
name: helm-controller-${{ env.ARCH }}
149118
path: ./bin/helm-controller-${{ env.ARCH }}
150119

151-
- name: Set DOCKERHUB_REPO
152-
run: |
153-
if [ "${{ github.repository_owner }}" == "k3s-io" ]; then
154-
echo "DOCKERHUB_REPO=rancher/helm-controller" >> $GITHUB_ENV
155-
else
156-
echo "DOCKERHUB_REPO=${{ secrets.DOCKER_USERNAME }}/helm-controller" >> $GITHUB_ENV
157-
fi
158-
159120
- name: Docker source meta
160121
id: meta
161122
uses: docker/metadata-action@v5
162123
with:
163124
images: |
164-
${{ env.DOCKERHUB_REPO }}
165125
${{ env.GHCR_REPO }}
166126
167-
- name: "Read Vault secrets"
168-
if: github.repository_owner == 'k3s-io'
169-
uses: rancher-eio/read-vault-secrets@main
170-
with:
171-
secrets: |
172-
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ;
173-
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_TOKEN ;
174-
175-
- name: Login to DockerHub with Rancher Secrets
176-
if: github.repository_owner == 'k3s-io'
177-
uses: docker/login-action@v3
178-
with:
179-
username: ${{ env.DOCKER_USERNAME }}
180-
password: ${{ env.DOCKER_TOKEN }}
181-
182-
# For forks, setup DockerHub login with GHA secrets
183-
- name: Login to DockerHub with GHA Secrets
184-
if: github.repository_owner != 'k3s-io'
185-
uses: docker/login-action@v3
186-
with:
187-
username: ${{ secrets.DOCKER_USERNAME }}
188-
password: ${{ secrets.DOCKER_TOKEN }}
189-
190127
- name: Login to GitHub Container Registry
191128
uses: docker/login-action@v3
192129
with:
193130
registry: ghcr.io
194131
username: ${{ github.repository_owner }}
195132
password: ${{ secrets.GITHUB_TOKEN }}
196-
133+
197134
- name: Build and push by digest
198135
id: build
199136
uses: docker/build-push-action@v6
200137
with:
201138
platforms: linux/${{ matrix.platform }}
202139
context: . # Required to see the new binary file we just built
203-
outputs: type=image,"name=${{ env.DOCKERHUB_REPO }},${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true
140+
outputs: type=image,"name=${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true
204141
target: production
205142

206143
- name: Export digest
@@ -217,7 +154,7 @@ jobs:
217154
if-no-files-found: error
218155
retention-days: 1
219156

220-
test:
157+
test:
221158
runs-on: ubuntu-latest
222159
steps:
223160
- name: Checkout
@@ -230,11 +167,11 @@ jobs:
230167

231168
- name: Test
232169
run: go test ./pkg/... -cover -tags=test
233-
170+
234171
binary-release:
235172
needs: [build, build-arm, test]
236173
runs-on: ubuntu-latest
237-
permissions:
174+
permissions:
238175
contents: write # Needed to update release with binary assets
239176
steps:
240177
- name: Checkout
@@ -246,7 +183,7 @@ jobs:
246183
pattern: helm-controller-*
247184
path: ./dist/artifacts
248185
merge-multiple: true
249-
186+
250187
- name: Compute checksum for each binary
251188
run: |
252189
arch=("amd64" "arm64" "arm")
@@ -255,15 +192,6 @@ jobs:
255192
for a in "${arch[@]}"; do
256193
sha256sum helm-controller-"${a}" > sha256sum-"${a}".txt
257194
done
258-
259-
- name: Upload binaries to release
260-
uses: softprops/action-gh-release@v2
261-
with:
262-
files: |
263-
dist/artifacts/helm-controller-*
264-
dist/artifacts/*.txt
265-
dist/artifacts/deploy*
266-
token: ${{ secrets.GITHUB_TOKEN }}
267195
268196
merge-manifests:
269197
runs-on: ubuntu-latest
@@ -273,46 +201,15 @@ jobs:
273201
permissions:
274202
contents: read
275203
packages: write
276-
id-token: write # needed for the Vault authentication
204+
id-token: write
277205
steps:
278206
- name: Download digests
279207
uses: actions/download-artifact@v4
280208
with:
281209
path: ${{ runner.temp }}/digests
282210
pattern: digests-*
283211
merge-multiple: true
284-
285-
- name: Set DOCKERHUB_REPO
286-
run: |
287-
if [ "${{ github.repository_owner }}" == "k3s-io" ]; then
288-
echo "DOCKERHUB_REPO=rancher/helm-controller" >> $GITHUB_ENV
289-
else
290-
echo "DOCKERHUB_REPO=${{ secrets.DOCKER_USERNAME }}/helm-controller" >> $GITHUB_ENV
291-
fi
292212

293-
- name: "Read Vault secrets"
294-
if: github.repository_owner == 'k3s-io'
295-
uses: rancher-eio/read-vault-secrets@main
296-
with:
297-
secrets: |
298-
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ;
299-
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_TOKEN ;
300-
301-
- name: Login to DockerHub with Rancher Secrets
302-
if: github.repository_owner == 'k3s-io'
303-
uses: docker/login-action@v3
304-
with:
305-
username: ${{ env.DOCKER_USERNAME }}
306-
password: ${{ env.DOCKER_TOKEN }}
307-
308-
# For forks, setup DockerHub login with GHA secrets
309-
- name: Login to DockerHub with GHA Secrets
310-
if: github.repository_owner != 'k3s-io'
311-
uses: docker/login-action@v3
312-
with:
313-
username: ${{ secrets.DOCKER_USERNAME }}
314-
password: ${{ secrets.DOCKER_TOKEN }}
315-
316213
- name: Login to GitHub Container Registry
317214
uses: docker/login-action@v3
318215
with:
@@ -328,18 +225,14 @@ jobs:
328225
uses: docker/metadata-action@v5
329226
with:
330227
images: |
331-
${{ env.DOCKERHUB_REPO }}
332228
${{ env.GHCR_REPO }}
333229
334230
- name: Create manifest list and push
335231
working-directory: ${{ runner.temp }}/digests
336232
run: |
337-
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
338-
$(printf '${{ env.DOCKERHUB_REPO }}@sha256:%s ' *)
339233
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
340234
$(printf '${{ env.GHCR_REPO }}@sha256:%s ' *)
341235
342236
- name: Inspect image
343237
run: |
344-
docker buildx imagetools inspect ${{ env.DOCKERHUB_REPO }}:${{ steps.meta.outputs.version }}
345-
docker buildx imagetools inspect ${{ env.GHCR_REPO }}:${{ steps.meta.outputs.version }}
238+
docker buildx imagetools inspect ${{ env.GHCR_REPO }}:${{ steps.meta.outputs.version }}

0 commit comments

Comments
 (0)