forked from PyPSA/PyPSA
-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (75 loc) · 2.53 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Deploy release
on:
push:
tags:
- v*.*.*
jobs:
deploy-to-pypi:
name: Build and publish Python distributions to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Build distribution
run: |
python setup.py sdist
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
deploy-to-github-releases:
name: Build and publish to GitHub Releases
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Fetch all history for all tags and branches (necessary for setuptools_scm)
run: git fetch --prune --unshallow
- name: Release
uses: softprops/action-gh-release@v2
with:
body: |
Revised release notes are available in the [documentation](https://pypsa.readthedocs.io/en/latest/release_notes.html).
append_body: true
generate_release_notes: true
update-version:
name: Update version in CITATION.cff
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: master
- name: Fetch all history for all tags and branches (necessary for setuptools_scm)
run: git fetch --prune --unshallow
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- run: pip install toml setuptools_scm
- run: |
import re
from setuptools_scm import get_version
# Fetch version number
version = get_version()
# Read CITATION.cff file
with open('CITATION.cff', 'r') as file:
cff_content = file.read()
# Update the version in the .cff file
updated_cff_content = re.sub(r"(?<=version: ).+(?= #)",version,cff_content,flags=re.MULTILINE)
# Write the updated content back to the CITATION.cff file
with open('CITATION.cff', 'w') as file:
file.write(updated_cff_content)
shell: python
- name: Commit and push changes
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git checkout master
git pull origin master
git add CITATION.cff
git commit -m '[github-actions.ci] auto update version in `CITATION.cff`' || exit 0
git push origin master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}