-
Notifications
You must be signed in to change notification settings - Fork 82
119 lines (103 loc) · 3.19 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
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
name: Release
# We only ever want 1 release at a time
concurrency: release
on:
pull_request:
types: closed
branches:
- develop
- master
jobs:
tag:
name: Create Tag
runs-on: ubuntu-latest
if: github.event.pull_request.merged
outputs:
tag: ${{ steps.bump.outputs.next_tag }}
steps:
- name: Checkout Code
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Setup Python 3.12
uses: actions/[email protected]
with:
python-version: '3.12'
architecture: x64
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r .scripts/requirements.txt
pip install poetry==1.4.0
- name: Get Latest Tag
id: latest_tag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
- name: Calculate base tag
id: calculate
run: python .scripts/bump.py ${{ steps.latest_tag.outputs.tag }} ${{ github.event.pull_request.number }} ${{ github.base_ref }}
- name: Bump version
id: bump
run: |
if [ "$BUMP_RULE" = "None" ]; then
echo "::set-output name=next_tag::$(echo $BASE_TAG)"
else
poetry version $BASE_TAG
poetry version $BUMP_RULE
NEXT_TAG=$(poetry version -s)
echo "::set-output name=next_tag::$(echo $NEXT_TAG)"
fi
env:
BASE_TAG: ${{ steps.calculate.outputs.base_tag }}
BUMP_RULE: ${{ steps.calculate.outputs.bump_rule }}
- name: Create Tag
id: create_tag
uses: K-Phoen/semver-release-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_branch: ${{ github.base_ref }}
release_strategy: tag
tag: ${{ steps.bump.outputs.next_tag }}
publish:
name: Publish Package
runs-on: ubuntu-latest
needs: tag
steps:
- name: Checkout Code
uses: actions/[email protected]
- name: Setup Python 3.12
uses: actions/[email protected]
with:
python-version: '3.12'
architecture: x64
- name: Setup Poetry
run: pip install poetry==1.4.0
- name: Publish to PyPI
run: |
poetry version ${{needs.tag.outputs.tag}}
poetry build
poetry publish --username '__token__' --password '${{ secrets.PYPI_TOKEN }}'
release:
name: Create Release
runs-on: ubuntu-latest
needs: [tag, publish]
steps:
- name: Create Draft Release
uses: release-drafter/[email protected]
if: github.base_ref == 'develop'
with:
tag: ${{needs.tag.outputs.tag}}
version: ${{needs.tag.outputs.tag}}
commitish: develop
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
uses: release-drafter/[email protected]
if: github.base_ref == 'master'
with:
tag: ${{needs.tag.outputs.tag}}
version: ${{needs.tag.outputs.tag}}
publish: true
commitish: master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}