-
Notifications
You must be signed in to change notification settings - Fork 61
108 lines (92 loc) · 2.79 KB
/
release.yaml
File metadata and controls
108 lines (92 loc) · 2.79 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
name: Release Package
on:
workflow_dispatch:
permissions:
users:
- ItayTheDar
inputs:
increment_version:
description: 'Increment version by major, minor, or patch'
required: true
default: 'patch'
type: choice
options:
- major
- minor
- patch
env:
VERSION_FILE_PATH: pyproject.toml
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@v3
with:
token: ${{ secrets.RELEASE_GIT_TOKEN }}
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Poetry
run: |
pip install poetry
- name: Set version using Poetry
run: |
# Extract the current version
CURRENT_VERSION=$(poetry version -s)
echo "Current version: $CURRENT_VERSION"
# Increment version
case ${{ inputs.increment_version }} in
major)
NEW_VERSION=$(poetry version major | awk '{print $NF}')
;;
minor)
NEW_VERSION=$(poetry version minor | awk '{print $NF}')
;;
patch)
NEW_VERSION=$(poetry version patch | awk '{print $NF}')
;;
*)
echo "Invalid input for increment_version"
exit 1
;;
esac
echo "New version: $NEW_VERSION"
echo "RELEASE_VERSION=$NEW_VERSION" >> $GITHUB_ENV
- name: Install build dependencies
run: |
poetry install --with build
- name: Update CHANGELOG.md
run: poetry run git-changelog . -o $CHANGELOG_FILE_PATH
- name: Build package with Poetry
run: |
poetry build
- 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
git commit -m "Increment version to $NEW_VERSION"
git push
- name: Publish package to PyPI
run: |
poetry publish --username ${{ secrets.PYPI_API_USER }} --password ${{ secrets.PYPI_API_TOKEN }}
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
name: v${{ env.RELEASE_VERSION }}
tag_name: v${{ env.RELEASE_VERSION }}
deploy-docs:
needs: release-package
permissions:
contents: read
pages: write
id-token: write
uses: ./.github/workflows/deploy_docs.yaml