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

Commit e12f29b

Browse files
committed
Automate release
Signed-off-by: Hidde Beydals <hello@hidde.co>
1 parent 4826f8e commit e12f29b

File tree

1 file changed

+61
-6
lines changed

1 file changed

+61
-6
lines changed

.github/workflows/build.yaml

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ on:
55
branches:
66
- main
77
- dev
8+
tags:
9+
- '**'
10+
paths-ignore:
11+
- README.md
812
pull_request:
13+
paths-ignore:
14+
- README.md
915
jobs:
1016
build:
1117
runs-on: ubuntu-latest
@@ -41,19 +47,68 @@ jobs:
4147
echo "Status: ${{ steps.buildx.outputs.status }}"
4248
echo "Flags: ${{ steps.buildx.outputs.flags }}"
4349
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
44-
- name: Build candidate
50+
- name: Cache Docker layers
51+
uses: actions/cache@v2
52+
id: cache
53+
with:
54+
path: /tmp/.buildx-cache
55+
key: ${{ runner.os }}-buildx-ghcache-${{ github.sha }}
56+
restore-keys: |
57+
${{ runner.os }}-buildx-ghcache-
58+
- name: Build candidate image
4559
id: build_candidate
4660
uses: docker/build-push-action@v2
4761
with:
4862
context: .
4963
file: Dockerfile
5064
platforms: ${{ env.PLATFORMS }}
5165
push: true
52-
tags: localhost:5000/golang-with-libgit2:latest
53-
- name: Inspect candidate
66+
tags: localhost:5000/${{ github.repository_owner }}/golang-with-libgit2:latest
67+
cache-from: type=local,src=/tmp/.buildx-cache
68+
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
69+
- name: Inspect candidate image
5470
run: |
55-
docker buildx imagetools inspect localhost:5000/golang-with-libgit2:latest
56-
- name: Test candidate
71+
docker buildx imagetools inspect localhost:5000/${{ github.repository_owner }}/golang-with-libgit2:latest
72+
- name: Test candidate image
5773
id: test_candidate
5874
run: |
59-
IMG=localhost:5000/golang-with-libgit2 make test
75+
IMG=localhost:5000/${{ github.repository_owner }}/golang-with-libgit2 make test
76+
- # Temp fix
77+
# https://github.com/docker/build-push-action/issues/252
78+
# https://github.com/moby/buildkit/issues/1896
79+
name: Move cache
80+
run: |
81+
rm -rf /tmp/.buildx-cache
82+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
83+
- name: Login to GHCR
84+
if: github.event_name != 'pull_request'
85+
uses: docker/login-action@v1
86+
with:
87+
registry: ghcr.io
88+
username: ${{ github.repository_owner }}
89+
password: ${{ secrets.GITHUB_TOKEN }}
90+
- name: Compose release candidate metadata
91+
id: meta
92+
uses: docker/metadata-action@v3
93+
if: github.event_name != 'pull_request'
94+
with:
95+
images: |
96+
ghcr.io/${{ github.repository_owner }}/golang-with-libgit2
97+
tags: |
98+
type=schedule
99+
type=ref,event=branch
100+
type=ref,event=tag
101+
type=sha
102+
type=sha,format=long
103+
- name: Release candidate image
104+
id: release_candidate
105+
if: github.event_name != 'pull_request'
106+
uses: docker/build-push-action@v2
107+
with:
108+
context: .
109+
file: Dockerfile
110+
platforms: ${{ env.PLATFORMS }}
111+
push: true
112+
tags: ${{ steps.meta.outputs.tags }}
113+
labels: ${{ steps.meta.outputs.labels }}
114+
cache-from: type=local,src=/tmp/.buildx-cache

0 commit comments

Comments
 (0)