Bump Version #1487
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Bump Version | |
on: | |
workflow_dispatch: | |
inputs: | |
force: | |
description: 'force release' | |
required: false | |
default: '0' | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
bump-version: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4.1.7 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
- name: Calculate changes from the latest tag to HEAD | |
id: changes | |
run: | | |
LATEST_TAG=$(git describe --abbrev=0 --tags) | |
echo "latest-tag = $LATEST_TAG" | |
COUNT=$(git log $LATEST_TAG..HEAD --pretty=format:"%s" --no-merges \ | |
--grep='^build:' \ | |
--grep='^ci:' \ | |
--grep='^feat:' \ | |
--grep='^fix:' \ | |
--grep='^docs:' \ | |
--grep='^style:' \ | |
--grep='^refactor:' \ | |
--grep='^perf:' \ | |
--grep='^test:' \ | |
--grep='^revert:' \ | |
--grep='^chore:' | awk 'END{print NR}') | |
echo "steps.changes.outputs.count = $COUNT" | |
FORCE=${{ inputs.force }} | |
if [[ "$FORCE" = "1" ]]; then | |
echo "::set-output name=count::1" | |
else | |
echo "::set-output name=count::$COUNT" | |
fi | |
- name: Bump version and push tag | |
id: tag_version | |
uses: mathieudutour/github-tag-action@v6.2 | |
with: | |
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
default_bump: patch | |
if: steps.changes.outputs.count > 0 | |
- name: Create a GitHub release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
with: | |
tag_name: ${{ steps.tag_version.outputs.new_tag }} | |
release_name: Release ${{ steps.tag_version.outputs.new_tag }} | |
body: ${{ steps.tag_version.outputs.changelog }} | |
if: steps.changes.outputs.count > 0 |