Skip to content

Update pull request step #2

Update pull request step

Update pull request step #2

# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
#
# SPDX-License-Identifier: MPL-2.0
name: Update PGM wheel version
on:
schedule:
- cron: '0 2 * * *'
workflow_dispatch:
push:
permissions:
contents: write
pull-requests: write
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
update-pgm-wheel-version:
name: Update PGM wheel version
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # 7.0.1
with:
fetch-depth: 0
- name: Check upstream release and update build.gradle
id: update-version
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
set -euo pipefail
latest_tag="$(gh api repos/PowerGridModel/power-grid-model/releases/latest --jq '.tag_name')"
latest_version="${latest_tag#v}"
current_version="$(sed -n 's/^def pgmVersion = "\(.*\)"$/\1/p' build.gradle)"
if [[ -z "${current_version}" ]]; then
echo "Could not find pgmVersion in build.gradle" >&2
exit 1
fi
if [[ "${current_version}" == "${latest_version}" ]]; then
echo "updated=false" >> "$GITHUB_OUTPUT"
exit 0
fi
sed -i "s/^def pgmVersion = \".*\"$/def pgmVersion = \"${latest_version}\"/" build.gradle
echo "updated=true" >> "$GITHUB_OUTPUT"
echo "current_version=${current_version}" >> "$GITHUB_OUTPUT"
echo "latest_version=${latest_version}" >> "$GITHUB_OUTPUT"
echo "branch_name=automation/update-pgm-wheel-version-${latest_version}" >> "$GITHUB_OUTPUT"
- name: Create pull request
if: steps.update-version.outputs.updated == 'true'
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1
with:
token: ${{ github.token }}
commit-message: "build: update PGM wheel version to ${{ steps.update-version.outputs.latest_version }}"
branch: ${{ steps.update-version.outputs.branch_name }}
delete-branch: true
title: "build: update PGM wheel version to ${{ steps.update-version.outputs.latest_version }}"
body: |
Updates `pgmVersion` in `build.gradle` from `${{ steps.update-version.outputs.current_version }}` to `${{ steps.update-version.outputs.latest_version }}`.
Source: latest GitHub release from `PowerGridModel/power-grid-model`.
labels: |
dependencies