-
Notifications
You must be signed in to change notification settings - Fork 60
120 lines (99 loc) · 3.41 KB
/
Copy pathrelease.yaml
File metadata and controls
120 lines (99 loc) · 3.41 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Release Package
on:
workflow_dispatch:
inputs:
increment_version:
description: "Increment version by major, minor, or patch"
required: true
default: "patch"
type: choice
options:
- major
- minor
- patch
env:
CHANGELOG_FILE_PATH: CHANGELOG.md
jobs:
run-tests:
uses: ./.github/workflows/tests.yaml
release-package:
runs-on: ubuntu-latest
needs: run-tests
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.RELEASE_GIT_TOKEN }}
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.9.7"
enable-cache: true
- name: Set version
run: |
CURRENT_VERSION=$(uv version --short)
echo "Current version: $CURRENT_VERSION"
uv version --bump "${{ inputs.increment_version }}" --frozen
NEW_VERSION=$(uv version --short)
echo "New version: $NEW_VERSION"
echo "RELEASE_VERSION=$NEW_VERSION" >> "$GITHUB_ENV"
NEW_VERSION="$NEW_VERSION" python - <<'PY'
import os
import re
from pathlib import Path
version = os.environ["NEW_VERSION"]
path = Path("nest/__init__.py")
text = path.read_text()
updated = re.sub(
r'^__version__ = "[^"]+"$',
f'__version__ = "{version}"',
text,
flags=re.MULTILINE,
)
if updated == text:
raise SystemExit("Could not update nest/__init__.py version")
path.write_text(updated)
PY
- name: Install build dependencies
run: uv sync --no-dev --group build
- name: Update CHANGELOG.md
run: uv run git-changelog . -o "$CHANGELOG_FILE_PATH" --bump "v$RELEASE_VERSION"
- name: Build package
run: uv build --sdist --wheel
- name: Check package metadata
run: uv run twine check dist/*
- name: Smoke test wheel
run: uv run --isolated --no-project --with dist/*.whl python -c "import nest; from nest.cli.cli import nest_cli; print(nest.__version__)"
- name: Smoke test source distribution
run: uv run --isolated --no-project --with dist/*.tar.gz python -c "import nest; from nest.cli.cli import nest_cli; print(nest.__version__)"
- name: Commit and push changes
run: |
git config --global user.name "github-actions"
git config --global user.email "github@actions.com"
git add "$CHANGELOG_FILE_PATH" pyproject.toml nest/__init__.py
git commit -m "Increment version to $RELEASE_VERSION"
git push
- name: Publish package to PyPI
env:
UV_PUBLISH_USERNAME: ${{ secrets.PYPI_API_USER }}
UV_PUBLISH_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: uv publish
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
name: v${{ env.RELEASE_VERSION }}
tag_name: v${{ env.RELEASE_VERSION }}
generate_release_notes: true
deploy-docs:
needs: release-package
permissions:
contents: read
pages: write
id-token: write
uses: ./.github/workflows/deploy_docs.yaml