-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (76 loc) · 2.41 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Release
run-name: Release (`${{ github.sha }}`)
on:
workflow_dispatch:
env:
PYTHON_VERSION: "3.11"
jobs:
create-tag:
name: Create a Git tag
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Get the version
id: get-version
run: |
echo "version=$(poetry version --short)" >> "$GITHUB_OUTPUT"
- name: Create a Git tag
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions"
git fetch --tags
git tag --annotate "v${{ steps.get-version.outputs.version }}" --message="v${{ steps.get-version.outputs.version }}"
git push origin "v${{ steps.get-version.outputs.version }}"
publish-to-pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: create-tag
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Publish to PyPI
run: |
git fetch --tags
git checkout v${{ needs.create-tag.outputs.version }}
poetry publish --build
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
create-release:
name: Create a GitHub release
runs-on: ubuntu-latest
needs: create-tag
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Create a GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create v${{ needs.create-tag.outputs.version }} --verify-tag --generate-notes --title "v${{ needs.create-tag.outputs.version }}" --repo ${{ github.repository }} --target ${{ github.sha }}