Skip to content

Update Microdata Tools Version #767

Update Microdata Tools Version

Update Microdata Tools Version #767

name: Update Microdata Tools Version
permissions:
contents: write
pull-requests: write
on:
schedule:
- cron: 0 10 * * * # Runs everyday at 10:00
workflow_dispatch: # Allows manual triggering of the workflow
jobs:
update-dependency:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensure the full history is fetched
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install the latest version of uv
uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2
- name: Sync dependencies
run: uv sync
- name: Check for New Version
id: check_version
run: |
CURRENT_VERSION=$(uv pip show microdata-tools | grep Version | awk '{print $2}')
LATEST_VERSION=$(curl -s https://pypi.org/pypi/microdata-tools/json | jq -r .info.version)
echo "Current version: $CURRENT_VERSION"
echo "Latest version: $LATEST_VERSION"
if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then
echo "::set-output name=new_version::$LATEST_VERSION"
else
echo "Already up-to-date"
exit 0
fi
- name: Update Microdata Tools Dependency
if: steps.check_version.outputs.new_version
env:
NEW_VERSION: ${{ steps.check_version.outputs.new_version }}
run: |
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
git pull origin main
git checkout -b "bump-microdata-tools-$NEW_VERSION"
uv add "microdata-tools==$NEW_VERSION"
git add pyproject.toml uv.lock
git commit -m "Update microdata-tools to $NEW_VERSION"
git push origin "bump-microdata-tools-$NEW_VERSION"
- name: Create Pull Request
if: steps.check_version.outputs.new_version
env:
NEW_VERSION: ${{ steps.check_version.outputs.new_version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create \
--base main \
--head "bump-microdata-tools-$NEW_VERSION" \
--title "Update microdata-tools to $NEW_VERSION" \
--body "This PR updates microdata-tools to version $NEW_VERSION."
# --reviewer statisticsnorway/microdata-developers # Reviwer not found [should work according to docs](https://cli.github.com/manual/gh_pr_create)