-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (70 loc) · 2.39 KB
/
versioning.yml
File metadata and controls
85 lines (70 loc) · 2.39 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
name: Versioning
on:
push:
branches:
- main
paths:
- changelog.d/**
- .github/**
workflow_dispatch:
permissions:
contents: write
jobs:
version-bump:
name: Build changelog and bump version
runs-on: ubuntu-latest
if: github.event.head_commit.message != 'Update package version'
steps:
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Checkout repo
uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install dependencies
run: uv pip install --system towncrier
- name: Bump version and build changelog
run: |
python .github/bump_version.py
VERSION=$(python -c "import re; print(re.search(r'version = \"(.+?)\"', open('pyproject.toml').read()).group(1))")
towncrier build --yes --version "$VERSION"
- name: Commit version bump
uses: EndBug/add-and-commit@v9
with:
add: "."
message: Update package version
release:
name: Create release
runs-on: ubuntu-latest
if: github.event.head_commit.message == 'Update package version'
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Get version
id: get-version
run: |
VERSION=$(python -c "import re; print(re.search(r'version = \"(.+?)\"', open('pyproject.toml').read()).group(1))")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Version: $VERSION"
- name: Create git tag
run: |
git tag "v${{ steps.get-version.outputs.version }}"
git push origin "v${{ steps.get-version.outputs.version }}"
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "v${{ steps.get-version.outputs.version }}" \
--title "v${{ steps.get-version.outputs.version }}" \
--notes "See [CHANGELOG.md](https://github.com/PolicyEngine/policyengine-api-v2-alpha/blob/main/CHANGELOG.md) for details." \
--latest