Skip to content

Enable precompiled header for all platforms. #4

Enable precompiled header for all platforms.

Enable precompiled header for all platforms. #4

name: Update version info
on:
workflow_dispatch: # manual trigger
pull_request: # PR merged into master
types:
- closed
branches:
- master
paths:
- "**/*.h"
- "**/*.hpp"
- "**/*.c"
- "**/*.cpp"
jobs:
Update_version_info:
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: master
- name: Check conditions
run: |
echo "SKIP_JOB=false" >> $GITHUB_ENV
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
echo "Current branch: $BRANCH_NAME"
if [[ "$BRANCH_NAME" != "master" ]]; then
echo "::error::Selected branch is not master!"
echo "SKIP_JOB=true" >> $GITHUB_ENV
else
LAST_COMMIT_MESSAGE=$(git log -1 --format=%B HEAD)
echo "Last commit message: $LAST_COMMIT_MESSAGE"
if [[ "$LAST_COMMIT_MESSAGE" == "Update version info: v."* ]]; then
echo "::warning::Previous commit already updated the version info!"
echo "SKIP_JOB=true" >> $GITHUB_ENV
fi
fi
- name: Update version info
if: ${{ env.SKIP_JOB == 'false' }}
id: update
run: |
VERSION_FILE="shared/plugin.h"
echo "file=$VERSION_FILE" >> $GITHUB_OUTPUT
VERSION=$(grep "#define PLUGIN_SDK_VERSION " "$VERSION_FILE" | awk '{print $3}')
VERSION=$((VERSION + 1))
echo "New version number: $VERSION"
sed -i "s/#define PLUGIN_SDK_VERSION .*/#define PLUGIN_SDK_VERSION $VERSION/" "$VERSION_FILE"
echo "version=$VERSION" >> $GITHUB_OUTPUT
#DATE=$(git log -1 --format=%cd --date=format-local:'%Y-%m-%d %H:%M:%S' HEAD)
DATE=$(date +"%Y-%m-%d %H:%M:%S")
echo "New date: $DATE"
sed -i "s/#define PLUGIN_SDK_DATE .*/#define PLUGIN_SDK_DATE $DATE/" "$VERSION_FILE"
- name: Commit and push changes
if: ${{ env.SKIP_JOB == 'false' }}
uses: stefanzweifel/git-auto-commit-action@v7
with:
branch: master
commit_message: "Update version info: v.${{ steps.update.outputs.version }}"
file_pattern: '${{ steps.update.outputs.file }}'