-
Notifications
You must be signed in to change notification settings - Fork 46
69 lines (56 loc) · 1.98 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Release
on:
push:
branches:
- master
env:
UV_VERSION: "0.4.28"
DEFAULT_PYTHON_VERSION: "3.12"
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Install uv version ${{ env.UV_VERSION }}
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
- name: Install python ${{ env.DEFAULT_PYTHON_VERSION }} using uv
run: uv python install ${{ env.DEFAULT_PYTHON_VERSION }}
- name: Get previous commit SHA
run: echo "sha=$(git rev-parse --verify --quiet HEAD^)" >> $GITHUB_ENV
- name: Detect and tag new version
id: check-version
if: ${{ env.sha }}
uses: salsify/action-detect-and-tag-new-version@v2
with:
version-command: echo $(grep "^version =" pyproject.toml | sed 's/version = "\(.*\)"/\1/')
- name: Bump version for dev release
if: "! steps.check-version.outputs.tag"
run: |
VERSION=$(grep "^version =" pyproject.toml | sed 's/version = "\(.*\)"/\1/')
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version $VERSION.dev.$(date +%s)
- name: Build package
run: uv build
- name: Publish package on PyPI
if: steps.check-version.outputs.tag
uses: pypa/gh-action-pypi-publish@release/v1
- name: Publish package on TestPyPI
if: "! steps.check-version.outputs.tag"
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
- name: Publish the release notes
uses: release-drafter/release-drafter@v6
with:
publish: ${{ steps.check-version.outputs.tag != '' }}
tag: ${{ steps.check-version.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}