Skip to content

Commit

Permalink
feat(worflows): implement workflows to increment the current version …
Browse files Browse the repository at this point in the history
…in code
  • Loading branch information
MasterLaplace committed Oct 20, 2023
1 parent 777ea5e commit 7b23dda
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 2 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/increment_major.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Increment Major Version

on:
pull_request:
branches:
- 'main'
- 'master'
- 'release'
- 'release/*'

jobs:
increment_major_version:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Increment Major Version
run: |
# Get the latest tag from the repository
latest_tag=$(git describe --tags --abbrev=0)
# Extract the major, minor, and patch versions from the tag
regex="([0-9]+)\.([0-9]+)\.([0-9]+)"
if [[ $latest_tag =~ $regex ]]; then
major_version="${BASH_REMATCH[1]}"
old_major_version="${BASH_REMATCH[1]}"
minor_version="${BASH_REMATCH[2]}"
old_minor_version="${BASH_REMATCH[2]}"
patch_version="${BASH_REMATCH[3]}"
old_patch_version="${BASH_REMATCH[3]}"
else
echo "Failed to parse the latest tag version."
exit 1
fi
# Increment the major version
((major_version++))
# Set the minor and patch versions to 0
minor_version=0
patch_version=0
# Construct the new version
new_version="v${major_version}.${minor_version}.${patch_version}"
# Replace the version in all relevant files except those in the 'Launcher' and 'Libs' folders
find . -type f -not -path "./Launcher/*" -not -path "./Libs/*" -exec sed -i "s/$latest_tag/$new_version/g" {} \;
find ./Engine/Config/Version/version.h -type f -exec sed -i "s/#define ENGINE_VERSION_MAJOR $old_major_version/#define ENGINE_VERSION_MAJOR $major_version/g" {} \;
find ./Engine/Config/Version/version.h -type f -exec sed -i "s/#define ENGINE_VERSION_MINOR $old_minor_version/#define ENGINE_VERSION_MINOR $minor_version/g" {} \;
find ./Engine/Config/Version/version.h -type f -exec sed -i "s/#define ENGINE_VERSION_PATCH $old_patch_version/#define ENGINE_VERSION_PATCH $patch_version/g" {} \;
# Commit the changes
git config user.name "Laplace-Engine-3D-Bot"
git config user.email "guillaume.papineau@epitech.eu"
git add .
git commit -m "update(root): Increment major version to $new_version"
git push
# Create a new tag
git tag -a $new_version -m "Engine-3D $new_version"
git push --tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60 changes: 60 additions & 0 deletions .github/workflows/increment_minor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Increment Minor Version

on:
pull_request:
branches:
- 'dev'

jobs:
increment_minor_version:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Increment Minor Version
run: |
# Get the latest tag from the repository
latest_tag=$(git describe --tags --abbrev=0)
# Extract the major, minor, and patch versions from the tag
regex="([0-9]+)\.([0-9]+)\.([0-9]+)"
if [[ $latest_tag =~ $regex ]]; then
major_version="${BASH_REMATCH[1]}"
minor_version="${BASH_REMATCH[2]}"
old_minor_version="${BASH_REMATCH[2]}"
patch_version="${BASH_REMATCH[3]}"
old_patch_version="${BASH_REMATCH[3]}"
else
echo "Failed to parse the latest tag version."
exit 1
fi
# Increment the minor version
((minor_version++))
# Set the patch version to 0
patch_version=0
# Construct the new version
new_version="v${major_version}.${minor_version}.${patch_version}"
# Replace the version in all relevant files except those in the 'Launcher' and 'Libs' folders
find . -type f -not -path "./Launcher/*" -not -path "./Libs/*" -exec sed -i "s/$latest_tag/$new_version/g" {} \;
find ./Engine/Config/Version/version.h -type f -exec sed -i "s/#define ENGINE_VERSION_MINOR $old_minor_version/#define ENGINE_VERSION_MINOR $minor_version/g" {} \;
find ./Engine/Config/Version/version.h -type f -exec sed -i "s/#define ENGINE_VERSION_PATCH $old_patch_version/#define ENGINE_VERSION_PATCH $patch_version/g" {} \;
# Commit the changes
git config user.name "Laplace-Engine-3D-Bot"
git config user.email "guillaume.papineau@epitech.eu"
git add .
git commit -m "update(root): Increment minor version to $new_version"
git push
# Create a new tag
git tag -a $new_version -m "Engine-3D $new_version"
git push --tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60 changes: 60 additions & 0 deletions .github/workflows/increment_patch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Increment Patch Version

on:
pull_request:
branches:
- '*'
- '!dev'
- '!main'
- '!master'
- '!release'
- '!release/*'

jobs:
increment_version:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Increment Patch Version
run: |
# Get the latest tag from the repository
latest_tag=$(git describe --tags --abbrev=0)
# Extract the major, minor, and patch versions from the tag
regex="([0-9]+)\.([0-9]+)\.([0-9]+)"
if [[ $latest_tag =~ $regex ]]; then
major_version="${BASH_REMATCH[1]}"
minor_version="${BASH_REMATCH[2]}"
patch_version="${BASH_REMATCH[3]}"
old_patch_version="${BASH_REMATCH[3]}"
else
echo "Failed to parse the latest tag version."
exit 1
fi
# Increment the patch version
((patch_version++))
# Construct the new version
new_version="v${major_version}.${minor_version}.${patch_version}"
# Replace the version in all relevant files except those in the 'Launcher' and 'Libs' folders
find . -type f -not -path "./Launcher/*" -not -path "./Libs/*" -exec sed -i "s/$latest_tag/$new_version/g" {} \;
find ./Engine/Config/Version/version.h -type f -exec sed -i "s/#define ENGINE_VERSION_PATCH $old_patch_version/#define ENGINE_VERSION_PATCH $patch_version/g" {} \;
# Commit the changes
git config user.name "Laplace-Engine-3D-Bot"
git config user.email "guillaume.papineau@epitech.eu"
git add .
git commit -m "update(root): Increment patch version to $new_version"
git push
# Create a new tag
git tag -a $new_version -m "Engine-3D $new_version"
git push --tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion Engine/Config/Version/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifdef FLAG_VERSION_PATCH
#define ENGINE_VERSION_PATCH FLAG_VERSION_PATCH
#else
#define ENGINE_VERSION_PATCH 0
#define ENGINE_VERSION_PATCH 6
#endif

////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Engine-3D v0.1.0
Engine-3D v0.1.6

0 comments on commit 7b23dda

Please sign in to comment.