-
Notifications
You must be signed in to change notification settings - Fork 31
144 lines (126 loc) · 4.61 KB
/
python-release.yaml
File metadata and controls
144 lines (126 loc) · 4.61 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
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
name: "[impit-python] Release to PyPI"
permissions:
contents: write
id-token: write
on:
workflow_dispatch:
inputs:
bump:
description: 'Bump version'
required: true
type: choice
default: 'patch'
options:
- 'major'
- 'minor'
- 'patch'
jobs:
get_version:
runs-on: ubuntu-latest
outputs:
bumped-version-commit-sha: ${{ steps.commit_version.outputs.commit_long_sha || github.sha }}
new_version: ${{ steps.increment_version.outputs.new_version }}
steps:
- uses: actions/checkout@v6
with:
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
- name: Use Python
uses: actions/setup-python@v6
with:
python-version: 3.x
- name: Set up uv package manager
uses: astral-sh/setup-uv@v7
- name: Use Node.js
uses: actions/setup-node@v6
- name: Get current version
id: get_version
working-directory: impit-python
run: |
echo "current_version=$(uvx --from=toml-cli toml get --toml-path=pyproject.toml project.version)" >> "$GITHUB_OUTPUT"
- name: Increment version
id: increment_version
working-directory: impit-python
run: |
echo "new_version=$(npx semver -i ${{ github.event.inputs.bump }} ${{ steps.get_version.outputs.current_version }})" >> "$GITHUB_OUTPUT"
- name: Set new version
id: show_new_version
working-directory: impit-python
run: |
echo "New version is ${{ steps.increment_version.outputs.new_version }}"
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version ${{ steps.increment_version.outputs.new_version }}
- name: Commit new version
id: commit_version
uses: EndBug/add-and-commit@v9
with:
author_name: github-actions[bot]
author_email: github-actions[bot]@users.noreply.github.com
message: "chore(py-release): bump `pyproject.toml` version [skip ci]"
add: 'impit-python/pyproject.toml'
tag: "py-${{ steps.increment_version.outputs.new_version }}"
test:
needs: [get_version]
name: Build and test
uses: ./.github/workflows/python-test.yaml
secrets: inherit
with:
commit_sha: ${{ needs.get_version.outputs.bumped-version-commit-sha }}
publish:
defaults:
run:
working-directory: impit-python
name: Publish
runs-on: ubuntu-latest
needs: [test]
steps:
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: impit-python/artifacts
- name: Move all wheels to /wheels
run: |
mkdir -p wheels
mv artifacts/**/*.{whl,tar.gz} wheels/
- name: List files
run: |
ls -lR
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: impit-python/wheels
changelog:
name: Generate changelog
needs: [publish, get_version]
runs-on: ubuntu-latest
outputs:
release_body: ${{ steps.git-cliff.outputs.content }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
ref: master
fetch-depth: 0
- name: Generate a changelog
uses: orhun/git-cliff-action@v4
id: git-cliff
with:
config: cliff.toml
args: --ignore-tags="(js|cli)-*" --include-path="./impit-python/**" --include-path="./impit/**"
env:
OUTPUT: impit-python/CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}
- name: Commit new changelog
id: commit_changelog
uses: EndBug/add-and-commit@v9
with:
author_name: github-actions[bot]
author_email: github-actions[bot]@users.noreply.github.com
message: "docs: update changelog [skip ci]"
add: 'impit-python/CHANGELOG.md'
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: "py-${{ needs.get_version.outputs.new_version }}"
name: "impit-python@${{ needs.get_version.outputs.new_version }}"
target_commitish: ${{ needs.get_version.outputs.bumped-version-commit-sha }}
body: ${{ steps.git-cliff.outputs.content }}