|
1 | 1 | name: Release |
| 2 | + |
2 | 3 | on: |
3 | 4 | - workflow_dispatch |
4 | 5 |
|
5 | | -env: |
6 | | - COSIGN_EXPERIMENTAL: 1 |
7 | | - REGISTRY: ghcr.io |
8 | | - IMAGE_NAME: ${{ github.repository }} |
9 | | - VERSION: 1.10.0 |
10 | | - |
11 | 6 | jobs: |
12 | | - build: |
13 | | - name: Build |
14 | | - runs-on: ubuntu-22.04 |
| 7 | + release: |
| 8 | + name: Release |
15 | 9 | permissions: |
16 | 10 | contents: write |
17 | | - packages: write |
18 | | - outputs: |
19 | | - image-release: ${{ steps.image-info.outputs.release }} |
20 | | - steps: |
21 | | - - name: Checkout source code |
22 | | - |
23 | | - |
24 | | - - name: Set up Carvel |
25 | | - uses: vmware-tanzu/[email protected] |
26 | | - with: |
27 | | - token: ${{ secrets.GITHUB_TOKEN }} |
28 | | - |
29 | | - - name: Log into container registry |
30 | | - uses: redhat-actions/[email protected] |
31 | | - with: |
32 | | - username: ${{ github.actor }} |
33 | | - password: ${{ secrets.GITHUB_TOKEN }} |
34 | | - registry: ${{ env.REGISTRY }} |
35 | | - |
36 | | - - name: Create k3d cluster |
37 | | - run: | |
38 | | - # Initialize brew because of https://github.com/actions/runner-images/issues/6283 |
39 | | - eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" |
40 | | - brew install k3d |
41 | | - k3d cluster create test-cluster |
42 | | -
|
43 | | - # Wait for the generation of a token for the Service Account |
44 | | - while [ $(kubectl get configmap kube-root-ca.crt --no-headers | wc -l) -eq 0 ] ; do |
45 | | - sleep 3 |
46 | | - done |
47 | | -
|
48 | | - - name: Package and publish OCI bundle |
49 | | - run: | |
50 | | - kctrl package release -y --version ${{ env.VERSION }} \ |
51 | | - --chdir package \ |
52 | | - --copy-to ../carvel-artifacts \ |
53 | | - --repo-output ../repo |
54 | | - |
55 | | - - name: Get released OCI image name with digest |
56 | | - id: image-info |
57 | | - run: | |
58 | | - package_file=$(find carvel-artifacts/packages -name 'package.yml') |
59 | | - image_release=$(yq '.spec.template.spec.fetch[0].imgpkgBundle.image' ${package_file}) |
60 | | - echo "IMAGE_RELEASE=${image_release}" >> $GITHUB_ENV |
61 | | - echo "release=${image_release}" >> $GITHUB_OUTPUT |
62 | | - |
63 | | - - name: Add additional tags to OCI image |
64 | | - run: | |
65 | | - podman pull ${IMAGE_RELEASE} |
66 | | - podman tag ${IMAGE_RELEASE} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} |
67 | | - podman tag ${IMAGE_RELEASE} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest |
68 | | - podman push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} |
69 | | - podman push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest |
70 | | - |
71 | | - - name: Create a release |
72 | | - env: |
73 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
74 | | - run: | |
75 | | - gh release create v${{ env.VERSION }} \ |
76 | | - --generate-notes \ |
77 | | - ./carvel-artifacts/packages/cert-manager.packages.kadras.io/package.yml \ |
78 | | - ./carvel-artifacts/packages/cert-manager.packages.kadras.io/metadata.yml \ |
79 | | - ./README.md |
80 | | - |
81 | | - - name: Upload package.yml artifact |
82 | | - |
83 | | - with: |
84 | | - name: ${{ env.VERSION }}.yml |
85 | | - path: ./repo/packages/cert-manager.packages.kadras.io/${{ env.VERSION }}.yml |
86 | | - retention-days: 1 |
87 | | - |
88 | | - - name: Upload metadata.yml artifact |
89 | | - |
90 | | - with: |
91 | | - name: metadata.yml |
92 | | - path: ./repo/packages/cert-manager.packages.kadras.io/metadata.yml |
93 | | - retention-days: 1 |
94 | | - |
95 | | - sign: |
96 | | - name: Sign |
97 | | - runs-on: ubuntu-22.04 |
98 | | - needs: [build] |
99 | | - permissions: |
100 | | - packages: write |
101 | 11 | id-token: write |
102 | | - env: |
103 | | - IMAGE_RELEASE: ${{ needs.build.outputs.image-release }} |
104 | | - steps: |
105 | | - - name: Install Cosign |
106 | | - |
107 | | - with: |
108 | | - cosign-release: 'v1.13.0' |
109 | | - |
110 | | - - name: Log into container registry |
111 | | - uses: redhat-actions/[email protected] |
112 | | - with: |
113 | | - username: ${{ github.actor }} |
114 | | - password: ${{ secrets.GITHUB_TOKEN }} |
115 | | - registry: ${{ env.REGISTRY }} |
116 | | - |
117 | | - - name: Sign image |
118 | | - run: | |
119 | | - cosign sign "${IMAGE_RELEASE}" |
120 | | - |
121 | | - provenance: |
122 | | - name: Provenance |
123 | | - runs-on: ubuntu-22.04 |
124 | | - needs: [build,sign] |
125 | | - permissions: |
126 | 12 | packages: write |
127 | | - id-token: write |
128 | | - env: |
129 | | - IMAGE_RELEASE: ${{ needs.build.outputs.image-release }} |
130 | | - PROVENANCE_FILE: provenance.att |
131 | | - steps: |
132 | | - - name: Install Cosign |
133 | | - |
134 | | - with: |
135 | | - cosign-release: 'v1.13.0' |
136 | | - |
137 | | - - name: Log into container registry |
138 | | - uses: redhat-actions/[email protected] |
139 | | - with: |
140 | | - username: ${{ github.actor }} |
141 | | - password: ${{ secrets.GITHUB_TOKEN }} |
142 | | - registry: ${{ env.REGISTRY }} |
143 | | - |
144 | | - - name: Extract digest |
145 | | - run: | |
146 | | - digest=$(echo ${IMAGE_RELEASE} | cut -d "@" -f2) |
147 | | - echo "IMAGE_DIGEST=${digest}" >> $GITHUB_ENV |
148 | | -
|
149 | | - - name: Generate provenance |
150 | | - uses: philips-labs/[email protected] |
151 | | - with: |
152 | | - command: generate |
153 | | - subcommand: container |
154 | | - arguments: --repository ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} --tags ${{ env.VERSION }} --digest ${{ env.IMAGE_DIGEST }} --output-path ${{ env.PROVENANCE_FILE }} |
155 | | - env: |
156 | | - COSIGN_EXPERIMENTAL: 0 |
157 | | - |
158 | | - - name: Attach provenance |
159 | | - run: | |
160 | | - jq '.predicate' "${PROVENANCE_FILE}" > provenance-predicate.att |
161 | | - cosign attest --predicate provenance-predicate.att --type slsaprovenance "${IMAGE_RELEASE}" |
162 | | -
|
163 | | - |
164 | | - with: |
165 | | - name: provenance.att |
166 | | - path: ${{ env.PROVENANCE_FILE }} |
167 | | - |
168 | | - repo: |
169 | | - name: Package Repository |
170 | | - runs-on: ubuntu-22.04 |
171 | | - needs: [provenance] |
172 | | - permissions: |
173 | | - contents: read |
174 | | - env: |
175 | | - PACKAGE_REPO: kadras-packages |
176 | | - steps: |
177 | | - - name: Download package.yml artifact |
178 | | - |
179 | | - with: |
180 | | - name: ${{ env.VERSION }}.yml |
181 | | - path: ./artifacts |
182 | | - |
183 | | - - name: Download metadata.yml artifact |
184 | | - |
185 | | - with: |
186 | | - name: metadata.yml |
187 | | - path: ./artifacts |
188 | | - |
189 | | - - name: Checkout package repository source code |
190 | | - |
191 | | - with: |
192 | | - path: kadras-packages |
193 | | - repository: ${{ github.repository_owner }}/${{ env.PACKAGE_REPO }} |
194 | | - ref: main |
195 | | - token: ${{ secrets.GH_ORG_PAT }} |
196 | | - |
197 | | - - name: Push release artifacts to package repository |
198 | | - env: |
199 | | - GH_TOKEN: ${{ secrets.GH_ORG_PAT }} |
200 | | - run: | |
201 | | - package_path=kadras-packages/repo/packages/cert-manager.packages.kadras.io |
202 | | - if [ ! -f ${package_path} ]; then |
203 | | - mkdir -p ${package_path} |
204 | | - fi |
205 | | -
|
206 | | - mv -f artifacts/${{ env.VERSION }}.yml ${package_path}/${{ env.VERSION }}.yml |
207 | | - mv -f artifacts/metadata.yml ${package_path}/metadata.yml |
208 | | -
|
209 | | - cd kadras-packages |
210 | | -
|
211 | | - git config user.name github-actions |
212 | | - git config user.email [email protected] |
213 | | -
|
214 | | - branch_name=$(date +%s | base64) |
215 | | - git checkout -b ${branch_name} |
216 | | -
|
217 | | - git add repo/packages/cert-manager.packages.kadras.io/${{ env.VERSION }}.yml |
218 | | - git add repo/packages/cert-manager.packages.kadras.io/metadata.yml |
219 | | -
|
220 | | - git commit -m "Update Cert Manager metadata and add version ${VERSION}" |
221 | | - git push origin ${branch_name} |
222 | | -
|
223 | | - gh pr create -f --base main --title "Add Cert Manager ${VERSION}" --body "Update Cert Manager metadata and add version ${VERSION}" |
| 13 | + uses: arktonix/cloud-native-utils/.github/workflows/package-release.yml@main |
| 14 | + with: |
| 15 | + package-name-slug: cert-manager |
| 16 | + package-name-display: Cert Manager |
| 17 | + registry-server: ghcr.io |
| 18 | + registry-username: ${{ github.actor }} |
| 19 | + image: ${{ github.repository }} |
| 20 | + version: 1.10.0 |
| 21 | + secrets: |
| 22 | + pull-request-token: ${{ secrets.GH_ORG_PAT }} |
0 commit comments