-
Notifications
You must be signed in to change notification settings - Fork 10
151 lines (120 loc) · 4.22 KB
/
autorelease.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
name: publish package
on:
push:
branches:
- master
schedule:
- cron: "12 3 * * *"
env:
BASEBRANCH: master
WORKBRANCH: autorelease
USERNAME: ko-zu (github-actions)
USEREMAIL: causeless@gmail.com
concurrency: publish-package-with-updated-psl
jobs:
verify-and-publish-main-branch:
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.BASEBRANCH }}
- name: Set git config
run: |
git config user.name "$USERNAME"
git config user.email "$USEREMAIL"
- uses: actions/setup-python@v4
with:
python-version: "3.x"
cache: "pip"
cache-dependency-path: "requirements-dev.txt"
- name: Verify the psl
run: |
pip install --progress-bar off -r requirements-dev.txt
pip install .
if ! python -m publicsuffixlist.test ; then
echo "Test failed. Abort."
exit 1
fi
- name: Tag and release new version
run: |
BASEVERSION=$(sed -nr 's/^__version__ = "([0-9\.]+)"$/\1/p' setup.py)
[[ -z "$BASEVERSION" ]] && exit 1
echo "BASEVERSION=${BASEVERSION}" >> $GITHUB_ENV
TAG=v${BASEVERSION}
git fetch origin $BASEBRANCH
git tag ${TAG} origin/$BASEBRANCH
git push origin ${TAG}
# Create refreshed workbranch.
git checkout origin/$BASEBRANCH -b $WORKBRANCH
VERSION=$(sed -nr 's/^__version__ = "([0-9\.]+)"$/\1/p' setup.py)
NEWDATE=$(date -u "+%Y%m%d")
NEWVERSION=${VERSION}.${NEWDATE}
NEWTAG=v${NEWVERSION}-gha
sed -ri 's/^__version__ = "[0-9\.]+\.[0-9]+"$/__version__ = "'${NEWVERSION}'"/' setup.py
pip install .
python setup.py sdist --formats=gztar
python setup.py bdist_wheel --universal
if ! python -m publicsuffixlist.test ; then
echo "Test failed. Abort."
exit 1
fi
git add setup.py publicsuffixlist/public_suffix_list.dat
git commit -m "Automated release: ${NEWTAG}"
git push -f origin $WORKBRANCH
git tag ${NEWTAG}
git push origin ${NEWTAG}
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
scheduled-autorelease:
if: ${{ github.event_name == 'schedule' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.WORKBRANCH }}
- name: Set git config
run: |
git config user.name "$USERNAME"
git config user.email "$USEREMAIL"
- uses: actions/setup-python@v4
with:
python-version: "3.x"
cache: "pip"
cache-dependency-path: "requirements-dev.txt"
- name: Update automation branch
id: gennewversion
run: |
pip install --progress-bar off -r requirements-dev.txt
pip install .
python -m publicsuffixlist.update
if git diff --exit-code publicsuffixlist/public_suffix_list.dat ; then
echo "No change in the PSL file. Skipping."
echo "release=false" >> $GITHUB_OUTPUT
exit 0
fi
VERSION=$(sed -nr 's/^__version__ = "([0-9\.]+)\.[0-9]+"$/\1/p' setup.py)
NEWDATE=$(date -u "+%Y%m%d")
NEWVERSION=${VERSION}.${NEWDATE}
NEWTAG=v${NEWVERSION}-gha
sed -ri 's/^__version__ = "[0-9\.]+\.[0-9]+"$/__version__ = "'${NEWVERSION}'"/' setup.py
pip install .
python setup.py sdist --formats=gztar
python setup.py bdist_wheel --universal
if ! python -m publicsuffixlist.test ; then
echo "Test failed. Abort."
exit 1
fi
git add setup.py publicsuffixlist/public_suffix_list.dat
git commit -m "Automated release: ${NEWTAG}"
git push -f origin $WORKBRANCH
git tag ${NEWTAG}
git push origin ${NEWTAG}
echo "release=true" >> $GITHUB_OUTPUT
- name: Publish package to PyPI
if: ${{ steps.gennewversion.outputs.release == 'true' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}