@@ -56,12 +56,49 @@ jobs:
5656 - name : Run tests
5757 run : pytest -v -p no:warnings
5858
59+ create-release :
60+ name : Create Release with Changelog
61+ runs-on : ubuntu-22.04
62+ needs : [test]
63+ if : startsWith(github.ref, 'refs/tags/v')
64+
65+ steps :
66+ - name : Checkout repository
67+ uses : actions/checkout@v4
68+ with :
69+ fetch-depth : 0
70+
71+ - name : Set up Python
72+ uses : actions/setup-python@v4
73+ with :
74+ python-version : " 3.11"
75+
76+ - name : Sync changelog to docs
77+ run : |
78+ cp CHANGELOG.md docs/changelog.md
79+ echo "✅ Synced changelog to docs"
80+
81+ - name : Extract release notes
82+ run : |
83+ VERSION=${GITHUB_REF#refs/tags/v}
84+ echo "Extracting release notes for version: $VERSION"
85+ python scripts/extract_release_notes.py $VERSION > current_release_notes.md
86+
87+ - name : Create GitHub Release
88+ uses : softprops/action-gh-release@v1
89+ with :
90+ body_path : current_release_notes.md
91+ draft : false
92+ prerelease : ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
93+ env :
94+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
95+
5996 publish-testpypi :
6097 name : Publish to TestPyPI
6198 runs-on : ubuntu-22.04
62- needs : [test] # Only run after tests pass
63- if : github.event_name == 'release ' && github.event.action == 'created' # Only on release creation
64-
99+ needs : [test, create-release ] # Run after tests and release creation
100+ if : github.event_name == 'push ' && startsWith( github.ref, 'refs/tags/v') # Only on tag push
101+
65102 steps :
66103 - name : Checkout repository
67104 uses : actions/checkout@v4
86123 env :
87124 TWINE_USERNAME : __token__
88125 TWINE_PASSWORD : ${{ secrets.TEST_PYPI_API_TOKEN }}
89-
126+
90127 - name : Test install from TestPyPI
91128 run : |
92129 # Create a temporary environment to test installation
@@ -104,8 +141,8 @@ jobs:
104141 publish-pypi :
105142 name : Publish to PyPI
106143 runs-on : ubuntu-22.04
107- needs : [test ] # Only run after TestPyPI publish succeeds
108- if : github.event_name == 'release ' && github.event.action == 'created' # Only on release creation
144+ needs : [publish-testpypi ] # Only run after TestPyPI publish succeeds
145+ if : github.event_name == 'push ' && startsWith( github.ref, 'refs/tags/v') # Only on tag push
109146
110147 steps :
111148 - name : Checkout repository
@@ -144,4 +181,38 @@ jobs:
144181 # Install from PyPI
145182 pip install $PACKAGE_NAME
146183 # Basic import test
147- python -c "import flixopt; print('PyPI installation successful!')"
184+ python -c "import flixopt; print('PyPI installation successful!')"
185+
186+ deploy-docs :
187+ name : Deploy Documentation
188+ runs-on : ubuntu-22.04
189+ needs : [publish-pypi] # Deploy docs after successful PyPI publishing
190+ if : startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'alpha') && !contains(github.ref, 'beta') && !contains(github.ref, 'rc')
191+
192+ steps :
193+ - name : Checkout repository
194+ uses : actions/checkout@v4
195+ with :
196+ fetch-depth : 0 # Fetch all history for proper versioning
197+
198+ - name : Set up Python
199+ uses : actions/setup-python@v4
200+ with :
201+ python-version : " 3.11"
202+
203+ - name : Install documentation dependencies
204+ run : |
205+ python -m pip install --upgrade pip
206+ pip install -e ".[docs]"
207+
208+ - name : Configure Git Credentials
209+ run : |
210+ git config user.name github-actions[bot]
211+ git config user.email 41898282+github-actions[bot]@users.noreply.github.com
212+
213+ - name : Deploy docs
214+ run : |
215+ VERSION=${GITHUB_REF#refs/tags/v}
216+ echo "Deploying docs after successful PyPI publish: $VERSION"
217+ mike deploy --push --update-aliases $VERSION latest
218+ mike set-default --push latest
0 commit comments