1- name : Release
1+ # This workflow will upload a Python Package using Twine when a release is created
2+ # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+ name : Upload Python Package
5+
26on :
3- push :
4- branches :
5- - main
6- - pre/*
7- paths :
8- - ' scrapegraph-py/**'
7+ release :
8+ types : [published]
99
1010jobs :
11- build :
12- name : Build
13- runs-on : ubuntu-latest
14- # Only run if scrapegraph-py has changes
15- if : contains(github.event.head_commit.modified, 'scrapegraph-py/') || contains(github.event.head_commit.added, 'scrapegraph-py/') || contains(github.event.head_commit.removed, 'scrapegraph-py/')
16- steps :
17- - name : Install git
18- run : |
19- sudo apt update
20- sudo apt install -y git
21- - name : Install uv
22- uses : astral-sh/setup-uv@v3
23- - name : Install Node Env
24- uses : actions/setup-node@v4
25- with :
26- node-version : 20
27- - name : Checkout
28- uses : actions/checkout@v4.1.1
29- with :
30- fetch-depth : 0
31- persist-credentials : false
32- - name : Build app
33- run : |
34- cd scrapegraph-py
35- uv sync --frozen
36- uv build
37- id : build_cache
38- if : success()
39- - name : Cache build
40- uses : actions/cache@v4
41- with :
42- path : scrapegraph-py/dist
43- key : ${{ runner.os }}-build-${{ hashFiles('scrapegraph-py/dist/**') }}
44- if : steps.build_cache.outputs.id != ''
11+ deploy :
4512
46- release :
47- name : Release
4813 runs-on : ubuntu-latest
49- needs : build
50- environment : development
51- if : |
52- github.event_name == 'push' && github.ref == 'refs/heads/main' ||
53- github.event_name == 'push' && github.ref == 'refs/heads/pre/beta' ||
54- github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged && github.event.pull_request.base.ref == 'main' ||
55- github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged && github.event.pull_request.base.ref == 'pre/beta'
56- permissions :
57- contents : write
58- issues : write
59- pull-requests : write
60- id-token : write
14+
6115 steps :
62- - name : Checkout repo
63- uses : actions/checkout@v4.1.1
64- with :
65- fetch-depth : 0
66- persist-credentials : false
67- - name : Install uv
68- uses : astral-sh/setup-uv@v3
69- - name : Setup Python environment
70- run : |
71- cd ./scrapegraph-py
72- uv sync
73- - name : Restore build artifacts
74- uses : actions/cache@v4
75- with :
76- path : ./scrapegraph-py/dist
77- key : ${{ runner.os }}-build-${{ hashFiles('./scrapegraph-py/dist/**') }}
78- - name : Semantic Release
79- uses : cycjimmy/semantic-release-action@v4.1.0
80- env :
81- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
82- PYPI_TOKEN : ${{ secrets.PYPI_TOKEN }}
83- with :
84- working_directory : ./scrapegraph-py
85- semantic_version : 23
86- extra_plugins : |
87- semantic-release-pypi@3
88- @semantic-release/git
89- @semantic-release/commit-analyzer@12
90- @semantic-release/release-notes-generator@13
91- @semantic-release/github@10
92- @semantic-release/changelog@6
93- conventional-changelog-conventionalcommits@7
16+ - uses : actions/checkout@v4
17+ - name : Set up Python
18+ uses : actions/setup-python@v5
19+ with :
20+ python-version : ' 3.x'
21+ - name : Install dependencies
22+ run : |
23+ python -m pip install --upgrade pip
24+ pip install setuptools wheel twine
25+ - name : Build and publish
26+ env :
27+ TWINE_USERNAME : mvincig11
28+ TWINE_PASSWORD : ${{ secrets.PYPI_PASSWORD }}
29+ run : |
30+ git fetch --all --tags
31+ python setup.py sdist bdist_wheel
32+ twine upload dist/*
0 commit comments