-
Notifications
You must be signed in to change notification settings - Fork 6
81 lines (68 loc) · 2.34 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
78
79
80
81
name: Publish
on:
push:
branches: [ main ]
jobs:
build_wheels:
if: "contains(github.event.head_commit.message, '[publish]')"
name: Build Wheels
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Preparations
run: python3 -m pip install -U twine build
- name: Build
run: python3 -m build
- name: Check
run: twine check dist/*
- name: Upload
uses: actions/upload-artifact@v3
with:
name: wheels_nc_py_api
path: dist/*.*
if-no-files-found: error
publish_pypi:
needs: [build_wheels]
if: "contains(github.event.head_commit.message, '[publish]')"
name: Upload to PyPi
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Get tag
run: |
RELEASE_VERSION=$(sed -n "s/^__version__.*\"\(.*\)\"$/\\1/p" ./nc_py_api/_version.py)
echo RELEASE_TAG="v$RELEASE_VERSION" >> $GITHUB_ENV
CHANGELOG=$(grep -oPz "(?s)##\s\[$RELEASE_VERSION.+?(?=##\s\[|$)" ./CHANGELOG.md | tr -d '\0' | sed /^$/d | sed '1d')
CHANGELOG=$(echo "$CHANGELOG" | sed '$!N;s/^###.*\n#/#/;P;D' | sed '$!N;s/^###.*\n#/#/;P;D' | sed '${/^###/d;}')
echo "CHANGELOG<<EOF" >> $GITHUB_ENV
echo "$CHANGELOG" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Download sdist and wheels
uses: actions/download-artifact@v3
with:
name: wheels_nc_py_api
path: wheelhouse_nc_py_api
- name: Create release draft
uses: ncipollo/[email protected]
with:
name: ${{ env.RELEASE_TAG }}
tag: ${{ env.RELEASE_TAG }}
commit: ${{ github.ref }}
draft: false
body: ${{ env.CHANGELOG }}
token: ${{ secrets.PAT_NC_PY_API }}
- name: Install twine
run: |
python3 -m pip install twine
python3 -m pip install urllib3==1.26.15
- name: Publish NcPyApi
run: |
python3 -m twine upload --skip-existing wheelhouse_nc_py_api/*.whl
python3 -m twine upload --skip-existing wheelhouse_nc_py_api/*tar.gz
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}