Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit 8d756f0

Browse files
committed
ensure assets are released
1 parent 4df79fe commit 8d756f0

File tree

3 files changed

+56
-9
lines changed

3 files changed

+56
-9
lines changed

.github/workflows/ci.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
types: [opened, synchronize, reopened]
55
push:
66
branches:
7-
- master
7+
- master
88

99
jobs:
1010
report:
@@ -15,7 +15,7 @@ jobs:
1515
run: echo ${{ github.ref }}
1616
- name: event_name
1717
run: echo ${{ github.event_name }}
18-
build:
18+
build-test-deploy-release:
1919
name: Build
2020
runs-on: ubuntu-latest
2121
steps:
@@ -45,12 +45,12 @@ jobs:
4545
run: make image-all KUBEBUILDER_DIR=${KUBEBUILDER_DIR}
4646
env:
4747
KUBEBUILDER_ASSETS: ${{ env.KUBEBUILDER_DIR }}/bin
48-
- name: hub login
49-
if: (github.event_name == 'push' && endsWith(github.ref,'/master')) || (github.event_name == 'create' && startsWith(github.ref,'refs/tags/'))
48+
49+
# these next steps are used for merge to master (push the images)
50+
# they really should be separate workflows or jobs, but github actions is awful about sharing between them, so it must be one job
51+
- name: docker login
52+
if: github.event_name == 'push' && endsWith(github.ref,'/master')
5053
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
5154
- name: deploy # when merged into master, tag master and push - ideally, this would be a separate job, but you cannot share docker build cache between jobs
5255
if: github.event_name == 'push' && endsWith(github.ref,'/master')
5356
run: make cd CONFIRM=true BRANCH_NAME=master
54-
- name: release # when based on a tag, tag master and push - ideally, this would be a separate job, but you cannot share docker build cache between jobs
55-
if: github.event_name == 'create' && startsWith(github.ref,'refs/tags/')
56-
run: make release CONFIRM=true

.github/workflows/release.yaml

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# workflow to release assets as part of the release
2+
13
on:
24
push:
35
tags:
@@ -6,8 +8,29 @@ on:
68
name: Upload Release Asset
79

810
jobs:
9-
build:
11+
readiness:
12+
name: check for appropriate image
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Set version and imagename
16+
id: get_version
17+
run: |
18+
echo ::set-env name=VERSION::${GITHUB_REF/refs\/tags\//}
19+
echo ::set-env name=IMAGENAME::packethost/cluster-api-provider-packet
20+
echo ::set-env name=COMMIT::${GITHUB_SHA}
21+
- name: information
22+
run: echo "checking for existence of image ${IMAGENAME}:${COMMIT}. If it does not exist, this will fail; wait for an earlier PR merge action to complete and re-run this job."
23+
- name: docker login
24+
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
25+
- name: check for docker image on hub
26+
run: docker buildx imagetools inspect ${IMAGENAME}:${COMMIT}
27+
- name: report
28+
run: ready for release; the docker image ${IMAGENAME}:${COMMIT} is available
29+
30+
release:
1031
name: Upload Release Asset
32+
needs:
33+
- readiness
1134
runs-on: ubuntu-latest
1235
steps:
1336
- name: Checkout code
@@ -74,3 +97,27 @@ jobs:
7497
asset_path: out/release/infrastructure-packet/${{ env.VERSION }}/metadata.yaml
7598
asset_name: metadata.yaml
7699
asset_content_type: application/yaml
100+
101+
images:
102+
runs-on: ubuntu-latest
103+
needs:
104+
- readiness
105+
steps:
106+
- name: docker login
107+
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
108+
- name: Set version and imagename
109+
id: get_version
110+
run: |
111+
echo ::set-env name=VERSION::${GITHUB_REF/refs\/tags\//}
112+
echo ::set-env name=IMAGENAME::packethost/cluster-api-provider-packet
113+
echo ::set-env name=COMMIT::${GITHUB_SHA}
114+
- name: get-image
115+
run: docker image pull ${IMAGENAME}:${COMMIT}
116+
- name: release-latest
117+
run: |
118+
docker tag ${IMAGENAME}:${COMMIT} ${IMAGENAME}:latest
119+
docker push ${IMAGENAME}:latest
120+
- name: release-semver
121+
run: |
122+
docker tag ${IMAGENAME}:${COMMIT} ${IMAGENAME}:${VERSION}
123+
docker push ${IMAGENAME}:${VERSION}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: vendor test manager clusterctl run install deploy crds generate fmt vet run kubebuilder ci cd
22

3-
GIT_VERSION ?= $(shell git log -1 --format="%h")
3+
GIT_VERSION ?= $(shell git log -1 --format="%H")
44
RELEASE_TAG := $(shell git describe --abbrev=0 --tags ${TAG_COMMIT} 2>/dev/null || true)
55
RELEASE_VERSION ?= $(shell cat VERSION)
66

0 commit comments

Comments
 (0)