Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Commit 76c0e68

Browse files
author
Paulo Gomes
committed
Change container tags to support semver
Signed-off-by: Paulo Gomes <[email protected]>
1 parent f743269 commit 76c0e68

File tree

2 files changed

+83
-25
lines changed

2 files changed

+83
-25
lines changed

Diff for: .github/workflows/build.yaml

+81-19
Original file line numberDiff line numberDiff line change
@@ -92,26 +92,13 @@ jobs:
9292
tags: localhost:5000/${{ github.repository_owner }}/golang-with-libgit2-all:latest
9393
cache-from: type=local,src=/tmp/.buildx-cache
9494
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
95-
- name: Build candidate image - libgit2 only
96-
id: build_candidate_libgti2_only
97-
uses: docker/build-push-action@v3
98-
with:
99-
context: .
100-
file: Dockerfile.libgit2-only
101-
platforms: ${{ env.PLATFORMS }}
102-
push: true
103-
tags: localhost:5000/${{ github.repository_owner }}/golang-with-libgit2-only:latest
104-
cache-from: type=local,src=/tmp/.buildx-cache
105-
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
10695
- name: Inspect candidate images
10796
run: |
10897
docker buildx imagetools inspect localhost:5000/${{ github.repository_owner }}/golang-with-libgit2-all:latest
109-
docker buildx imagetools inspect localhost:5000/${{ github.repository_owner }}/golang-with-libgit2-only:latest
11098
- name: Test candidate images
11199
id: test_candidate
112100
run: |
113101
IMG=localhost:5000/${{ github.repository_owner }}/golang-with-libgit2-all make test
114-
IMG=localhost:5000/${{ github.repository_owner }}/golang-with-libgit2-only LIBGIT2_ONLY=true make test
115102
- # Temp fix
116103
# https://github.com/docker/build-push-action/issues/252
117104
# https://github.com/moby/buildkit/issues/1896
@@ -134,9 +121,7 @@ jobs:
134121
images: |
135122
ghcr.io/${{ github.repository_owner }}/golang-with-libgit2-all
136123
tags: |
137-
type=schedule
138-
type=ref,event=branch
139-
type=ref,event=tag
124+
type=semver,pattern=v{{version}}
140125
type=sha
141126
type=sha,format=long
142127
- name: Release candidate image - golang-with-libgit2-all
@@ -162,6 +147,85 @@ jobs:
162147
cosign sign $image
163148
done
164149
150+
build-libgit2-only:
151+
runs-on: ubuntu-latest
152+
env:
153+
PLATFORMS: linux/amd64,linux/arm/v7,linux/arm64
154+
services:
155+
registry:
156+
image: registry:2
157+
ports:
158+
- 5000:5000
159+
steps:
160+
- name: Checkout
161+
uses: actions/checkout@v3
162+
- name: Unshallow
163+
run: git fetch --prune --unshallow
164+
- name: Setup Cosign
165+
uses: sigstore/cosign-installer@main
166+
- name: Set up QEMU
167+
id: qemu
168+
uses: docker/setup-qemu-action@v2
169+
with:
170+
image: tonistiigi/binfmt:latest
171+
platforms: ${{ env.PLATFORMS }}
172+
- name: Set up Docker Buildx
173+
id: buildx
174+
uses: docker/setup-buildx-action@v2
175+
with:
176+
config-inline: |
177+
[worker.oci]
178+
max-parallelism = 4
179+
driver-opts: network=host
180+
- name: Inspect builder
181+
run: |
182+
echo "Name: ${{ steps.buildx.outputs.name }}"
183+
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
184+
echo "Status: ${{ steps.buildx.outputs.status }}"
185+
echo "Flags: ${{ steps.buildx.outputs.flags }}"
186+
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
187+
- name: Cache Docker layers
188+
uses: actions/cache@v3
189+
id: cache
190+
with:
191+
path: /tmp/.buildx-cache
192+
key: ${{ runner.os }}-buildx-ghcache-${{ github.sha }}
193+
restore-keys: |
194+
${{ runner.os }}-buildx-ghcache-
195+
- run: cat ./hack/static.sh
196+
- name: Build candidate image - libgit2 only
197+
id: build_candidate_libgti2_only
198+
uses: docker/build-push-action@v3
199+
with:
200+
context: .
201+
file: Dockerfile.libgit2-only
202+
platforms: ${{ env.PLATFORMS }}
203+
push: true
204+
tags: localhost:5000/${{ github.repository_owner }}/golang-with-libgit2-only:latest
205+
cache-from: type=local,src=/tmp/.buildx-cache
206+
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
207+
- name: Inspect candidate images
208+
run: |
209+
docker buildx imagetools inspect localhost:5000/${{ github.repository_owner }}/golang-with-libgit2-only:latest
210+
- name: Test candidate images
211+
id: test_candidate
212+
run: |
213+
IMG=localhost:5000/${{ github.repository_owner }}/golang-with-libgit2-only LIBGIT2_ONLY=true make test
214+
- # Temp fix
215+
# https://github.com/docker/build-push-action/issues/252
216+
# https://github.com/moby/buildkit/issues/1896
217+
name: Move cache
218+
run: |
219+
rm -rf /tmp/.buildx-cache
220+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
221+
- name: Login to GHCR
222+
if: github.event_name != 'pull_request'
223+
uses: docker/login-action@v2
224+
with:
225+
registry: ghcr.io
226+
username: ${{ github.repository_owner }}
227+
password: ${{ secrets.GITHUB_TOKEN }}
228+
165229
- name: Compose release candidate metadata - golang-with-libgit2-only
166230
id: meta_libgit2_only
167231
uses: docker/metadata-action@v3
@@ -170,9 +234,7 @@ jobs:
170234
images: |
171235
ghcr.io/${{ github.repository_owner }}/golang-with-libgit2-only
172236
tags: |
173-
type=schedule
174-
type=ref,event=branch
175-
type=ref,event=tag
237+
type=semver,pattern=v{{version}}
176238
type=sha
177239
type=sha,format=long
178240
- name: Release candidate image - golang-with-libgit2-only

Diff for: README.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,9 @@ FROM go-${BASE_VARIANT} AS build-dependencies-awesome-os
9494
### Releasing a new image
9595

9696
For the `main` branch, images are pushed automatically to a tag matching the branch name, and a tag in the format of
97-
`sha-<Git sha>`. In addition, images are created for new tags, with as preferred format: `libgit2-<libgit2 SemVer>`.
97+
`sha-<Git sha>`. In addition, images are created for new tags, with as preferred format: `v<SemVer>`.
9898

99-
For example, `libgit2-1.1.1` for an image with **libgit2 1.1.1** included.
100-
101-
In case changes happen to the `Dockerfile` while the `libgit2` version does not change, sequential tags should
102-
be suffixed with `-<seq num in range>`. For example, `libgit2-1.1.1-2` for the **third** container image
103-
with the same version.
99+
For example, `v0.1.0`.
104100

105101
### Debugging cross-compilation
106102

0 commit comments

Comments
 (0)