1+ name : Release
2+
3+ on :
4+ push :
5+ tags : ['v*.*.*']
6+
7+ env :
8+ IMAGE_NAME : podmortem-log-parser
9+ DOCKERFILE : ./src/main/docker/Dockerfile.native
10+ DEP_STAGE : dependencies
11+
12+ jobs :
13+ warm-cache :
14+ runs-on : self-hosted
15+ permissions : {contents: read, packages: write}
16+ steps :
17+ - uses : actions/checkout@v4
18+ - uses : docker/setup-buildx-action@v3
19+
20+ - name : Login to GHCR
21+ uses : docker/login-action@v3
22+ with :
23+ registry : ghcr.io
24+ username : ${{ github.actor }}
25+ password : ${{ secrets.GH_PAT }}
26+
27+ - name : Build deps layer
28+ uses : docker/build-push-action@v6
29+ with :
30+ context : .
31+ file : ${{ env.DOCKERFILE }}
32+ target : ${{ env.DEP_STAGE }}
33+ push : true
34+ platforms : linux/amd64
35+ cache-from : type=gha,scope=deps
36+ cache-to : |
37+ type=gha,mode=max,scope=deps
38+ type=registry,ref=ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:deps-cache,mode=max
39+ tags : ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:deps-cache
40+ build-args : GITHUB_USER=${{ github.actor }}
41+ secrets : GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
42+
43+ build-arch :
44+ needs : warm-cache
45+ runs-on : self-hosted
46+ permissions : {contents: read, packages: write}
47+ strategy :
48+ matrix :
49+ arch : [amd64, arm64]
50+ include :
51+ - arch : amd64
52+ platform : linux/amd64
53+ - arch : arm64
54+ platform : linux/arm64
55+ steps :
56+ - uses : actions/checkout@v4
57+ - uses : docker/setup-buildx-action@v3
58+ - uses : docker/login-action@v3
59+ with :
60+ registry : ghcr.io
61+ username : ${{ github.actor }}
62+ password : ${{ secrets.GH_PAT }}
63+
64+ - name : Build & push ${{ matrix.arch }}
65+ uses : docker/build-push-action@v6
66+ with :
67+ context : .
68+ file : ${{ env.DOCKERFILE }}
69+ platforms : ${{ matrix.platform }}
70+ push : true
71+ cache-from : |
72+ type=gha,scope=deps
73+ type=gha,scope=build-${{ matrix.arch }}
74+ cache-to : type=gha,mode=max,scope=build-${{ matrix.arch }}
75+ tags : |
76+ ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-${{ matrix.arch }}
77+ build-args : GITHUB_USER=${{ github.actor }}
78+ secrets : GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
79+
80+ manifest :
81+ needs : build-arch
82+ runs-on : self-hosted
83+ permissions : {contents: read, packages: write}
84+ steps :
85+ - uses : docker/login-action@v3
86+ with :
87+ registry : ghcr.io
88+ username : ${{ github.actor }}
89+ password : ${{ secrets.GH_PAT }}
90+
91+ - name : Create manifest list
92+ run : |
93+ for TAG in ${{ github.ref_name }} latest; do
94+ docker buildx imagetools create \
95+ -t ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${TAG} \
96+ ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-amd64 \
97+ ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-arm64
98+ done
99+
100+ release-notes :
101+ needs : manifest
102+ runs-on : self-hosted
103+ permissions : {contents: write}
104+ steps :
105+ - name : Generate GitHub Release
106+ uses : softprops/action-gh-release@v1
107+ with :
108+ tag_name : ${{ github.ref_name }}
109+ generate_release_notes : true
0 commit comments