-
Notifications
You must be signed in to change notification settings - Fork 15
80 lines (77 loc) · 2.86 KB
/
Copy pathrelease.yaml
File metadata and controls
80 lines (77 loc) · 2.86 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
name: Publish on PyPI
on:
release:
types: [published]
workflow_dispatch:
inputs:
candidate:
description: 'Release candidate.'
required: true
type: boolean
default: true
test_pypi:
description: 'Test PyPi.'
type: boolean
default: false
jobs:
pypi:
name: PyPI Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install pip --upgrade
python -m pip install build --upgrade
python -m pip install setuptools --upgrade
python -m pip install packaging --upgrade
- name: Set pyproject version
run: |
echo "PACKAGE=$(python -c 'import setuptools; setuptools.setup()' --version)" >> $GITHUB_ENV
- name: Check package version (compare package version with tag)
id: check_package_version
shell: python
run: |
import os
from packaging.version import parse
package_version = os.getenv('PACKAGE')
if parse(package_version) != parse('${{ github.event.release.tag_name }}'):
print(f'version mismatch: {package_version} (in package) vs ${{ github.event.release.tag_name }} (GitHub tag)')
exit(1)
else:
print('version match')
exit(0)
- name: Create whl and tar.gz files in sdist
run: |
rm -rf docs/ Examples/ tests/
make package
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: ${{ inputs.test_pypi && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }}
- name: Bump version to next candidate
if: ${{ inputs.candidate && !inputs.test_pypi }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
make bumpversion-candidate
- name: Create pull request
id: cpr
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GH_ACCESS_TOKEN }}
commit-message: bumpversion-candidate
title: Automated Bump Version Candidate
body: "This is an auto-generated PR that bumps the version to the next candidate."
branch: bumpversion-candidate-update
branch-suffix: short-commit-hash
base: main
- name: Enable Pull Request Automerge
if: ${{ steps.cpr.outputs.pull-request-operation == 'created' }}
run: gh pr merge "${{ steps.cpr.outputs.pull-request-number }}" --squash --auto
env:
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}