Bump Version #121
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Bump Version | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 12 * * *" # Runs daily at 12:00 | |
jobs: | |
check-version: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Git | |
run: | | |
git config --global user.name "github-actions" | |
git config --global user.email "actions@github.com" | |
# Checkout the MaCh3 repository | |
- name: Checkout MaCh3 repository | |
uses: actions/checkout@v4 | |
with: | |
repository: mach3-software/MaCh3 | |
path: MaCh3 | |
# Extract the MaCh3 version from CMakeLists.txt | |
- name: Get MaCh3 version | |
run: | | |
MaCh3_version=$(grep -Po '(?<=project\(MaCh3 VERSION )\d+\.\d+\.\d+' MaCh3/CMakeLists.txt) | |
echo "Extracted MaCh3 version: ${MaCh3_version}" | |
echo "MaCh3_VERSION=${MaCh3_version}" >> $GITHUB_ENV | |
# Checkout the MaCh3Tutorial repository | |
- name: Checkout MaCh3Tutorial repository | |
run: | | |
git clone https://${{ secrets.MACH3_VALIDATIONS_PAT }}@github.com/mach3-software/MaCh3Tutorial.git MaCh3Tutorial | |
# Extract the MaCh3Tutorial version from CMakeLists.txt | |
- name: Get MaCh3Tutorial version | |
run: | | |
MaCh3Tutorial_version=$(grep -Po '(?<=set\(MaCh3Tutorial_VERSION )\d+\.\d+\.\d+' MaCh3Tutorial/CMakeLists.txt -i) | |
echo "Extracted MaCh3Tutorial version: ${MaCh3Tutorial_version}" | |
echo "MaCh3Tutorial_VERSION=${MaCh3Tutorial_version}" >> $GITHUB_ENV | |
# Compare the versions and create a new branch if they differ | |
- name: Compare versions and create branch if different | |
run: | | |
if [ "$MaCh3_VERSION" != "$MaCh3Tutorial_VERSION" ]; then | |
echo "Versions are different. Creating a new branch in MaCh3Tutorial." | |
cd MaCh3Tutorial | |
git checkout -b update_version_${MaCh3_VERSION} | |
# Update the MaCh3Tutorial_VERSION in CMakeLists.txt | |
sed -i "s/SET(MaCh3Tutorial_VERSION .*)/SET(MaCh3Tutorial_VERSION ${MaCh3_VERSION})/" CMakeLists.txt | |
git status | |
git diff | |
# Commit the changes | |
git add CMakeLists.txt | |
git commit -m "Bump MaCh3Tutorial_VERSION to ${MaCh3_VERSION}" | |
git push origin update_version_${MaCh3_VERSION} | |
# Create Pull Request | |
# gh pr create --title "Bump MaCh3Tutorial_VERSION to ${MaCh3_VERSION}" --body "This PR updates the MaCh3Tutorial_VERSION to ${MaCh3_VERSION}." --base main --head update_version_${{ env.MaCh3_VERSION }} --fill --reviewer KSkwarczynski | |
else | |
echo "Versions are the same. No new branch created." | |
fi | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |