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

refactor(release): update make-release script to generate author names #760

Merged
merged 2 commits into from
Dec 12, 2019
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ How to Cite

##### ***Software/Code citation for FloPy:***

[Bakker, M., Post, V., Langevin, C.D., Hughes, J.D., White, J.T., Starn, J.J., and Fienen, M.N., 2019, FloPy v3.3.0 — release candidate: U.S. Geological Survey Software Release, 18 November 2019, http://dx.doi.org/10.5066/F7BK19FH](http://dx.doi.org/10.5066/F7BK19FH)
[Bakker, M., Post, V., Langevin, C. D., Hughes, J. D., White, J. T., Leaf, A. T., Paulinski, S. R., Larsen, J. D., Toews, M. W., Morway, E. D., Bellino, J. C., Starn, J. J., and Fienen, M. N., 2019, FloPy v3.3.0 — release candidate: U.S. Geological Survey Software Release, 12 December 2019, http://dx.doi.org/10.5066/F7BK19FH](http://dx.doi.org/10.5066/F7BK19FH)


MODFLOW Resources
Expand Down
1 change: 0 additions & 1 deletion binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ dependencies:
- rasterio>=1.0
- rasterstats
- pyshp
- hydrofunctions
- pip
2 changes: 1 addition & 1 deletion code.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"laborHours": -1,
"version": "3.3.0",
"date": {
"metadataLastUpdated": "2019-11-18"
"metadataLastUpdated": "2019-12-12"
},
"organization": "U.S. Geological Survey",
"permissions": {
Expand Down
2 changes: 1 addition & 1 deletion docs/PyPi_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ How to Cite

*Software/Code citation for FloPy:*

[Bakker, M., Post, V., Langevin, C.D., Hughes, J.D., White, J.T., Starn, J.J., and Fienen, M.N., 2019, FloPy v3.3.0 — release candidate: U.S. Geological Survey Software Release, 18 November 2019, http://dx.doi.org/10.5066/F7BK19FH](http://dx.doi.org/10.5066/F7BK19FH)
[Bakker, M., Post, V., Langevin, C. D., Hughes, J. D., White, J. T., Leaf, A. T., Paulinski, S. R., Larsen, J. D., Toews, M. W., Morway, E. D., Bellino, J. C., Starn, J. J., and Fienen, M. N., 2019, FloPy v3.3.0 — release candidate: U.S. Geological Survey Software Release, 12 December 2019, http://dx.doi.org/10.5066/F7BK19FH](http://dx.doi.org/10.5066/F7BK19FH)


Disclaimer
Expand Down
6 changes: 3 additions & 3 deletions docs/USGS_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ author:
- Michael W. Toews
- Eric D. Morway
- Jason C. Bellino
- Jeffrey Starn
- Jeffrey J. Starn
- Michael N. Fienen
header-includes:
- \usepackage{fancyhdr}
Expand All @@ -23,7 +23,7 @@ header-includes:
- \fancyhead[CE, CO]{FloPy Release Notes}
- \fancyfoot[LE, RO]{FloPy version 3.3.0}
- \fancyfoot[CO, CE]{\thepage\ of \pageref{LastPage}}
- \fancyfoot[RE, LO]{11/18/2019}
- \fancyfoot[RE, LO]{12/12/2019}
geometry: margin=0.75in
---

Expand Down Expand Up @@ -56,7 +56,7 @@ How to Cite

##### ***Software/Code citation for FloPy:***

[Bakker, M., Post, V., Langevin, C.D., Hughes, J.D., White, J.T., Starn, J.J., and Fienen, M.N., 2019, FloPy v3.3.0 — release candidate: U.S. Geological Survey Software Release, 18 November 2019, http://dx.doi.org/10.5066/F7BK19FH](http://dx.doi.org/10.5066/F7BK19FH)
[Bakker, M., Post, V., Langevin, C. D., Hughes, J. D., White, J. T., Leaf, A. T., Paulinski, S. R., Larsen, J. D., Toews, M. W., Morway, E. D., Bellino, J. C., Starn, J. J., and Fienen, M. N., 2019, FloPy v3.3.0 — release candidate: U.S. Geological Survey Software Release, 12 December 2019, http://dx.doi.org/10.5066/F7BK19FH](http://dx.doi.org/10.5066/F7BK19FH)


Disclaimer
Expand Down
83 changes: 44 additions & 39 deletions docs/make_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,25 @@ Instructions for making a FloPy release
## Make a release branch from develop

1. Make a release branch from develop (*e.g.* `release3.2.10`)
2. Update MODFLOW 6 dfn files in the repository and MODFLOW 6 package classes by running:
2. Update MODFLOW 6 dfn files in the repository and MODFLOW 6 package classes by running:

```
python -c 'import flopy; flopy.mf6.utils.generate_classes(branch="master", backup=False)'
```

Evaluate if there are any changes that seem to reduce MODFLOW 6 functionality before committing changes on the release branch.


## Update the release version number

1. Increment `major`, `minor`, and/or `micro` numbers in `flopy/version.py`, as appropriate.


## Update the Software/Code citation for FloPy

1. Update the `authors` list in `release/make-release.py` for the Software/Code citation for FloPy, if required.


## Build USGS release notes

1. Manually run `make-release.py` in the `release/` directory to update version information using:
Expand Down Expand Up @@ -58,43 +65,12 @@ Instructions for making a FloPy release
3. Make release on [GitHub website](https://github.com/modflowpy/flopy/releases). Add version changes for [current release](https://github.com/modflowpy/flopy/blob/develop/docs/version_changes.md) from to release text. Publish release.


## Update PyPi

1. Make sure `pypandoc` and `twine` are installed using:

```
conda search pypandoc
conda search twine
```


2. If they are not installed, install one or both using using:


```
conda install pypandoc
conda install twine
```

3. Create the source zip file in a terminal using:

```
python setup.py sdist --format=zip
```

4. Upload the release to PyPi using (*make sure* `twine` *is installed using conda*):

```
twine upload dist/flopy-version.zip
```


## Update flopy-feedstock for conda install

1. Download the `*.tar.gz` file for the current release from the [GitHub website](https://github.com/modflowpy/flopy/releases).

2. Calculate the sha256 checksum for the `*.tar.gz` using:

```
openssl sha256 flopy-version.tar.gz
```
Expand All @@ -107,8 +83,8 @@ Instructions for making a FloPy release
cd /Users/jdhughes/Documents/Development/flopy-feedstock_git
git fetch upstream
git checkout master
git reset --hard upstream/master
git push origin master --force
git reset --hard upstream/master
git push origin master --force
```

4. Rerender the repo using `conda-smithy` (make sure `conda-smithy` is installed using conda):
Expand All @@ -124,6 +100,36 @@ Instructions for making a FloPy release
6. Make pull request to [flopy-feedstock](https://github.com/conda-forge/flopy-feedstock)


## Update PyPi

1. Make sure `pypandoc` and `twine` are installed using:

```
conda search pypandoc
conda search twine
```


2. If they are not installed, install one or both using using:


```
conda install pypandoc
conda install twine
```

3. Create the source zip file in a terminal using:

```
python setup.py sdist --format=zip
```

4. Upload the release to PyPi using (*make sure* `twine` *is installed using conda*):

```
twine upload dist/flopy-version.zip
```

## Sync develop and master branches

1. Merge the `master` branch into the `develop` branch.
Expand All @@ -134,8 +140,7 @@ Instructions for making a FloPy release

```
python make-release.py
```
```
4. Commit and push the modified `develop` branch.





2 changes: 1 addition & 1 deletion flopy/version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# flopy version file automatically created using...make-release.py
# created on...November 18, 2019 08:34:13
# created on...December 12, 2019 16:22:42

major = 3
minor = 3
Expand Down
115 changes: 86 additions & 29 deletions release/make-release.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# as the path if the file is in the root repository directory
paths = ['../flopy', '../',
'../docs', '../docs',
'../', '../']
'../', '../', '../docs']
files = ['version.py', 'README.md',
'USGS_release.md', 'PyPi_release.md',
'code.json', 'DISCLAIMER.md']
'code.json', 'DISCLAIMER.md', 'notebook_examples.md']

# check that there are the same number of entries in files and paths
if len(paths) != len(files):
Expand All @@ -27,6 +27,16 @@

pak = 'flopy'

# authors list for Software/Code citation for FloPy
# author should be defined LastName FirstName MiddleInitial
# MiddleInitial can be absent. Use spaces instead of commas to separate
# LastName, FirstName, and MiddleInitial.
authors = ['Bakker Mark', 'Post Vincent', 'Langevin Christian D',
'Hughes Joseph D', 'White Jeremy T', 'Leaf Andrew T',
'Paulinski Scott R', 'Larsen Joshua D', 'Toews Michael W',
'Morway Eric D', 'Bellino Jason C', 'Starn Jeffrey J',
'Fienen Michael N']

approved = '''Disclaimer
----------

Expand Down Expand Up @@ -115,6 +125,32 @@ def get_tag(v0, v1, v2):
return tag


def get_software_citation(version, is_approved):
now = datetime.datetime.now()
sb = ''
if not is_approved:
sb = ' — release candidate'
line = '['
for ipos, author in enumerate(authors):
if ipos > 0:
line += ', '
if ipos == len(authors) - 1:
line += 'and '
sv = author.split()
tauthor = '{}, {}.'.format(sv[0], sv[1][0])
if len(sv) > 2:
tauthor += ' {}.'.format(sv[2][0])
line += tauthor
line += ', {}, '.format(now.year) + \
'FloPy v{}{}: '.format(version, sb) + \
'U.S. Geological Survey Software Release, ' + \
'{}, '.format(now.strftime('%d %B %Y')) + \
'http://dx.doi.org/10.5066/F7BK19FH]' + \
'(http://dx.doi.org/10.5066/F7BK19FH)'

return line


def update_version():
try:
fpth = os.path.join(paths[0], files[0])
Expand Down Expand Up @@ -157,6 +193,9 @@ def update_version():
# update README.md with new version information
update_readme_markdown(vmajor, vminor, vmicro)

# update notebook_examples.md
update_notebook_examples_markdown()

# update code.json
update_codejson(vmajor, vminor, vmicro)

Expand Down Expand Up @@ -232,27 +271,20 @@ def update_readme_markdown(vmajor, vminor, vmicro):
'modflowpy/flopy/badge.svg?branch={})]'.format(branch) + \
'(https://coveralls.io/github/modflowpy/' + \
'flopy?branch={})'.format(branch)
elif '[Binder]' in line:
# [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/modflowpy/flopy.git/develop)
line = '[![Binder](https://mybinder.org/badge_logo.svg)]' + \
'(https://mybinder.org/v2/gh/modflowpy/flopy.git/' + \
'{}'.format(branch) + ')'
elif 'http://dx.doi.org/10.5066/F7BK19FH' in line:
now = datetime.datetime.now()
sb = ''
if not is_approved:
sb = ' — release candidate'
line = '[Bakker, M., Post, V., Langevin, C.D., Hughes, J.D., ' + \
'White, J.T., Leaf, A.T., Paulinski, S.R., Larsen, J.D., ' + \
'Toews, M.W., Morway, E.D., Bellino, J.C., Starn, J.J., ' + \
'and Fienen, M.N., ' + \
'{}, '.format(now.year) + \
'FloPy v{}{}: '.format(version, sb) + \
'U.S. Geological Survey Software Release, ' + \
'{}, '.format(now.strftime('%d %B %Y')) + \
'http://dx.doi.org/10.5066/F7BK19FH]' + \
'(http://dx.doi.org/10.5066/F7BK19FH)'
line = get_software_citation(version, is_approved)
elif 'Disclaimer' in line:
line = disclaimer
terminate = True
f.write('{}\n'.format(line))
if terminate:
break

f.close()

# write disclaimer markdown file
Expand All @@ -264,6 +296,34 @@ def update_readme_markdown(vmajor, vminor, vmicro):
return


def update_notebook_examples_markdown():
# create disclaimer text
is_approved, disclaimer = get_disclaimer()

# define branch
if is_approved:
branch = 'master'
else:
branch = 'develop'

# read notebook_examples.md into memory
fpth = os.path.join(paths[6], files[6])
with open(fpth, 'r') as file:
lines = [line.rstrip() for line in file]

# rewrite notebook_examples.md
terminate = False
f = open(fpth, 'w')
for line in lines:
if '[Binder]' in line:
# [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/modflowpy/flopy.git/develop)
line = '[![Binder](https://mybinder.org/badge_logo.svg)]' + \
'(https://mybinder.org/v2/gh/modflowpy/flopy.git/' + \
'{}'.format(branch) + ')'
f.write('{}\n'.format(line))
f.close()


def update_USGSmarkdown(vmajor, vminor, vmicro):
# get branch
branch = get_branch()
Expand Down Expand Up @@ -295,19 +355,13 @@ def update_USGSmarkdown(vmajor, vminor, vmicro):
f.write('---\n')
f.write('title: FloPy Release Notes\n')
f.write('author:\n')
f.write(' - Mark Bakker\n')
f.write(' - Vincent Post\n')
f.write(' - Christian D. Langevin\n')
f.write(' - Joseph D. Hughes\n')
f.write(' - Jeremy T. White\n')
f.write(' - Andrew T. Leaf\n')
f.write(' - Scott R. Paulinski\n')
f.write(' - Joshua D. Larsen\n')
f.write(' - Michael W. Toews\n')
f.write(' - Eric D. Morway\n')
f.write(' - Jason C. Bellino\n')
f.write(' - Jeffrey Starn\n')
f.write(' - Michael N. Fienen\n')
for author in authors:
sv = author.split()
tauthor = '{}'.format(sv[1])
if len(sv) > 2:
tauthor += ' {}.'.format(sv[2][0])
tauthor += ' {}'.format(sv[0])
f.write(' - {}\n'.format(tauthor))
f.write('header-includes:\n')
f.write(' - \\usepackage{fancyhdr}\n')
f.write(' - \\usepackage{lastpage}\n')
Expand All @@ -330,6 +384,9 @@ def update_USGSmarkdown(vmajor, vminor, vmicro):
writeline = False
elif line == 'How to Cite':
writeline = True
elif 'http://dx.doi.org/10.5066/F7BK19FH' in line:
writeline = True
line = get_software_citation(version, is_approved)
elif line == 'MODFLOW Resources':
writeline = False
elif line == 'Disclaimer':
Expand Down