Skip to content

Commit

Permalink
fix: add a dedicated version bump workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
lpm0073 committed Nov 13, 2023
1 parent 7b71ae9 commit 8c59680
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/versionBump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#---------------------------------------------------------
# - Create a semantical release
# - Set latest tag
#---------------------------------------------------------
name: Bump version

on:
workflow_dispatch:
push:
branches:
- next
- next-major

jobs:
build:
runs-on: ubuntu-latest

steps:
# required antecedent
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '20.9.0'

- name: Install npm dev dependencies
run: npm install --only=dev

- name: Get current version
id: current_version
run: |
echo "::set-output name=version::$(python -c 'from __version__ import __version__; print(__version__)')"
env:
GITHUB_TOKEN: ${{ secrets.PAT }}

- name: Get next version
id: next_version
run: |
echo "::set-output name=version::$(npx semantic-release --dry-run | awk '/The next release version is/{print $NF}')"
env:
GITHUB_TOKEN: ${{ secrets.PAT }}

- name: Debug current version
id: debug_current_version
run: echo "Current version is '${{ steps.current_version.outputs.version }}'"

- name: Debug next version
id: debug_next_version
run: echo "Next version is '$(npx semantic-release --dry-run | awk '/The next release version is/{print $NF}')'"
env:
GITHUB_TOKEN: ${{ secrets.PAT }}

- name: Debug next version output
id: debug_next_version_output
run: echo "Next version is '${{ steps.next_version.outputs.version }}'"
env:
GITHUB_TOKEN: ${{ secrets.PAT }}

- name: Update __version__
if: steps.current_version.outputs.version != steps.next_version.outputs.version
id: update_version
run: |
echo "__version__ = '${{ steps.next_version.outputs.version }}'" > __version__.py
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add __version__.py
git commit -m "chore: [gh] Update __version__.py to ${{ steps.next_version.outputs.version }} [skip ci]"
git push https://${{ secrets.PAT }}@github.com/${{ github.repository }}.git HEAD:main
env:
GITHUB_TOKEN: ${{ secrets.PAT }}

0 comments on commit 8c59680

Please sign in to comment.