38
38
git config --global user.email "github-actions[bot]@users.noreply.github.com"
39
39
40
40
- name : Run semantic release
41
+ id : release
41
42
env :
42
43
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
43
44
run : |
44
45
semantic-release version
45
- semantic-release publish
46
+ semantic-release publish
47
+
48
+ # Get the new version for Docker tagging
49
+ NEW_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
50
+ echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_OUTPUT
51
+
52
+ - name : Set up Docker Buildx
53
+ if : steps.release.outputs.NEW_VERSION != ''
54
+ uses : docker/setup-buildx-action@v3
55
+
56
+ - name : Log in to Container Registry
57
+ if : steps.release.outputs.NEW_VERSION != ''
58
+ uses : docker/login-action@v3
59
+ with :
60
+ registry : ghcr.io
61
+ username : ${{ github.actor }}
62
+ password : ${{ secrets.GITHUB_TOKEN }}
63
+
64
+ - name : Extract Docker metadata
65
+ if : steps.release.outputs.NEW_VERSION != ''
66
+ id : meta
67
+ uses : docker/metadata-action@v5
68
+ with :
69
+ images : ghcr.io/${{ github.repository }}
70
+ tags : |
71
+ type=semver,pattern={{version}},value=v${{ steps.release.outputs.NEW_VERSION }}
72
+ type=semver,pattern={{major}}.{{minor}},value=v${{ steps.release.outputs.NEW_VERSION }}
73
+ type=semver,pattern={{major}},value=v${{ steps.release.outputs.NEW_VERSION }}
74
+ type=raw,value=latest,enable={{is_default_branch}}
75
+
76
+ - name : Build and push Docker image
77
+ if : steps.release.outputs.NEW_VERSION != ''
78
+ uses : docker/build-push-action@v5
79
+ with :
80
+ context : .
81
+ platforms : linux/amd64,linux/arm64
82
+ push : true
83
+ tags : ${{ steps.meta.outputs.tags }}
84
+ labels : ${{ steps.meta.outputs.labels }}
85
+ cache-from : type=gha
86
+ cache-to : type=gha,mode=max
0 commit comments