Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created publish-package.yml #4

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
73aa6fb
Create publish-package.yml
cenevan May 17, 2024
3d40028
basic version
cenevan May 17, 2024
d0ac192
Merge branch 'storyprotocol:main' into main
cenevan May 23, 2024
1289220
version changes
cenevan May 24, 2024
2d19833
workflow dispatch
cenevan May 24, 2024
12d3a35
dependencies
cenevan May 24, 2024
5d48efa
change version
cenevan May 24, 2024
aa127fe
auto version change
cenevan May 24, 2024
6c8cb46
fix matrix
cenevan May 24, 2024
4c1c799
test
cenevan May 24, 2024
5637e1c
test2
cenevan May 24, 2024
14cd807
test3
cenevan May 24, 2024
b2a7e0c
test4
cenevan May 24, 2024
ac30a43
test5
cenevan May 24, 2024
88a910b
update version final
cenevan May 24, 2024
54dc098
update version final 1
cenevan May 24, 2024
9fc25d2
auto push 1
cenevan May 24, 2024
1c5627c
Update version
actions-user May 24, 2024
099bc8d
Update version
actions-user May 24, 2024
eec9c01
fix update version
cenevan May 24, 2024
999adae
Update version
actions-user May 24, 2024
7ebcdd3
add linting
cenevan May 24, 2024
eba934c
add flake file
cenevan May 24, 2024
4bfca14
Update version
actions-user May 24, 2024
67abaed
flake config change
cenevan May 24, 2024
fc53672
Update version
actions-user May 24, 2024
590f3e2
Update version
actions-user May 24, 2024
f2b5f67
version change
cenevan May 24, 2024
8d3878c
Update version
actions-user May 24, 2024
f895cf6
version control
cenevan May 29, 2024
62abc8c
Update version
actions-user May 29, 2024
4f6e095
Update version
actions-user May 29, 2024
878e1d0
Update version
actions-user May 29, 2024
af1cd66
version change
cenevan May 29, 2024
95eb48d
Update version
actions-user May 29, 2024
4814963
consolidate version files
cenevan May 29, 2024
dee6f8a
Update version
actions-user May 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
exclude = abi
ignore = W, E, F
109 changes: 109 additions & 0 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: publish package to PyPi

on:
workflow_dispatch:
inputs:
version_type:
type: choice
description: version to be published
options:
- major
- minor
- patch

jobs:
Timestamp:
uses: storyprotocol/gha-workflows/.github/workflows/reusable-timestamp.yml@main

lint:
needs: Timestamp
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8

- name: Run flake8
run: |
flake8 .

build:
needs: [Timestamp, lint]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["pypy3.9", "pypy3.10", "3.9", "3.10", "3.11", "3.12"]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
pip install -r requirements.txt
python -m pip install --upgrade pip
pip install setuptools wheel

- name: Build package
run: python setup.py sdist bdist_wheel

publish:
needs: [Timestamp, build, lint]
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: |
pip install -r requirements.txt
python -m pip install --upgrade pip
pip install setuptools wheel

- name: Change version number
env:
VERSION_TYPE: ${{ github.event.inputs.version_type }}
run: python update_version.py

- name: Commit version change
run: |
git add setup.py
git config --global user.name 'GitHub Actions Bot'
git config --global user.email '[email protected]'
git commit -m "Update version"

- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main

- name: Build package
run: python setup.py sdist bdist_wheel

- name: Publish to PyPI
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='story_protocol_python_sdk',
version='0.2.1',
version='0.1.7',
packages=find_packages(where='src', exclude=["tests"]),
package_dir={'': 'src'},
install_requires=[
Expand Down
26 changes: 26 additions & 0 deletions update_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import re, os
from setuptools import setup

version_type = os.getenv('VERSION_TYPE')

with open('setup.py', 'r') as f:
setup_py = f.read()

version = re.search(r"version='(\d+\.\d+\.\d+)'", setup_py).group(1)
major, minor, patch = map(int, version.split('.'))

if version_type == 'major':
major += 1
minor = 0
patch = 0
elif version_type == 'minor':
minor += 1
patch = 0
elif version_type == 'patch':
patch += 1

new_version = f"{major}.{minor}.{patch}"

with open('setup.py', 'w') as f:
f.write(re.sub(r"version='(\d+\.\d+\.\d+)'", f"version='{new_version}'", setup_py))