1+ # Thanks to https://github.com/museofficial/muse/blob/master/.github/workflows/publish.yml for this amazing workflow.
2+
3+ name : Make release & publish Docker image
4+
5+ on :
6+ push :
7+ tags :
8+ - ' v*'
9+
10+ env :
11+ REGISTRY_IMAGE : ghcr.io/seijinmark/esk
12+
13+ jobs :
14+ publish :
15+ strategy :
16+ matrix :
17+ runner-platform :
18+ - ubuntu-latest
19+ - namespace-profile-default-arm64
20+ include :
21+ - runner-platform : ubuntu-latest
22+ build-arch : linux/amd64
23+ tagged-platform : amd64
24+ - runner-platform : namespace-profile-default-arm64
25+ build-arch : linux/arm64
26+ tagged-platform : arm64
27+ runs-on : ${{ matrix.runner-platform }}
28+ permissions :
29+ contents : read
30+ packages : write
31+ attestations : write
32+ id-token : write
33+ steps :
34+ - name : Set up Buildx
35+ uses : docker/setup-buildx-action@v3
36+
37+ - name : Login to DockerHub
38+ uses : docker/login-action@v1
39+ with :
40+ username : ${{ secrets.DOCKERHUB_USERNAME }}
41+ password : ${{ secrets.DOCKERHUB_TOKEN }}
42+
43+ - name : Login to GitHub Container Registry
44+ uses : docker/login-action@v3
45+ with :
46+ registry : ghcr.io
47+ username : ${{ github.repository_owner }}
48+ password : ${{ secrets.GITHUB_TOKEN }}
49+
50+ - name : Get current time
51+ uses : josStorer/get-current-time@v2
52+ id : current-time
53+
54+ - name : Build and push
55+ id : docker_build
56+ uses : docker/build-push-action@v6
57+ with :
58+ push : true
59+ tags : |
60+ seijinmark/esk:${{ github.sha }}-${{ matrix.tagged-platform }}
61+ ${{ env.REGISTRY_IMAGE }}:${{ github.sha }}-${{ matrix.tagged-platform }}
62+ platforms : ${{ matrix.build-arch }}
63+ build-args : |
64+ COMMIT_HASH=${{ github.sha }}
65+ BUILD_DATE=${{ steps.current-time.outputs.time }}
66+
67+ combine :
68+ name : Combine platform tags
69+ runs-on : ubuntu-latest
70+ needs : publish
71+ permissions :
72+ contents : read
73+ packages : write
74+ attestations : write
75+ id-token : write
76+ steps :
77+ - uses : actions/checkout@v1
78+
79+ - name : Set up Buildx
80+ uses : docker/setup-buildx-action@v1
81+
82+ - name : Login to DockerHub
83+ uses : docker/login-action@v1
84+ with :
85+ username : ${{ secrets.DOCKERHUB_USERNAME }}
86+ password : ${{ secrets.DOCKERHUB_TOKEN }}
87+
88+ - name : Login to GitHub Container Registry
89+ uses : docker/login-action@v3
90+ with :
91+ registry : ghcr.io
92+ username : ${{ github.repository_owner }}
93+ password : ${{ secrets.GITHUB_TOKEN }}
94+
95+ - name : Get tags (Docker Hub)
96+ id : get-tags-dockerhub
97+ uses : Surgo/docker-smart-tag-action@v1
98+ with :
99+ docker_image : seijinmark/esk
100+
101+ - name : Get tags (ghcr.io)
102+ id : get-tags-ghcr
103+ uses : Surgo/docker-smart-tag-action@v1
104+ with :
105+ docker_image : ${{ env.REGISTRY_IMAGE }}
106+
107+ - name : Combine tags (Docker Hub)
108+ run : docker buildx imagetools create $(echo '${{ steps.get-tags-dockerhub.outputs.tag }}' | tr "," "\0" | xargs -0 printf -- '-t %s ') 'seijinmark/esk:${{ github.sha }}-arm64' 'seijinmark/esk:${{ github.sha }}-amd64'
109+
110+ - name : Combine tags (GitHub Container Registry)
111+ run : docker buildx imagetools create $(echo '${{ steps.get-tags-ghcr.outputs.tag }}' | tr "," "\0" | xargs -0 printf -- '-t %s ') '${{ env.REGISTRY_IMAGE }}:${{ github.sha }}-arm64' '${{ env.REGISTRY_IMAGE }}:${{ github.sha }}-amd64'
112+
113+ - name : Update Docker Hub description
114+ uses : peter-evans/dockerhub-description@v2.4.3
115+ with :
116+ username : ${{ secrets.DOCKERHUB_USERNAME }}
117+ password : ${{ secrets.DOCKERHUB_PASSWORD }}
118+ repository : seijinmark/esk
119+
120+ release :
121+ name : Create GitHub release
122+ runs-on : ubuntu-latest
123+ needs : combine
124+ steps :
125+ - uses : actions/checkout@v2
126+
127+ - name : Get version from tag
128+ id : tag_name
129+ run : |
130+ echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v}
131+ shell : bash
132+
133+ - name : Get Changelog Entry
134+ id : changelog_reader
135+ uses : mindsers/changelog-reader-action@v2
136+ with :
137+ version : ${{ steps.tag_name.outputs.current_version }}
138+ path : ./CHANGELOG.md
139+
140+ - name : Create/update release
141+ uses : ncipollo/release-action@v1
142+ with :
143+ tag : v${{ steps.changelog_reader.outputs.version }}
144+ name : Release v${{ steps.changelog_reader.outputs.version }}
145+ body : ${{ steps.changelog_reader.outputs.changes }}
146+ prerelease : ${{ steps.changelog_reader.outputs.status == 'prereleased' }}
147+ draft : ${{ steps.changelog_reader.outputs.status == 'unreleased' }}
148+ allowUpdates : true
149+ token : ${{ secrets.GH_PAT }}
0 commit comments