Files
bump-erp-app-version/README.md
T
NikoKS 59e040994b
Test action / integration (push) Failing after 12s
Update major version tag / update-major-tag (push) Successful in 5s
fix: bootstrap apps without version config
2026-08-26 23:34:46 +07:00

4.8 KiB

Bump ERP App Version

A forge-neutral composite action for preparing a versioned Frappe/ERPNext app before merging its release branch. It uses bump-my-version and ordinary Git commands, without gh or GitHub API calls.

The action compares [tool.bumpversion].current_version on the checked-out target branch with the configured base branch:

  • Equal: bump, commit, and optionally push the new version.
  • Target newer than base: do nothing, making PR synchronization events idempotent.
  • Target older than base: fail and require branch synchronization.

Requirements

  • A Linux runner with Bash, Git, and Python 3.11 or newer.
  • A clean checkout of the branch that should receive the version commit.
  • Persisted Git credentials with permission to push that branch.
  • Stable MAJOR.MINOR.PATCH versions.
  • A bump-my-version configuration that includes every version file.

Example pyproject.toml for a Frappe app:

[tool.bumpversion]
current_version = "0.0.1"
commit = false
tag = false

[[tool.bumpversion.files]]
filename = "erp_operations/__init__.py"
search = '__version__ = "{current_version}"'
replace = '__version__ = "{new_version}"'

Gitea Actions usage

name: Prepare application version

on:
  pull_request:
    branches: [main]
    types: [opened, reopened, synchronize]

permissions:
  contents: write
  pull-requests: read

jobs:
  version:
    if: ${{ gitea.head_ref == 'develop' }}
    runs-on: ubuntu-latest
    steps:
      - name: Check out develop
        uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
        with:
          ref: develop
          fetch-depth: 0
          token: ${{ secrets.GITEA_TOKEN }}

      - name: Prepare version
        id: version
        # The absolute URL is required when Gitea's DEFAULT_ACTIONS_URL is "github".
        uses: https://gitea.cptckp.com/Nurinda/bump-erp-app-version@v1
        with:
          config-file: pyproject.toml
          version-file: erp_operations/__init__.py
          base-branch: main
          target-branch: develop
          bump: patch
          git-user-name: ERP Operations Release Bot
          git-user-email: it@nurinda.co.id

      - name: Report version
        run: echo "${{ steps.version.outputs.previous-version }} -> ${{ steps.version.outputs.current-version }}"

Gitea may suppress workflows caused by pushes authenticated with its built-in GITEA_TOKEN. If CI checks must rerun on the generated commit, pass a narrowly scoped bot repository token to actions/checkout instead.

Inputs

Input Default Description
config-file pyproject.toml bump-my-version TOML configuration
version-file empty App __init__.py used to bootstrap a base branch that predates the configuration
base-branch main Branch providing the baseline version
target-branch develop Checked-out branch receiving the commit
bump patch major, minor, or patch
remote origin Git remote used for fetch and push
commit-message chore(release): prepare v{version} Version commit message
git-user-name ERP App Release Bot Git commit identity
git-user-email actions@localhost Git commit identity
bump-my-version-version 1.5.1 Exact package version installed in an isolated environment
push true Whether to push the created commit

Outputs

Output Description
bumped true when a commit was created
previous-version Version before the action ran
current-version Version after the action ran
commit Created commit SHA, empty for a no-op

Safety behavior

The action does not force-push, create tags, publish releases, or call forge APIs. Concurrent release jobs are resolved safely by the remote rejecting a non-fast-forward push. Configure workflow-level concurrency if release PRs can overlap.

For the first versioned release, the base branch might not contain [tool.bumpversion] yet. Set version-file to the app's __init__.py; the action will read its base-branch __version__ as the bootstrap baseline. Once the configuration reaches the base branch, it becomes the authoritative baseline.

Releasing the action

Create and push an immutable semantic-version tag:

git tag -a v1.1.0 -m "Release v1.1.0"
git push origin v1.1.0

The Update major version tag Gitea workflow validates the release tag and automatically moves the corresponding floating major tag (for example, v1) to the same commit. Consumers can continue using Nurinda/bump-erp-app-version@v1 to receive compatible v1 releases.

Development

Run the integration test:

./tests/integration.sh

The test creates a temporary Git remote and verifies bumping, committing, pushing, and idempotent reruns.