-
Notifications
You must be signed in to change notification settings - Fork 17
126 lines (121 loc) · 3.9 KB
/
publish-release.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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.