Skip to content

Commit

Permalink
Merge pull request #425 from hkad98/PSDK-165
Browse files Browse the repository at this point in the history
RELATED: PSDK-165 automate release process

Reviewed-by: Tomas Kouba
             https://github.com/tomaso
  • Loading branch information
gdgate authored Nov 15, 2023
2 parents 3e19a22 + 97a8445 commit 7fb0aa6
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- gooddata-dbt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand Down
96 changes: 96 additions & 0 deletions .github/workflows/bump-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# (C) 2023 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: 'minor'
options:
- major
- minor
- patch

permissions:
contents: write

jobs:
bump-version:
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.bump.outputs.new_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version-file: '.python-version'
cache: 'pip'
- name: Bump version
id: bump
run: |
NEW_VERSION=$(python ./scripts/bump_version.py ${{ github.event.inputs.bump_type }})
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Bump version in documentation
run: |
python scripts/bump_doc_dependencies.py ${{ steps.bump.outputs.new_version }}
- name: Bump version in codebase
run: |
make release-ci VERSION=${{ steps.bump.outputs.new_version }}
- name: Commit version bump and push to custom branch
id: commit
uses: EndBug/add-and-commit@v9
with:
message: "Bump to ${{ steps.bump.outputs.new_version }}"
committer_name: GitHub Actions
committer_email: [email protected]
new_branch: "release/${{ steps.bump.outputs.new_version }}"
- name: Create PR with the version bump
id: pr
if: ${{ steps.commit.outputs.pushed == 'true' }}
run: |
PR_URL=$(gh pr create \
--title "[bot] bump to ${{ steps.bump.outputs.new_version }}" \
--body ":rocket: Automated PR to bump to ${{ steps.bump.outputs.new_version }}." \
--base master --head "release/${{ steps.bump.outputs.new_version }}")
PR_NUMBER=$(basename $PR_URL)
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Approve the PR as yenkins-admin
if: ${{ steps.commit.outputs.pushed == 'true' }}
run: |
gh pr review ${{ steps.bump.outputs.pr_number }} --approve
gh issue update ${{ steps.bump.outputs.pr_number }} --add-label "merge"
env:
GH_TOKEN: ${{ secrets.TOKEN_GITHUB_YENKINS_ADMIN }}
# create-release-branch:
# needs:
# - bump-version
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Create documentation rel/${{ github.event.inputs.bump_type }} branch
# run: |
# git config user.name GitHub Actions
# git config user.email [email protected]
# git checkout -b rel/${{ needs.bump-version.outputs.new_version }}
# git push origin rel/${{ needs.bump-version.outputs.new_version }}
# trigger-release:
# needs:
# - bump-version
# - create-release-branch
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Push new tag – v${{ needs.bump-version.outputs.new_version }}
# run: |
# git config user.name GitHub Actions
# git config user.email [email protected]
# git tag v${{ needs.bump-version.outputs.new_version }}
# git push origin v${{ needs.bump-version.outputs.new_version }}
2 changes: 1 addition & 1 deletion .github/workflows/dev-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- gooddata-sdk
- gooddata-dbt
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up python 3.11
uses: actions/setup-python@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/netlify-deploy-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/netlify-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
- name: Hugo Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-master-as.alpha.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- gooddata-sdk
- gooddata-dbt
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
python_version: [py311, py310, py39, py38]
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Execute tests
run: |
make test-ci
Expand All @@ -55,7 +55,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
Expand All @@ -73,7 +73,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ release:
if [ -z "$(VERSION)" ]; then echo "Usage: 'make release VERSION=X.Y.Z'"; false; else \
tbump $(VERSION) --no-tag --no-push ; fi

.PHONY: release-ci
release-ci:
if [ -z "$(VERSION)" ]; then echo "Usage: 'make release-ci VERSION=X.Y.Z'"; false; else \
tbump $(VERSION) --only-patch --non-interactive ; fi

.PHONY: check-copyright
check-copyright:
./scripts/check_copyright.py FOLDER
Expand Down
6 changes: 3 additions & 3 deletions scripts/bump_doc_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

import tomlkit

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

_TOML_FILE = _CURRENT_DIR / "config/production/params.toml"
_REDIR_FILE = _CURRENT_DIR / "layouts/index.redir"
_TOML_FILE = _ROOT_DIR / "docs/config/production/params.toml"
_REDIR_FILE = _ROOT_DIR / "docs/layouts/index.redir"


def bump_toml(file_path: Path, version: list[int]):
Expand Down
33 changes: 33 additions & 0 deletions scripts/bump_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# (C) 2023 GoodData Corporation
import sys
import tomllib
from pathlib import Path

_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))))

0 comments on commit 7fb0aa6

Please sign in to comment.