Skip to content

Update Version

Update Version #3

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