Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Fix/create pr on tag #7

Fix/create pr on tag

Fix/create pr on tag #7

Workflow file for this run

name: check-pyproject-version
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
check_version:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install dependencies
run: |
python -m pip install "toml==0.10.2" "toml-cli==0.6.0"
- name: Compare Versions
id: compare_versions
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PYPROJECT_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['tool']['poetry']['version'])")
echo "PYPROJECT_VERSION=${PYPROJECT_VERSION}"
GITHUB_RELEASE_VERSION=$(curl --silent "https://api.github.com/repos/climatepolicyradar/data-access/releases/latest" | jq -r '.tag_name')
# remove the "v" from the version
GITHUB_RELEASE_VERSION=${GITHUB_RELEASE_VERSION:1}
echo "GITHUB_RELEASE_VERSION=${GITHUB_RELEASE_VERSION}"
if [[ $PYPROJECT_VERSION > $GITHUB_RELEASE_VERSION ]]; then
echo "The pyproject.toml version is greater than the latest GitHub release."
echo "BUMP_GITHUB_RELEASE=True" >> $GITHUB_OUTPUT
else
echo "The pyproject.toml version is not greater than the latest GitHub release."
exit 1
fi
- name: Bump GitHub Release
if: steps.compare_versions.outputs.BUMP_GITHUB_RELEASE == 'True'
run: |
PYPROJECT_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['tool']['poetry']['version'])")
echo "PYPROJECT_VERSION=${PYPROJECT_VERSION}"
echo "Bumping GitHub release to -> ${PYPROJECT_VERSION}"
toml set --toml-path pyproject.toml tool.poetry.version ${PYPROJECT_VERSION}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5