-
-
Notifications
You must be signed in to change notification settings - Fork 6
137 lines (118 loc) · 4.07 KB
/
publish_alpha.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
# This workflow will generate an ALPHA release distribution and upload it to PyPI
name: Publish Alpha Build
on:
pull_request:
types: [closed]
branches:
- dev
paths-ignore:
- 'version.py'
- 'test/**'
- 'examples/**'
- '.github/**'
- '.gitignore'
- 'LICENSE'
- 'CHANGELOG.md'
- 'MANIFEST.in'
- 'README.md'
- 'scripts/**'
jobs:
build_and_publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: dev
fetch-depth: 0 # Avoid errors when pushing refs to the destination repository
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install Build Tools
run: |
python -m pip install build wheel
- name: Debug GitHub Labels
run: |
echo "Labels in Pull Request:"
echo "${{ toJson(github.event.pull_request.labels) }}"
# Convert the labels array into text using jq
LABELS=$(echo '${{ toJson(github.event.pull_request.labels) }}' | jq -r '.[].name')
# Handle the case where there are no labels
if [ -z "$LABELS" ]; then
echo "No labels found on the pull request."
else
echo "Labels: $LABELS"
fi
- name: Determine version bump
id: version_bump
run: |
# Convert the labels array into text using jq
LABELS=$(echo '${{ toJson(github.event.pull_request.labels) }}' | jq -r '.[].name')
# Handle the case where there are no labels
if [ -z "$LABELS" ]; then
echo "No labels found on the pull request."
LABELS=""
fi
echo "Labels: $LABELS"
MAJOR=0
MINOR=0
BUILD=0
# Loop over the labels and determine the version bump
for label in $LABELS; do
echo "Processing label: $label"
if [ "$label" == "breaking" ]; then
MAJOR=1
elif [ "$label" == "feature" ]; then
MINOR=1
elif [ "$label" == "fix" ]; then
BUILD=1
fi
done
# Set the output based on the labels found
if [ $MAJOR -eq 1 ]; then
echo "::set-output name=part::major"
elif [ $MINOR -eq 1 ]; then
echo "::set-output name=part::minor"
elif [ $BUILD -eq 1 ]; then
echo "::set-output name=part::build"
else
echo "::set-output name=part::alpha"
fi
- name: Update version in version.py
run: |
python scripts/update_version.py ${{ steps.version_bump.outputs.part }} --version-file $GITHUB_WORKSPACE/version.py
- name: "Generate release changelog"
uses: heinrichreimer/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
maxIssues: 50
id: changelog
- name: Commit to dev
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Increment Version
branch: dev
- name: version
run: echo "::set-output name=version::$(python setup.py --version)"
id: version
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: V${{ steps.version.outputs.version }}
release_name: Release ${{ steps.version.outputs.version }}
body: |
Changes in this Release
${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: true
commitish: dev
- name: Build Distribution Packages
run: |
python setup.py sdist bdist_wheel
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{secrets.PYPI_TOKEN}}