-
Notifications
You must be signed in to change notification settings - Fork 39
152 lines (137 loc) · 4.82 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
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
name: release
# Triggers when new issue is opened
on:
issues:
types: [opened]
jobs:
# Action to bump version and push tag
Bump-version:
if: startsWith(github.event.issue.title, 'release') && (startsWith(github.event.issue.body, 'patch') ||
startsWith(github.event.issue.body, 'minor') || startsWith(github.event.issue.body, 'major'))
runs-on: [ubuntu-latest]
strategy:
matrix:
python-version: [3.6]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@master
with:
persist-credentials: false
# Check for permissions
- uses: scherermichael/action-has-permission@master
id: check
with:
required-permission: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python ${{ matrix.python-version }}
if: steps.check.outputs.has-permission
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
# Bump version
- uses: geertvdc/setup-hub@master
- name: Bump version and tag
if: steps.check.outputs.has-permission
run: |
git config --global user.email ${{ github.actor }}@users.noreply.github.com
git config --global user.name ${{ github.actor }}
git pull
python -m pip install --upgrade bumpversion
bumpversion ${{ github.event.issue.body }}
# Push tags
- name: Push changes
if: steps.check.outputs.has-permission
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.access_token }}
tags: true
branch: master
# Action to build and publish distribution to PyPI and TestPyPI
build-and-publish:
needs: Bump-version
name: Build and publish Python distribution to PyPI and TestPyPI
runs-on: ubuntu-18.04
env:
version: 0.0.0
container:
image: 'rootproject/root:latest'
steps:
- uses: actions/checkout@master
- uses: scherermichael/action-has-permission@master
id: check2
with:
required-permission: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: geertvdc/setup-hub@master
# Build package
- name: Create package
id: version
if: steps.check2.outputs.has-permission
run: |
git config --global user.email ${{ github.actor }}@users.noreply.github.com
git config --global user.name ${{ github.actor }}
git pull
yum install -y python-pip ghostscript
python -m pip install pytest_pylint configparser astroid pyyml papermill future
echo "::set-output name=version::$(python -c "from hepdata_lib import __version__; print(__version__)")"
python -m pip install wheel
python setup.py sdist bdist_wheel
# Publish package to test PyPI
- name: Publish distribution to Test PyPI
if: steps.check2.outputs.has-permission
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/
# Sleep
- name: Sleep for 300 seconds
uses: jakejarvis/wait-action@master
with:
time: '300s'
# Run tests
- name: Test with pytest
run: |
pip install --index-url https://test.pypi.org/simple/ hepdata_lib==${{ steps.version.outputs.version }}
python setup.py test
python -m pylint hepdata_lib/*.py
python -m pylint tests/*.py --rcfile=tests/pylintrc
# Add automatic comment on the issue
- name: Create comment
if: steps.check2.outputs.has-permission
uses: jungwinter/comment@v1
id: create
with:
type: create
body: |
Test PyPI release version: ${{ steps.version.outputs.version }}
- https://test.pypi.org/project/hepdata-lib/${{ steps.version.outputs.version }}/
issue_number: ${{ github.event.issue.number }}
token: ${{ secrets.GITHUB_TOKEN }}
# Publish to PyPI
- name: Publish distribution to PyPI
if: steps.check2.outputs.has-permission
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}
# Add automatic comment on the issue
- name: Create comment
if: steps.check2.outputs.has-permission
uses: jungwinter/comment@v1
id: create2
with:
type: create
body: |
PyPI release version: ${{ steps.version.outputs.version }}
- https://pypi.org/project/hepdata-lib/
issue_number: ${{ github.event.issue.number }}
token: ${{ secrets.GITHUB_TOKEN }}
# Close issue
- name: Close Issue
uses: peter-evans/close-issue@v1
with:
issue-number: ${{ github.event.issue.number }}