-
Notifications
You must be signed in to change notification settings - Fork 10
77 lines (66 loc) · 2.18 KB
/
publish.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
name: Publish PyPi
on:
push:
tags:
- '*'
jobs:
release:
name: Create Release
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v1
- name: Build changelog message
id: changelog
run: |
tags_no=$(git tag -l | wc -l | sed 's/ //g')
new_tag=$(git describe --tags --abbrev=0)
if [[ "${tags_no}" > 1 ]]; then
old_tag=$(git describe --tags --abbrev=0 --tags ${new_tag}^)
echo "get log from ${old_tag}..${new_tag}"
content=$(git log ${old_tag}..${new_tag} --oneline --decorate --pretty=format:"%s" | tail -n 1)
content="${content//'%'/%25}"
content="${content//$'\n'/%0A}"
content="${content//$'\r'/%0D}"
else
content="Initial release"
old_tag=$new_tag
echo "same tag ${old_tag}..${new_tag}"
fi
echo $content
echo "::set-output name=message::${content}"
echo "::set-output name=new_tag::${new_tag}"
echo "::set-output name=old_tag::${old_tag}"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: |
## Changelog
${{ steps.changelog.outputs.message }}
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ steps.changelog.outputs.old_tag }}...${{ steps.changelog.outputs.new_tag }}
draft: false
prerelease: false
deploy:
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist
twine upload dist/* --verbose