-
-
Notifications
You must be signed in to change notification settings - Fork 2
144 lines (124 loc) · 4.6 KB
/
publish.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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Publish and Release
on:
push:
branches:
- main
paths:
- 'fastapi_agents/**'
- 'pyproject.toml'
- 'uv.lock'
- 'docs/**'
- 'README.md'
workflow_dispatch:
jobs:
version_bump_and_publish:
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (contains(join(github.event.head_commit.modified, ' '), 'fastapi_agents/') || contains(join(github.event.head_commit.modified, ' '), 'pyproject.toml'))) }}
permissions:
contents: write
runs-on: ubuntu-latest
environment:
name: pypi
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Set up Python version from file
uses: actions/setup-python@v4
with:
python-version-file: .python-version
- name: Install uv
run: |
python3 -m pip install --upgrade pip
python3 -m pip install uv
- name: Install dev dependencies
run: |
uv sync --dev
- name: Run tests with pytest
run: |
uv run pytest
- name: Bump version and tag
run: |
uv run bump-version
NEW_VERSION=$(uv run get-version)
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add pyproject.toml uv.lock
git commit -m "Bump version to $NEW_VERSION"
git tag v$NEW_VERSION
- name: Push changes and tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git push origin main --tags
- name: Build and publish
env:
UV_PUBLISH_TOKEN: ${{ secrets.UV_PUBLISH_TOKEN }}
run: |
uv build
uv publish
- name: Get previous version tag
id: get_previous_version_tag
run: |
PREVIOUS_TAG=$(git describe --tags $(git rev-list --tags --skip=1 --max-count=1))
echo "PREVIOUS_TAG=$PREVIOUS_TAG" >> $GITHUB_ENV
- name: Generate release notes
id: generate_release_notes
run: |
echo "Changes in this release:" > release_notes.md
git log $(git describe --tags --abbrev=0 $(git describe --tags --abbrev=0)^)..HEAD --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" >> release_notes.md
echo "" >> release_notes.md
echo "" >> release_notes.md
echo "[View details on PyPI](https://pypi.org/project/fastapi-agents/${{ env.NEW_VERSION }}/)" >> release_notes.md
echo "" >> release_notes.md
echo "To upgrade via pip:" >> release_notes.md
echo "\`\`\`" >> release_notes.md
echo "pip install --upgrade fastapi-agents" >> release_notes.md
echo "\`\`\`" >> release_notes.md
echo "" >> release_notes.md
- name: Output release notes for debugging
run: cat release_notes.md
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.NEW_VERSION }}
release_name: Release v${{ env.NEW_VERSION }}
body_path: release_notes.md
- name: Prevent publish trigger
run: echo "Skipped publish" > skip_publish.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
generate_and_publish_docs:
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (contains(join(github.event.head_commit.modified, ' '), 'README.md') || contains(join(github.event.head_commit.modified, ' '), 'docs/'))) || github.job == 'version_bump_and_publish' }}
permissions:
contents: write
pages: write
id-token: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Set up Python version from file
uses: actions/setup-python@v4
with:
python-version-file: .python-version
- name: Install uv
run: |
python3 -m pip install --upgrade pip
python3 -m pip install uv
- name: Install dev dependencies
run: |
uv sync --dev
- name: Build docs
run: |
uv run mkdocs build
- name: Deploy to GitHub Pages
run: |
uv run mkdocs gh-deploy --force