-
Notifications
You must be signed in to change notification settings - Fork 19
76 lines (63 loc) · 2.19 KB
/
release.yml
File metadata and controls
76 lines (63 loc) · 2.19 KB
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
70
71
72
73
74
75
76
name: Release
on:
push:
# The CI job is triggered after merged to branch, so the version between last commits are compared
branches: [main]
workflow_dispatch:
inputs:
force_release:
type: boolean
description: 'Force release regardless of version changes'
default: false
env:
PYTHONVERSION: "3.12"
jobs:
release:
runs-on: macos-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
uv sync
uv pip install twine build toml
- name: Compare versions
id: compare-versions
run: |
source .venv/bin/activate
FORCE_RELEASE="${{ github.event.inputs.force_release }}"
CUR_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
git switch --detach HEAD^
MAIN_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
git switch -
echo "Current version in pyproject.toml: $CUR_VERSION"
echo "Version on main branch: $MAIN_VERSION"
echo "FORCE_RELEASE: $FORCE_RELEASE"
if [ "$FORCE_RELEASE" == "true" ]; then
echo "Force release is enabled. Proceeding with the release."
echo "SKIP_RELEASE=false" >> $GITHUB_ENV
elif [ "$CUR_VERSION" == "$MAIN_VERSION" ]; then
echo "The version hasn't changed. Skipping release."
echo "SKIP_RELEASE=true" >> $GITHUB_ENV
else
echo "Versions differ. Proceed with the release."
echo "SKIP_RELEASE=false" >> $GITHUB_ENV
fi
- name: Release to PyPI
if: env.SKIP_RELEASE != 'true'
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_PUBLISHER_TOKEN }}
run: |
uv run python -m build --sdist
uv run twine upload -r pypi dist/*