-
Notifications
You must be signed in to change notification settings - Fork 145
116 lines (109 loc) · 4.08 KB
/
release-if-needed.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
name: Release if needed
on:
push:
branches:
- main
env:
PYTHON_VERSION: "3.11"
jobs:
check-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r tools/tools_requirements.txt
pip install --upgrade hatch
- name: Check which 📦 needs to be released
run: |
python tools/check_package_release.py
- name: Set outputs
id: version_check
run: |
echo "new_release=${{ env.NEW_RELEASE }}" >> $GITHUB_OUTPUT
echo "package_name=${{ env.PACKAGE_NAME }}" >> $GITHUB_OUTPUT
echo "package_version=${{ env.PACKAGE_VERSION }}" >> $GITHUB_OUTPUT
outputs:
new_release: ${{ steps.version_check.outputs.new_release }}
package_name: ${{ steps.version_check.outputs.package_name }}
package_version: ${{ steps.version_check.outputs.package_version }}
build-publish:
needs: [check-version]
if: |
needs.check-version.outputs.new_release == 'True'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r tools/tools_requirements.txt
pip install hatch
- name: Extract release notes from ${{needs.check-version.outputs.package_name}}/CHANGELOG.md
id: extract
run: |
formatted_date=$(date +"%Y-%m-%d")
python tools/extract_release_notes.py \
"${{needs.check-version.outputs.package_name}}" \
"${{needs.check-version.outputs.package_version}} — $formatted_date"
- name: Tag main and create release on github
run: |
./tools/release.sh mckinsey vizro ${{ secrets.GITHUB_TOKEN }} \
${{needs.check-version.outputs.package_name}} \
${{needs.check-version.outputs.package_version}} release_body.txt
- name: Build package
run: |
cd "${{ needs.check-version.outputs.package_name }}"
hatch build
- name: Set PyPI token
run: |
if [ "${{ needs.check-version.outputs.package_name }}" == "vizro-core" ]; then
echo 'PYPI_TOKEN=${{ secrets.VIZRO_PYPI_TOKEN }}' >> $GITHUB_ENV
elif [ "${{ needs.check-version.outputs.package_name }}" == "vizro-ai" ]; then
echo 'PYPI_TOKEN=${{ secrets.VIZRO_AI_PYPI_TOKEN }}' >> $GITHUB_ENV
fi
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: ${{ needs.check-version.outputs.package_name }}/dist
password: ${{ env.PYPI_TOKEN }}
version-bump:
needs: [check-version, build-publish]
if: |
needs.check-version.outputs.new_release == 'True'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.VIZRO_SVC_PAT }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install hatch
- name: Push bumped version to main
run: |
cd "${{ needs.check-version.outputs.package_name }}"
hatch version patch,dev
hatch run changelog:add
if [ "${{ needs.check-version.outputs.package_name }}" == "vizro-core" ]; then
hatch run schema
fi
git config user.email "[email protected]"
git config user.name "Vizro Team"
git add -A
git commit -m "[Release] Bump ${{needs.check-version.outputs.package_name}} to $(hatch version) [skip ci]"
git push origin main