Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
41 changes: 41 additions & 0 deletions .github/workflows/upload_pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Upload to PyPI

on:
workflow_dispatch:
push:
branches:
- main
release:
types:
- published

jobs:
make_sdist:
name: Make SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Optional, use if you use setuptools_scm

- name: Build SDist
run: pipx run build --sdist

- uses: actions/upload-artifact@v4
with:
path: dist/*.tar.gz

upload_all:
needs: [make_sdist]
environment: pypi
permissions:
id-token: write
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist

- uses: pypa/gh-action-pypi-publish@release/v1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
ghash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode("ascii")
ghash_arg = "-DCELMECHGITHASH="+ghash.strip()
except:
ghash_arg = "-DCELMECHGITHASH=485554c96625e8d3f90d5dd7cfac3e6a29eea763" #GITHASHAUTOUPDATE
ghash_arg = "-DCELMECHGITHASH=b48d1d9fb4e0e7a82402ea61d84f9dff899f048d" #GITHASHAUTOUPDATE

extra_link_args=[]
if sys.platform == 'darwin':
Expand Down
32 changes: 30 additions & 2 deletions update_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,33 @@
with open("setup.py", "w") as f:
f.writelines(setuplines)

print("To commit, copy and paste:")
print("\ngit commit -a -m \"Updating version to "+celmechversion+"\"")
# find changelog
with open("changelog.md") as f:
found_start = 0
changelog = ""
cl = f.readlines()
for l in cl:
if found_start == 0 and l.startswith("### Version"):
if celmechversion in l:
found_start = 1
continue
if found_start == 1 and l.startswith("### Version"):
found_start = 2
if found_start == 1:
changelog += l

if found_start != 2 or len(changelog.strip())<5:
raise RuntimeError("Changelog not found")

with open("_changelog.tmp", "w") as f:
f.writelines(changelog.strip()+"\n")

print("----")
print("Changelog:\n")
print(changelog.strip())
print("----")
print("Next:")
print("\ngit commit -a -m \""+celmechversion+"\"")
print("git tag "+celmechversion+" && git push && git push --tags")
print("gh release create "+celmechversion+" --notes-file _changelog.tmp")
print("----")