-
-
Notifications
You must be signed in to change notification settings - Fork 14
116 lines (111 loc) · 3.89 KB
/
deploy.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
---
name: "Deploy"
# yamllint disable-line rule:truthy
on:
release:
types:
- published
workflow_dispatch:
env:
MODULE_NAME: aiolyric
jobs:
deploy:
name: 🚀 Linux - Deploy Module
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/[email protected]
with:
ref: "master"
token: ${{ secrets.PUSH_TOKEN }}
- name: 🏗 Set up Python
uses: actions/[email protected]
with:
python-version: "3.12"
architecture: "x64"
cache: "pip"
- name: 🏗 Install setuptools, wheel, twine, click, twisted, incremental
run: |
python -m pip install --upgrade setuptools wheel twine click twisted incremental
- name: 🔢 Get old version
id: get-version-old
run: |
python -m pip install .
# Read version from _version.py
result=$(python <<EOF
from ${{ env.MODULE_NAME }}._version import __version__
print(__version__.public())
EOF
)
echo "version=$result" >> $GITHUB_OUTPUT
- name: 🔢 Set correct vertion - Developement
if: ${{ github.event_name != 'release' }}
run: |
# If version does not contain dev, add it
if [[ ! "${{ steps.get-version-old.outputs.version }}" == *"dev"* ]]; then
python -m incremental.update ${{ env.MODULE_NAME }} --dev
fi
- name: 🔢 Set correct vertion - Release
if: ${{ github.event_name == 'release' }}
run: |
# If version contains dev*, remove it
if [[ "${{ steps.get-version-old.outputs.version }}" == *"dev"* ]]; then
NEW_VERSION=$(echo "${{ steps.get-version-old.outputs.version }}" | sed 's/.dev.*//')
python -m incremental.update ${{ env.MODULE_NAME }} --newversion $NEW_VERSION
fi
- name: 🔢 Get current version
id: get-version-current
run: |
result=$(python <<EOF
from ${{ env.MODULE_NAME }}._version import __version__
print(__version__.public())
EOF
)
echo "version=$result" >> $GITHUB_OUTPUT
- name: ⤵️ Pull latest changes from GitHub
run: |
git pull --ff
- name: 🖊 Commit
uses: stefanzweifel/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }}
with:
commit_message: |
Bump ${{ env.MODULE_NAME }} version to ${{ steps.get-version-current.outputs.version }}
- name: 🏗 Install package
run: |
python setup.py sdist bdist_wheel
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
- name: 🔢 Increment version - Developement
if: ${{ github.event_name != 'release' }}
run: |
python -m incremental.update ${{ env.MODULE_NAME }} --dev
- name: 🔢 Increment version - Release
if: ${{ github.event_name == 'release' }}
run: |
python -m incremental.update ${{ env.MODULE_NAME }} --patch
python -m incremental.update ${{ env.MODULE_NAME }} --dev
- name: 🔢 Get new version
id: get-version-new
run: |
result=$(python <<EOF
from ${{ env.MODULE_NAME }}._version import __version__
print(__version__.public())
EOF
)
echo "version=$result" >> $GITHUB_OUTPUT
- name: ⤵️ Pull latest changes from GitHub
run: |
git pull --ff
- name: 🖊 Commit
uses: stefanzweifel/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }}
with:
commit_message: |
Bump ${{ env.MODULE_NAME }} version to ${{ steps.get-version-new.outputs.version }}