mirror of
https://github.com/elmerfds/TrafegoDNS.git
synced 2026-01-13 14:49:35 -06:00
Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 1 to 2. - [Release notes](https://github.com/softprops/action-gh-release/releases) - [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md) - [Commits](https://github.com/softprops/action-gh-release/compare/v1...v2) --- updated-dependencies: - dependency-name: softprops/action-gh-release dependency-version: '2' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
110 lines
3.7 KiB
YAML
110 lines
3.7 KiB
YAML
name: Version Bump
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
bump_type:
|
|
description: 'Version bump type (patch, minor, major)'
|
|
required: true
|
|
default: 'minor'
|
|
type: choice
|
|
options:
|
|
- patch
|
|
- minor
|
|
- major
|
|
|
|
jobs:
|
|
version-bump:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
outputs:
|
|
new_version: ${{ steps.version.outputs.NEW_VERSION }}
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '18'
|
|
|
|
- name: Calculate version
|
|
id: version
|
|
run: |
|
|
# Get the current version
|
|
CURRENT_VERSION=$(node -p "require('./package.json').version")
|
|
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
|
|
|
|
# Determine bump type from workflow dispatch input
|
|
BUMP_TYPE="${{ github.event.inputs.bump_type || 'minor' }}"
|
|
|
|
# Calculate new version based on bump type
|
|
MAJOR_VERSION=${VERSION_PARTS[0]}
|
|
MINOR_VERSION=${VERSION_PARTS[1]}
|
|
PATCH_VERSION=${VERSION_PARTS[2]}
|
|
|
|
if [ "$BUMP_TYPE" == "major" ]; then
|
|
MAJOR_VERSION=$((MAJOR_VERSION + 1))
|
|
MINOR_VERSION=0
|
|
PATCH_VERSION=0
|
|
elif [ "$BUMP_TYPE" == "minor" ]; then
|
|
MINOR_VERSION=$((MINOR_VERSION + 1))
|
|
PATCH_VERSION=0
|
|
elif [ "$BUMP_TYPE" == "patch" ]; then
|
|
PATCH_VERSION=$((PATCH_VERSION + 1))
|
|
fi
|
|
|
|
NEW_VERSION="${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}"
|
|
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_OUTPUT
|
|
echo "New version will be: ${NEW_VERSION} (${BUMP_TYPE} bump)"
|
|
|
|
- name: Update package.json and package-lock.json
|
|
run: |
|
|
# Update version in package.json
|
|
npm version ${{ steps.version.outputs.NEW_VERSION }} --no-git-tag-version
|
|
|
|
# Update name in package-lock.json
|
|
PACKAGE_NAME=$(node -p "require('./package.json').name")
|
|
jq --arg name "$PACKAGE_NAME" --arg version "${{ steps.version.outputs.NEW_VERSION }}" '.name = $name | .version = $version' package-lock.json > package-lock.tmp
|
|
mv package-lock.tmp package-lock.json
|
|
|
|
- name: Commit changes
|
|
run: |
|
|
git config --local user.email "action@github.com"
|
|
git config --local user.name "GitHub Action"
|
|
git add package.json package-lock.json
|
|
git commit -m "Bump version to ${{ steps.version.outputs.NEW_VERSION }}" || echo "No changes to commit"
|
|
git push
|
|
|
|
create-tag-and-release:
|
|
needs: version-bump
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: main # Checkout the main branch to get the updated version
|
|
fetch-depth: 0
|
|
|
|
- name: Create Git tag
|
|
run: |
|
|
git config --local user.email "action@github.com"
|
|
git config --local user.name "GitHub Action"
|
|
git tag -a v${{ needs.version-bump.outputs.new_version }} -m "Version ${{ needs.version-bump.outputs.new_version }}"
|
|
git push origin v${{ needs.version-bump.outputs.new_version }}
|
|
|
|
- name: Create GitHub Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: v${{ needs.version-bump.outputs.new_version }}
|
|
name: Release v${{ needs.version-bump.outputs.new_version }}
|
|
draft: false
|
|
prerelease: false
|
|
generate_release_notes: true |