Skip to content

Merge pull request #1872 from cmu-delphi/release/indicators_v0.3.43_u… #90

Merge pull request #1872 from cmu-delphi/release/indicators_v0.3.43_u…

Merge pull request #1872 from cmu-delphi/release/indicators_v0.3.43_u… #90

name: Publish release
on:
push:
branches: [ prod ]
workflow_dispatch:
jobs:
correct_repository:
runs-on: ubuntu-latest
steps:
- name: fail on fork
if: github.repository_owner != 'cmu-delphi'
run: exit 1
check:
runs-on: ubuntu-latest
needs: correct_repository
steps:
- name: Check out code
uses: actions/checkout@v2
with:
ssh-key: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_SSH }}
fetch-depth: 5
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install bump2version
run: python -m pip install bump2version
- name: Check for delphi-utils changes
uses: dorny/paths-filter@v2
id: changes
with:
# when base and ref are the same, changes are detected against the most recent commit before the push.
# see https://github.com/dorny/paths-filter#usage for details.
base: 'prod'
ref: 'prod'
filters: |
utils:
- '_delphi_utils_python/**'
- name: Extract indicators version
id: indicators
run: |
echo -n "::set-output name=version::"
bump2version --dry-run --list patch | grep ^current_version | sed -r s,"^.*=",,
- name: Tag indicators
run: git tag covidcast-indicators/v${{ steps.indicators.outputs.version }}
- name: Extract utils version
id: utils
working-directory: ./_delphi_utils_python
run: |
echo -n "::set-output name=version::"
bump2version --dry-run --list patch | grep ^current_version | sed -r s,"^.*=",,
- name: Tag utils
if: ${{ steps.changes.outputs.utils == 'true' }}
run: git tag delphi-utils/v${{ steps.utils.outputs.version }}
- name: Publish tags
run: git push --tags
outputs:
indicators-version: ${{ steps.indicators.outputs.version }}
utils-version: ${{ steps.utils.outputs.version }}
publish-utils: ${{ steps.changes.outputs.utils }}
upload_pypi:
needs: check
if: ${{ needs.check.outputs.publish-utils == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: _delphi_utils_python
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install testing dependencies
run: |
python -m pip install --upgrade pip
pip install pylint pytest pydocstyle wheel twine
- name: Install
run: |
make install
- name: Release
run: |
make release
- uses: actions/upload-artifact@v2
with:
name: delphi_utils
path: _delphi_utils_python/dist/*.tar.gz
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.DELPHI_PYPI_PROD_TOKEN }}
packages_dir: _delphi_utils_python/dist/
skip_existing: true
sync_main:
needs: correct_repository
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
with:
ref: main
ssh-key: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_SSH }}
- name: Reset main branch
run: |
git fetch origin prod:prod
git reset --hard prod
- name: Create pull request into main
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_PAT }}
branch: bot/sync-prod-main
commit-message: 'chore: sync prod-main'
base: main
title: 'chore: sync prod->main'
labels: chore
reviewers: krivard
assignees: krivard
body: |
Syncing Prod->Main.