Skip to content

Commit 79733bf

Browse files
authored
feat: auto publish on version change (#106)
1 parent a718715 commit 79733bf

File tree

3 files changed

+66
-27
lines changed

3 files changed

+66
-27
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Publish to GitHub Release on Version Change
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v3
14+
with:
15+
fetch-depth: 2
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.x'
21+
22+
- name: Get current and previous version
23+
id: get_version
24+
run: |
25+
set -e
26+
CURR_VERSION=$(grep "version=" setup.py | head -1 | sed -E "s/.*version=['\"]([^'\"]*)['\"].*/\1/")
27+
PREV_VERSION=$(git show HEAD^:setup.py | grep "version=" | head -1 | sed -E "s/.*version=['\"]([^'\"]*)['\"].*/\1/")
28+
echo "Current version: $CURR_VERSION"
29+
echo "Previous version: $PREV_VERSION"
30+
echo "curr_version=$CURR_VERSION" >> $GITHUB_OUTPUT
31+
echo "prev_version=$PREV_VERSION" >> $GITHUB_OUTPUT
32+
33+
- name: Check if version changed
34+
id: version_check
35+
run: |
36+
if [ "${{ steps.get_version.outputs.curr_version }}" != "${{ steps.get_version.outputs.prev_version }}" ]; then
37+
echo "changed=true" >> $GITHUB_OUTPUT
38+
else
39+
echo "changed=false" >> $GITHUB_OUTPUT
40+
fi
41+
42+
- name: Create GitHub Release
43+
if: ${{ steps.version_check.outputs.changed == 'true' }}
44+
uses: softprops/action-gh-release@v1
45+
with:
46+
tag_name: ${{ steps.get_version.outputs.curr_version }}
47+
name: Release ${{ steps.get_version.outputs.curr_version }}
48+
generate_release_notes: true
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
52+
- name: Install dependencies
53+
if: ${{ steps.version_check.outputs.changed == 'true' }}
54+
run: |
55+
python -m pip install --upgrade pip
56+
pip install setuptools wheel twine
57+
58+
- name: Build and publish
59+
if: ${{ steps.version_check.outputs.changed == 'true' }}
60+
env:
61+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
62+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
63+
run: |
64+
python setup.py sdist bdist_wheel
65+
twine upload dist/*

.github/workflows/pythonpublish.yaml

Lines changed: 0 additions & 26 deletions
This file was deleted.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name='fyle',
8-
version='1.1.0',
8+
version='1.1.1',
99
author='Siva Narayanan',
1010
author_email='siva@fyle.in',
1111
description='Python SDK for accessing Fyle Platform APIs',

0 commit comments

Comments
 (0)