forked from muhammedattif/Paymob-Solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (54 loc) · 2.07 KB
/
publish.yml
File metadata and controls
65 lines (54 loc) · 2.07 KB
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
name: Publish Python 🐍 distributions 📦 to PyPI
on:
release:
types: [published]
push:
branches:
- main
jobs:
build-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: '3.9'
- name: Install pypa/setuptools
run: python -m pip install wheel
- name: Extract tag name
id: tag
run: echo ::set-output name=TAG_NAME::$(echo $GITHUB_REF | cut -d / -f 3)
- name: Determine new release version
id: release-version
if: github.ref == 'refs/heads/main'
run: |
current_version=${{ steps.tag.outputs.TAG_NAME }}
IFS='.' read -ra version_parts <<< "$current_version"
new_version="${version_parts[0]}.${version_parts[1]}.$((${version_parts[2]} + 1))"
echo "::set-output name=NEW_RELEASE_VERSION::$new_version"
- name: Update version in setup.py
run: |
if [[ -n "${{ steps.release-version.outputs.NEW_RELEASE_VERSION }}" ]]; then
new_release_version="${{ steps.release-version.outputs.NEW_RELEASE_VERSION }}"
sed -i "s/{{VERSION_PLACEHOLDER}}/${new_release_version}/g" setup.py
else
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" setup.py
fi
- name: Build a binary wheel
run: python setup.py sdist bdist_wheel
- name: Publish package 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Adjust release tag
if: startsWith(github.ref, 'refs/tags/')
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git tag -d "${{ steps.tag.outputs.TAG_NAME }}"
git push origin :refs/tags/${{ steps.tag.outputs.TAG_NAME }}
git tag "${{ steps.tag.outputs.TAG_NAME }}"
git push origin "${{ steps.tag.outputs.TAG_NAME }}"