-
Notifications
You must be signed in to change notification settings - Fork 16
179 lines (155 loc) · 5.1 KB
/
main.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: Bump version, create release and deploy
on:
push:
branches:
- main
jobs:
isort:
uses: ./.github/workflows/isort.yml
black:
uses: ./.github/workflows/black.yml
build:
uses: ./.github/workflows/build.yml
docs:
uses: ./.github/workflows/docs.yml
api:
uses: ./.github/workflows/api.yml
bump:
needs: [isort, black, build, docs, api]
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.semver.outputs.next }}
old_tag: ${{ steps.semver.outputs.current }}
steps:
- name: Create Github token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.DBBS_APP_ID }}
private-key: ${{ secrets.DBBS_APP_PRIVATE_KEY }}
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
- name: Get Next Version
id: semver
uses: ietf-tools/semver-action@v1
with:
token: ${{ steps.app-token.outputs.token }}
branch: main
noVersionBumpBehavior: warn
tag_release:
needs: [ bump ]
# Skip job in case no version bump is required
# in this case the variable tag will not be set by semver
if: ${{ needs.bump.outputs.tag != ''}}
runs-on: ubuntu-latest
steps:
- name: Create Github token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.DBBS_APP_ID }}
private-key: ${{ secrets.DBBS_APP_PRIVATE_KEY }}
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Bump version in Python project
run: |
pip install --upgrade pip bump-my-version
oldv="${{ needs.bump.outputs.old_tag }}"
newv="${{needs.bump.outputs.tag}}"
# Bump the version, dropping the leading `v` with `${x:1}`
bump-my-version replace --current-version=${oldv:1} --new-version=${newv:1} pyproject.toml
- name: Commit & Push version change
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: main
commit_message: 'docs: bump version: ${{ needs.bump.outputs.old_tag }} → ${{ needs.bump.outputs.tag }} [skip ci]'
- name: Create tag
uses: rickstaa/action-create-tag@v1
with:
tag: ${{ needs.bump.outputs.tag }}
github_token: ${{ steps.app-token.outputs.token }}
release:
runs-on: ubuntu-latest
needs: [bump, tag_release]
steps:
- name: Create Github token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.DBBS_APP_ID }}
private-key: ${{ secrets.DBBS_APP_PRIVATE_KEY }}
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
- name: Pull commit of version change
run: |
git pull origin main
- name: Update CHANGELOG
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ steps.app-token.outputs.token }}
fromTag: ${{ needs.bump.outputs.tag }}
toTag: ${{ needs.bump.outputs.old_tag }}
- name: Create Release
uses: ncipollo/[email protected]
with:
allowUpdates: true
draft: false
makeLatest: true
tag: ${{ needs.bump.outputs.tag }}
name: ${{ needs.bump.outputs.tag }}
body: ${{ steps.changelog.outputs.changes }}
token: ${{ steps.app-token.outputs.token }}
- name: Commit CHANGELOG.md
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: main
commit_message: 'docs: update CHANGELOG.md for ${{ github.ref_name }} [skip ci]'
file_pattern: CHANGELOG.md
pypi-publish:
runs-on: ubuntu-latest
needs: release
environment:
name: pypi
url: https://pypi.org/p/bsb-core
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Create Github token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.DBBS_APP_ID }}
private-key: ${{ secrets.DBBS_APP_PRIVATE_KEY }}
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
- name: Pull commits of version bump
run: |
git pull origin main
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install dependencies and build dist
run: |
python -m pip install --upgrade pip
pip install build
python -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1