Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .github/workflows/bump-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# (C) 2026 GoodData Corporation
name: Bump version & trigger release

on:
workflow_dispatch:
inputs:
bump_type:
description: 'Type of version bump to perform (following semver).'
type: choice
required: true
default: 'patch'
options:
- major
- minor
- patch

permissions:
contents: write
pull-requests: write

jobs:
bump-version:
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.bump.outputs.new_version }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
token: ${{ secrets.TOKEN_GITHUB_YENKINS_ADMIN }}

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: latest

- name: Install dependencies
run: uv sync --only-group release --locked

- name: Bump version
id: bump
run: |
NEW_VERSION=$(uv run python ./scripts/bump_version.py ${{ github.event.inputs.bump_type }})
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT

- name: Bump version in codebase
run: make release-ci VERSION=${{ steps.bump.outputs.new_version }}

- name: Specify release branch
id: branch
run: |
if [ "${{ github.event.inputs.bump_type }}" == "patch" ]; then
RELEASE_BRANCH="patch/${{ steps.bump.outputs.new_version }}"
else
RELEASE_BRANCH="rel/${{ steps.bump.outputs.new_version }}"
fi
echo "release_branch=$RELEASE_BRANCH" >> $GITHUB_OUTPUT

- name: Create and push release ${{ steps.bump.outputs.new_version }}
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git checkout -b ${{ steps.branch.outputs.release_branch }}
git add -A
git commit -m "Release ${{ steps.bump.outputs.new_version }}"
git push origin ${{ steps.branch.outputs.release_branch }} --force-with-lease
git checkout master
git merge ${{ steps.branch.outputs.release_branch }}
git push origin master

- name: Push tag v${{ steps.bump.outputs.new_version }}
run: |
git tag v${{ steps.bump.outputs.new_version }}
git push origin v${{ steps.bump.outputs.new_version }}

create-release:
needs: bump-version
permissions:
contents: write
uses: ./.github/workflows/release-github.yaml
with:
tag: v${{ needs.bump-version.outputs.new_version }}

publish:
needs: [bump-version, create-release]
permissions:
id-token: write
uses: ./.github/workflows/release-pypi.yaml
with:
tag: v${{ needs.bump-version.outputs.new_version }}
35 changes: 35 additions & 0 deletions .github/workflows/release-github.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# (C) 2026 GoodData Corporation
name: Create GitHub Release

on:
workflow_call:
inputs:
tag:
type: string
required: true
workflow_dispatch:
inputs:
tag:
description: 'Tag to release (e.g. v0.1.0)'
type: string
required: true

permissions:
contents: write

jobs:
github_release:
name: Create GitHub release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.tag }}
token: ${{ secrets.GITHUB_TOKEN }}
generate_release_notes: true
draft: false
prerelease: false
make_latest: true
40 changes: 40 additions & 0 deletions .github/workflows/release-pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# (C) 2026 GoodData Corporation
name: Publish to PyPI

on:
workflow_call:
inputs:
tag:
type: string
required: true
workflow_dispatch:
inputs:
tag:
description: 'Tag to publish (e.g. v0.1.0)'
type: string
required: true

permissions:
id-token: write

jobs:
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag }}

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Build
run: uv build --out-dir dist

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
verbose: true
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# (C) 2026 GoodData Corporation
.PHONY: dev
dev:
uv sync
uv sync --all-groups
uv run pre-commit install

@echo "\n\nRun 'source .venv/bin/activate' to activate the virtual environment"
Expand Down Expand Up @@ -29,3 +29,8 @@ test:

.PHONY: check
check: format lint test type

.PHONY: release-ci
release-ci:
if [ -z "$(VERSION)" ]; then echo "Usage: 'make release-ci VERSION=X.Y.Z'"; false; else \
uv run tbump $(VERSION) --only-patch --non-interactive && uv lock ; fi
22 changes: 22 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ dev = [
"pytest==9.0.0",
"pytest-mock==3.15.1",
]
release = [
"tbump==6.11.0",
"tomlkit==0.11.8",
]

[tool.ty.src]
include = ["src", "tests"]
Expand All @@ -53,3 +57,21 @@ gooddata-legacy2cloud = "gooddata_legacy2cloud.arg_parsing.cli_commands:main"
[build-system]
requires = ["uv_build>=0.10.9,<0.11.0"]
build-backend = "uv_build"

[tool.tbump.version]
current = "0.1.0"
regex = '''
(?P<major>\d+)
\.
(?P<minor>\d+)
\.
(?P<patch>\d+)
'''

[tool.tbump.git]
message_template = "Bump to {new_version}"
tag_template = "v{new_version}"

[[tool.tbump.file]]
src = "pyproject.toml"
search = 'version = "{current_version}"'
36 changes: 36 additions & 0 deletions scripts/bump_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# (C) 2026 GoodData Corporation
import sys
from pathlib import Path

import tomllib

_ROOT_DIR = Path(__file__).resolve().parent.parent


def get_version(content: dict) -> list[int]:
current_version = (
content.get("tool", {}).get("tbump", {}).get("version", {}).get("current")
)
if current_version is None:
raise ValueError("No current version found while reading from pyproject.toml")
return list(map(int, current_version.split(".")))


if __name__ == "__main__":
bump_type = sys.argv[1]
with open(_ROOT_DIR / "pyproject.toml", "rb") as f:
data = tomllib.load(f)
version = get_version(data)
match bump_type:
case "patch":
version[2] += 1
case "minor":
version[1] += 1
version[2] = 0
case "major":
version[0] += 1
version[1] = 0
version[2] = 0
case _:
raise ValueError("Invalid bump type")
print(".".join(list(map(str, version))))
79 changes: 79 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading