Skip to content

Commit

Permalink
Merge pull request #217 from Stryder-Git/master
Browse files Browse the repository at this point in the history
Automated Release Management
  • Loading branch information
Stryder-Git authored Oct 8, 2022
2 parents ac55a8c + 8fdd7cd commit 427fe4f
Show file tree
Hide file tree
Showing 10 changed files with 933 additions and 105 deletions.
14 changes: 14 additions & 0 deletions .github/config_new_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

new_version: '4.0.1'

change_log: |
- testing stuff
- and others
release_body: |
Full Documentation: pandas_market_calendars.readthedocs.io
19 changes: 19 additions & 0 deletions .github/workflows/check_branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: check_branch
on:
pull_request_target:
branches:
- master

workflow_dispatch:

jobs:
wrong_branch:
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.head.repo.fork || github.head_ref != 'dev' }}

steps:
- uses: superbrothers/close-pull-request@v3
with:
comment: Please re-open this PR against the dev branch. For more information, consult CONTRIBUTING.md.
- run: echo PR against master that is not based on dev && exit 1

121 changes: 121 additions & 0 deletions .github/workflows/releaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: releaser
on:
push:
branches: [master]

env:
NEWV: ''
OLDV: ''

jobs:
run_tests:
uses: ./.github/workflows/test_runner.yml

make_new_release:
needs: run_tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: get new_version
id: new_version
uses: KJ002/[email protected]
with:
file: .github/config_new_release.yml
key-path: '["new_version"]'

- name: get_new_current_version
run: |
echo "NEWV=${{ steps.new_version.outputs.data }}" >> $GITHUB_ENV
echo "OLDV=$(grep "VERSION" -m1 setup.py | cut -d"=" -f2 | sed "s/['\" ]//g")" >> $GITHUB_ENV
- name: verify ${{env.NEWV}} > ${{env.OLDV}}
if: ${{ env.NEWV <= env.OLDV }}
run: echo you did not increment the version number && exit 1

- name: get changes
id: changes
uses: KJ002/[email protected]
with:
file: .github/config_new_release.yml
key-path: '["change_log"]'

- name: get body
id: body
uses: KJ002/[email protected]
with:
file: .github/config_new_release.yml
key-path: '["release_body"]'

- name: update change log
run: |
sed 5q docs/change_log.rst > docs/new_log.rst
echo "$NEWV ($(date +%m/%d/%Y))" >> docs/new_log.rst
echo '~~~~~~~~~~~~~~' >> docs/new_log.rst
echo "${{ steps.changes.outputs.data }}" >> docs/new_log.rst
sed -n 6,$(wc -l docs/change_log.rst | cut -d' ' -f1)p docs/change_log.rst >> docs/new_log.rst
mv docs/new_log.rst docs/change_log.rst
- name: set up new version
run: |
sed -i "s/$OLDV/$NEWV/" setup.py
sed -i "s/$OLDV/$NEWV/" pyproject.toml
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine jupyter pytest
- name: build package
run: python -m build

- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}

- name: install from pypi
run: |
while [ "$NEWV" != $(pip index versions pandas_market_calendars | cut -d'(' -f2 | cut -d')' -f1 | sed 1q) ];\
do echo not found yet, sleeping 5s; sleep 5s; done
pip install pandas_market_calendars==$NEWV
- name: run tests
run: |
pip install .
mv pandas_market_calendars pandas_market_calendars_copy
python -c 'import pandas_market_calendars;print(pandas_market_calendars.__version__)'
pytest tests
- name: prepare usage.rst
run: |
sudo apt install pandoc
jupyter nbconvert --execute --ExecutePreprocessor.kernel_name='python3' --to rst --output-dir docs --output usage.rst examples/usage.ipynb
- uses: stefanzweifel/git-auto-commit-action@v4
with:
file_pattern: setup.py pyproject.toml docs/change_log.rst docs/usage.rst
commit_message: '[GH-Actions] v${{ env.NEWV }} -- updated configuration and documentation files.'

- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: v${{ env.NEWV }}
tag_name: v${{ env.NEWV }}
body: |
Changes:
${{ steps.changes.outputs.data }}
${{ steps.body.outputs.data }}




89 changes: 89 additions & 0 deletions .github/workflows/test_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: test_release
on:
pull_request:
branches: [master]

workflow_dispatch:

env:
NEWV: ""
OLDV: ""

jobs:
check:
runs-on: ubuntu-latest
steps:
- if: ${{ github.event.pull_request.head.repo.fork || github.head_ref != 'dev' }}
run: echo PR against main that is not based on dev && exit 1

run_tests:
needs: check
uses: ./.github/workflows/test_runner.yml

test_new_release:
needs: run_tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: get new_version
id: new_version
uses: KJ002/[email protected]
with:
file: .github/config_new_release.yml
key-path: '["new_version"]'

- name: get_new_current_version
run: |
echo "NEWV=${{ steps.new_version.outputs.data }}" >> $GITHUB_ENV
echo "OLDV=$(grep "VERSION" -m1 setup.py | cut -d"=" -f2 | sed "s/['\" ]//g")" >> $GITHUB_ENV
- name: warn_no_version
if: ${{ env.NEWV <= env.OLDV }}
uses: thollander/actions-comment-pull-request@v1
with:
message: WARNING - Version number in change_log is not incremented. Will not test release.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: exit_no_version
if: ${{ env.NEWV <= env.OLDV }}
run: echo you did not update the change_log && exit 1

- name: make rc vnumber
run: echo "NEWV=${{env.NEWV}}rc${{github.run_number}}.dev${{github.run_attempt}}" >> $GITHUB_ENV

- name: set version
run: |
echo release candidate: $NEWV
sed -i "s/$OLDV/$NEWV/" setup.py
sed -i "s/$OLDV/$NEWV/" pyproject.toml
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install dependencies
run: |
pip install --upgrade pip
pip install build twine pytest
- name: Build source distribution and wheel files
run: python -m build

- name: Upload files to TestPyPI
run: python -m twine upload --verbose --repository testpypi dist/* -u__token__ -p${{ secrets.TEST_PYPI_TOKEN }}

- name: Install from testpypi
run: |
while [ "$NEWV" != $(pip index versions -i https://test.pypi.org/simple --pre pandas_market_calendars | cut -d'(' -f2 | cut -d')' -f1 | sed 1q) ];\
do echo not found yet, sleeping 5s; sleep 5s; done
pip install -i https://test.pypi.org/simple pandas_market_calendars==$NEWV --no-deps
- name: test new release
run: |
pip install .
mv pandas_market_calendars pandas_market_calendars_copy
python -c 'import pandas_market_calendars;print(pandas_market_calendars.__version__)'
pytest tests
67 changes: 67 additions & 0 deletions .github/workflows/test_runner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: test_runner
on:
pull_request:
branches: [dev]
workflow_call:
workflow_dispatch:

jobs:
run_tests:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10']

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest coveralls
pip install .
- name: run tests
run: |
coverage run --source=pandas_market_calendars -m pytest tests
coverage lcov -o coverage.lcov
- name: coveralls parallel
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
flag-name: test_${{matrix.os}}_${{matrix.python-version}}
parallel: true
path-to-lcov: coverage.lcov

report_coverage:
if: ${{ always() }}
needs: run_tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: coveralls finalize
id: coveralls_finalize
uses: coverallsapp/github-action@master
with:
github-token: ${{secrets.github_token}}
parallel-finished: true
path-to-lcov: coverage.lcov









2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'default'
html_theme = 'sphinx_rtd_theme'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down
2 changes: 1 addition & 1 deletion docs/make_examples.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ FOR %%a IN (%~dp0\.) do set SOURCE=%%~dpa
set OLD_PYTHONPATH=%PYTHONPATH%
set PYTHONPATH=%PYTHONPATH%;%SOURCE%

jupyter nbconvert --ExecutePreprocessor.kernel_name=python3 --to rst --execute --output usage.rst ..\examples\usage.ipynb
jupyter nbconvert --to rst --execute --output-dir . --output usage.rst ..\examples\usage.ipynb
set PYTHONPATH=%OLD_PYTHONPATH%
Loading

0 comments on commit 427fe4f

Please sign in to comment.