Skip to content

Commit 4641b75

Browse files
committed
fix: release
1 parent 8c5e38a commit 4641b75

File tree

3 files changed

+63
-58
lines changed

3 files changed

+63
-58
lines changed

.github/workflows/docker-publish.yml

Lines changed: 0 additions & 56 deletions
This file was deleted.

.github/workflows/pr-release.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
with:
1919
fetch-depth: 0
2020
ref: ${{ github.event.pull_request.head.ref }}
21-
token: ${{ secrets.GITHUB_TOKEN }}
21+
token: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
2222

2323
- name: Set up Python
2424
uses: actions/setup-python@v4
@@ -67,6 +67,26 @@ jobs:
6767
run: |
6868
git push origin "v${{ steps.version.outputs.RC_VERSION }}"
6969
70+
- name: Set up Docker Buildx
71+
uses: docker/setup-buildx-action@v3
72+
73+
- name: Log in to Container Registry
74+
uses: docker/login-action@v3
75+
with:
76+
registry: ghcr.io
77+
username: ${{ github.actor }}
78+
password: ${{ secrets.GITHUB_TOKEN }}
79+
80+
- name: Build and push Docker image
81+
uses: docker/build-push-action@v5
82+
with:
83+
context: .
84+
platforms: linux/amd64,linux/arm64
85+
push: true
86+
tags: ghcr.io/${{ github.repository }}:v${{ steps.version.outputs.RC_VERSION }}
87+
cache-from: type=gha
88+
cache-to: type=gha,mode=max
89+
7090
- name: Create GitHub pre-release
7191
env:
7292
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,49 @@ jobs:
3838
git config --global user.email "github-actions[bot]@users.noreply.github.com"
3939
4040
- name: Run semantic release
41+
id: release
4142
env:
4243
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4344
run: |
4445
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

Comments
 (0)