-
Notifications
You must be signed in to change notification settings - Fork 1
181 lines (158 loc) · 6.33 KB
/
update_version.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: Update Version
on:
workflow_dispatch:
inputs:
bump:
description: 'The version bump to apply [possible values: major, minor, patch]'
required: true
type: choice
options:
- major
- minor
- patch
package:
description: 'The package to update [possible values: all, darts-acquisition, darts-ensemble, darts-pipeline, darts-preprocessing, darts-segmentation, darts-superresolution]'
required: true
type: choice
options:
- all
- darts-acquisition
- darts-ensemble
- darts-pipeline
- darts-preprocessing
- darts-segmentation
- darts-superresolution
publish:
description: 'Publish the package to PyPI and GitHub releases'
required: false
type: boolean
default: false
jobs:
update-version:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install rye
uses: eifinger/setup-rye@v4
with:
enable-cache: true
version: '0.39.0'
# Do a version bump to the package
- name: Update version in pyproject.toml
run: |
if [ ${{ github.event.inputs.package }} == 'all' ]; then
rye version --bump ${{ github.event.inputs.bump }}
cd darts-acquisition && rye version --bump ${{ github.event.inputs.bump }}
cd ../darts-ensemble && rye version --bump ${{ github.event.inputs.bump }}
cd ../darts-pipeline && rye version --bump ${{ github.event.inputs.bump }}
cd ../darts-preprocessing && rye version --bump ${{ github.event.inputs.bump }}
cd ../darts-segmentation && rye version --bump ${{ github.event.inputs.bump }}
cd ../darts-superresolution && rye version --bump ${{ github.event.inputs.bump }}
else
rye version --bump ${{ github.event.inputs.bump }}
cd ${{ github.event.inputs.package }} && rye version --bump ${{ github.event.inputs.bump }}
fi
# Get the new version with rye version and save it as an variable
- name: Get new version
id: get_version
run: echo "VERSION=$(rye version)" >> $GITHUB_OUTPUT
- name: Commit changes
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git add pyproject.toml
git commit -m "${{ github.event.inputs.bump }} version bump to ${{ steps.get_version.outputs.VERSION }} of ${{ github.event.inputs.package }}"
git push
build-and-publish:
runs-on: ubuntu-latest
needs:
- update-version
permissions:
contents: write
id-token: write
if: github.event.inputs.publish == true
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install rye
uses: eifinger/setup-rye@v4
with:
enable-cache: true
version: '0.39.0'
- name: Build package
run: |
if [ ${{ github.event.inputs.package }} == 'all' ]; then
cd darts-acquisition && rye build && cd ..
cd darts-ensemble && rye build && cd ..
cd darts-pipeline && rye build && cd ..
cd darts-preprocessing && rye build && cd ..
cd darts-segmentation && rye build && cd ..
cd darts-superresolution && rye build && cd ..
else
cd ${{ github.event.inputs.package }} && rye build && cd ..
fi
# - name: Publish to PyPI
# run: |
# if [ ${{ github.event.inputs.package }} == 'all' ]; then
# cd darts-acquisition && rye publish --token ${{ secrets.PYPI_TOKEN }} --yes && cd ..
# cd darts-ensemble && rye publish --token ${{ secrets.PYPI_TOKEN }} --yes && cd ..
# cd darts-pipeline && rye publish --token ${{ secrets.PYPI_TOKEN }} --yes && cd ..
# cd darts-preprocessing && rye publish --token ${{ secrets.PYPI_TOKEN }} --yes && cd ..
# cd darts-segmentation && rye publish --token ${{ secrets.PYPI_TOKEN }} --yes && cd ..
# cd darts-superresolution && rye publish --token ${{ secrets.PYPI_TOKEN }} --yes && cd ..
# else
# cd ${{ github.event.inputs.package }} && rye publish --token ${{ secrets.PYPI_TOKEN }} --yes && cd ..
# fi
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.get_version.outputs.VERSION }}
release_name: Release ${{ steps.get_version.outputs.VERSION }}
draft: false
prerelease: false
- name: Upload packages to GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for file in ${{ github.event.inputs.package }}/dist/*.{whl,tar.gz}; do
echo "Uploading $file..."
curl -sSL \
-X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: $(file -b --mime-type $file)" \
--data-binary @$file \
"${{ steps.create_release.outputs.upload_url }}?name=$(basename $file)"
done
build-and-publish-docs:
runs-on: ubuntu-latest
needs:
- update-version
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Get cache id
run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- name: Cache dependencies
uses: actions/cache@v4
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material
- name: Install dependencies
run: |
pip install "mkdocs-material[imaging]>=9.5.38" "mkdocstrings[python]>=0.26.1" "mike>=2.1.3"
- name: Publish documentation
run: mike deploy --push --update-aliases ${{ steps.get_version.outputs.VERSION }} latest