Skip to content

Commit 57bcd63

Browse files
committed
chore(ci): setup automatic semantic-release with Docker build
1 parent e4a5da6 commit 57bcd63

2 files changed

Lines changed: 48 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,48 @@ name: Release
22

33
on:
44
push:
5-
tags:
6-
- 'v*'
5+
branches:
6+
- main
77

88
permissions:
9-
contents: read
9+
contents: write
1010
packages: write
1111

1212
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
concurrency:
16+
group: release
17+
cancel-in-progress: false
18+
19+
outputs:
20+
released: ${{ steps.release.outputs.released }}
21+
version: ${{ steps.release.outputs.version }}
22+
tag: ${{ steps.release.outputs.tag }}
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
ref: ${{ github.ref_name }}
30+
31+
- name: Python Semantic Release
32+
id: release
33+
uses: python-semantic-release/python-semantic-release@v9.15.2
34+
with:
35+
github_token: ${{ secrets.GITHUB_TOKEN }}
36+
1337
docker:
38+
needs: release
39+
if: needs.release.outputs.released == 'true'
1440
runs-on: ubuntu-latest
1541

1642
steps:
1743
- name: Checkout
1844
uses: actions/checkout@v4
1945
with:
20-
ref: ${{ github.ref }}
46+
ref: ${{ needs.release.outputs.tag }}
2147

2248
- name: Set up Docker Buildx
2349
uses: docker/setup-buildx-action@v3
@@ -35,8 +61,8 @@ jobs:
3561
with:
3662
images: ghcr.io/${{ github.repository }}
3763
tags: |
38-
type=semver,pattern={{version}}
39-
type=semver,pattern={{major}}.{{minor}}
64+
type=semver,pattern={{version}},value=${{ needs.release.outputs.version }}
65+
type=semver,pattern={{major}}.{{minor}},value=${{ needs.release.outputs.version }}
4066
type=raw,value=latest
4167
4268
- name: Build and push

pyproject.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,19 @@ exclude_lines = [
120120
"if TYPE_CHECKING:",
121121
]
122122

123+
# Semantic Release configuration
124+
[tool.semantic_release]
125+
version_toml = ["pyproject.toml:project.version"]
126+
tag_format = "v{version}"
127+
commit_parser = "conventional"
128+
allow_zero_version = true
129+
major_on_zero = false
130+
131+
[tool.semantic_release.branches.main]
132+
match = "main"
133+
prerelease = false
134+
135+
[tool.semantic_release.commit_author]
136+
env = "GIT_COMMIT_AUTHOR"
137+
default = "github-actions <actions@github.com>"
138+

0 commit comments

Comments
 (0)