-
-
Notifications
You must be signed in to change notification settings - Fork 3
54 lines (51 loc) · 1.65 KB
/
python-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
name: Upload Python Package
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: 'Version'
required: true
default: '0.0.0'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Version from input
if: github.event_name != 'push'
run: |
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: Version from pushed tag
if: github.event_name == 'push'
run: |
# from refs/tags/v1.2.3 get 1.2.3
echo "version=$(echo $GITHUB_REF | sed 's#.*/v##')" >> $GITHUB_ENV
- name: Autobump version
run: |
PLACEHOLDER="__version__ = 'develop'"
REPLACEMENT="__version__ = '${{ env.version }}'"
VERSION_FILE="weconnect_cli/__version.py"
# ensure the placeholder is there. If grep doesn't find the placeholder
# it exits with exit code 1 and github actions aborts the build.
grep "$PLACEHOLDER" "$VERSION_FILE"
sed -i "s/$PLACEHOLDER/$REPLACEMENT/g" "$VERSION_FILE"
grep "$REPLACEMENT" "$VERSION_FILE"
shell: bash
- 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 bdist_wheel
twine upload dist/*