Skip to content

Workflow file for this run

name: Merge dev into main with version bump
on:
pull_request:
branches: ["main"]
workflow_dispatch:
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Git config
run: |
git config --local user.name "boutzi"
git config --local user.email "joe@arkaans.com"
- name: Checkout dev branch
run: |
git checkout dev
git pull origin dev
- name: Increment version (package.json)
id: increment_version
run: |
CURRENT_VERSION=$(jq -r '.version' package.json)
IFS='.' read -r major minor patch <<< "$CURRENT_VERSION"
echo "Version actuelle: $CURRENT_VERSION"
PR_TITLE="${{ github.event.pull_request.title }}"
echo "Pull Request Title: $PR_TITLE"
if [[ "$PR_TITLE" == *"major"* ]]; then
major=$((major + 1))
minor=0
patch=0
elif [[ "$PR_TITLE" == *"feat"* ]]; then
minor=$((minor + 1))
patch=0
elif [[ "$PR_TITLE" == *"fix"* ]]; then
patch=$((patch + 1))
else
echo "Aucun incrément de version spécifié. Aucune modification."
exit 0
fi
NEW_VERSION="$major.$minor.$patch"
echo "Nouvelle version: $NEW_VERSION"
jq --arg new_version "$NEW_VERSION" '.version = $new_version' package.json > tmp.$$.json && mv tmp.$$.json package.json
echo "new_version=$NEW_VERSION" >> $GITHUB_ENV
- name: Commit and push version bump to dev
run: |
git add package.json
git commit -m "Bump version to ${{ env.new_version }}" || echo