1
0
reusable-workflows/.gitea/workflows/setPackageVersion.yaml
2024-10-24 15:07:04 +02:00

56 lines
1.6 KiB
YAML

name: Set Package Version
on:
workflow_call:
inputs:
version:
required: true
type: string
branch:
required: true
type: string
packagePath:
required: false
type: string
jobs:
SetVersion:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set
run: |
git pull --ff-only origin ${{ inputs.branch }}
echo "Setting Version to ${{ inputs.version }}"
git_path=$(pwd)
if [ -n "${{ inputs.packagePath }}" ]; then
echo "Change Directory to ${{ inputs.packagePath }}"
cd ${{ inputs.packagePath }}
fi
npm version --allow-same-version --no-git-tag-version ${{ inputs.version }}
echo "Change Directory back to $git_path"
cd $git_path
- name: Commit version change
run: |
if git diff --quiet && git diff --cached --quiet; then
echo "No changes in the repository."
exit 0
fi
package_name=package.json
if [ -n "${{ inputs.packagePath }}" ]; then
package_name="${{ inputs.packagePath }}package.json"
fi
git config user.name "${{ vars.GIT_DEPLOY_NAME }}"
git config user.email "${{ vars.GIT_DEPLOY_MAIL }}"
git add $package_name
git commit -m "Update package.json version to $TAG_VERSION"
- name: Push changes back to repository
run: |
git push origin ${{ inputs.branch }}