@@ -3,11 +3,11 @@ name: publish
33on :
44 push :
55 branches : ['main']
6- release :
7- types : ['published']
6+ tags : ['v*.*.*']
7+
8+ concurrency : ${{ github.ref }}
89
910env :
10- REGISTRY : ghcr.io
1111 IMAGE_NAME : cloudstruct/cardano-submit-api
1212
1313jobs :
@@ -21,16 +21,30 @@ jobs:
2121 - name : qemu
2222 uses : docker/setup-qemu-action@v1
2323 - uses : docker/setup-buildx-action@v1
24- - name : login
24+ - name : Login to Docker Hub
25+ uses : docker/login-action@v1
26+ with :
27+ username : cloudstruct
28+ password : ${{ secrets.DOCKER_PASSWORD }} # uses token
29+ - name : Login to GHCR
2530 uses : docker/login-action@v1
2631 with :
27- registry : ${{ env.REGISTRY }}
32+ registry : ghcr.io
2833 username : ${{ github.actor }}
2934 password : ${{ secrets.GITHUB_TOKEN }}
3035 - id : meta
3136 uses : docker/metadata-action@v3
3237 with :
33- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
38+ images : |
39+ ${{ env.IMAGE_NAME }}
40+ ghcr.io/${{ env.IMAGE_NAME }}
41+ tags : |
42+ # Only version, no revision
43+ type=match,pattern=v(.*)-(.*),group=1
44+ # branch
45+ type=ref,event=branch
46+ # semver
47+ type=semver,pattern={{version}}
3448 - name : push
3549 uses : docker/build-push-action@v2
3650 with :
3953 platforms : linux/amd64,linux/arm64
4054 tags : ${{ steps.meta.outputs.tags }}
4155 labels : ${{ steps.meta.outputs.labels }}
56+ # Update Docker Hub from README
57+ - name : Docker Hub Description
58+ uses : peter-evans/dockerhub-description@v3
59+ with :
60+ username : cloudstruct
61+ password : ${{ secrets.DOCKER_PASSWORD }}
62+ repository : ${{ env.IMAGE_NAME }}
63+ readme-filepath : ./README.md
64+ short-description : " A Go implementation of the Cardano Submit API service"
65+
66+ github-release :
67+ runs-on : ubuntu-latest
68+ needs : [build-and-push-image]
69+ steps :
70+ - run : " echo \" RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"
71+ - uses : actions/github-script@v5
72+ if : startsWith(github.ref, 'refs/tags/')
73+ with :
74+ github-token : ${{ secrets.GITHUB_TOKEN }}
75+ script : |
76+ try {
77+ await github.rest.repos.createRelease({
78+ draft: false,
79+ generate_release_notes: true,
80+ name: process.env.RELEASE_TAG,
81+ owner: context.repo.owner,
82+ prerelease: false,
83+ repo: context.repo.repo,
84+ tag_name: process.env.RELEASE_TAG,
85+ });
86+ } catch (error) {
87+ core.setFailed(error.message);
88+ }
0 commit comments