11name : Release
22
33on :
4+ push :
5+ branches : [main]
46 release :
57 types :
68 - published
9+ workflow_dispatch :
710
811jobs :
912 publish-release :
@@ -16,23 +19,45 @@ jobs:
1619 - name : Fetch git tags
1720 run : git fetch --prune --unshallow --tags
1821
19- - name : Get release version
20- run : |
21- VERSION=`echo "${{ github.ref_name }}" | sed 's/v\(.*\)/\1/' `
22- echo "VERSION=${VERSION}"
23- echo "VERSION=${VERSION}" >> ${GITHUB_ENV}
22+ - name : Set up QEMU
23+ uses : docker/setup-qemu-action@v3
2424
25- - name : Docker Build
26- run : |
27- docker build -t yurishkuro/microsim:${VERSION} .
25+ - name : Set up Docker Buildx
26+ uses : docker/setup-buildx-action@v3
27+ with :
28+ install : true
2829
29- - name : Docker Login
30- run : |
31- echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u "yurishkuro" docker.io --password-stdin
30+ - name : Extract tags/labels from Git
31+ id : docker_meta
32+ uses : docker/metadata-action@v5
33+ with :
34+ images : jaegertracing/protobuf
35+ # The 'tags:' section defines how the Docker image will be tagged:
36+ # - pushes to main branch will be published as 'latest'
37+ # - pushes tagged with semver will be published as that version (without 'v')
38+ # - other tags can be used as is
39+ # Documentation: https://github.com/docker/metadata-action#tags-input
40+ tags : |
41+ type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
42+ type=semver,pattern={{version}}
43+ type=ref,event=tag
3244
33- - name : Docker Upload
34- run : |
35- docker push yurishkuro/microsim:${VERSION}
45+ - name : Login to DockerHub
46+ if : github.event_name != 'pull_request'
47+ uses : docker/login-action@v3
48+ with :
49+ username : yurishkuro
50+ password : ${{ secrets.DOCKERHUB_TOKEN }}
51+
52+ - name : Build and maybe push Docker image
53+ uses : docker/build-push-action@v5
54+ with :
55+ push : ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
56+ tags : ${{ steps.docker_meta.outputs.tags }}
57+ labels : ${{ steps.docker_meta.outputs.labels }}
58+ cache-from : type=gha
59+ cache-to : type=gha,mode=max
60+ platforms : linux/amd64,linux/arm64
3661
3762 - name : SBOM Generation
3863
0 commit comments