Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Squashed commit of the following: #221

Closed
wants to merge 1 commit into from
Closed
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
41 changes: 32 additions & 9 deletions .github/workflows/bump-version-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ on:
required: false
default: true
type: boolean
changelog-config:
description: "Changelog config path."
required: false
default: ""
type: string
working-directory:
description: "Working directory containing `.bumpversion.cfg`. (Default is .)"
required: false
Expand Down Expand Up @@ -57,15 +52,28 @@ jobs:
uses: bakdata/ci-templates/actions/[email protected]
with:
ref: ${{ github.event.repository.default_branch }}
persist-credentials: false # required for pushing to protected branch later
persist-credentials: true # required for pushing to protected branch later

- name: Setup Git
run: |
git config --global user.name "${{ secrets.github-username }}"
git config --global user.email "${{ secrets.github-email }}"

- name: Bump version
- name: Remove snapshot suffix
id: bump-version
uses: bakdata/ci-templates/actions/bump-version@v1.21.2
uses: bakdata/ci-templates/actions/bump-version@feat/new-bumpversion
with:
release-type: ${{ inputs.release-type }}
release-type: "release"
working-directory: ${{ inputs.working-directory }}

- name: Commit .bumpversion.cfg file without snapshot
run: |
git add .bumpversion.cfg
git commit -m "Bump version ${{ steps.bump-version.outputs.old-version }} → ${{ steps.bump-version.outputs.release-version }}"
git fetch origin
git rebase --strategy-option=theirs origin/main
git push --verbose

- name: Create changelog
id: build-changelog
uses: bakdata/ci-templates/actions/[email protected]
Expand Down Expand Up @@ -93,3 +101,18 @@ jobs:
github-token: ${{ secrets.github-token }}
release-title: "${{ steps.bump-version.outputs.release-version }}"
release-body: "${{ steps.build-changelog.outputs.single-changelog }}"

- name: Bump to next snapshot version
id: bump-version-snapshot
uses: bakdata/ci-templates/actions/bump-version@feat/new-bumpversion
with:
release-type: ${{ inputs.release-type }}
working-directory: ${{ inputs.working-directory }}

- name: Commit .bumpversion.cfg file new version and snapshot
run: |
git add .bumpversion.cfg
git commit -m "Bump version ${{ steps.bump-version.outputs.release-version }} → ${{ steps.bump-version-snapshot.outputs.release-version }}"
git fetch origin
git rebase --strategy-option=theirs origin/main
git push --verbose
43 changes: 33 additions & 10 deletions actions/bump-version/action.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
name: "Bump version"
description: "Bump version with python bump2version using .bumpversion.cfg"
description: "Bump version with python bump-my-version using .bumpversion.cfg"
# config example .bumpversion.cfg:
# [bumpversion]
# current_version = 1.0.0
# search = version: {current_version}
# replace = version: {new_version}
# parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(-(?P<release>snapshot))?
# serialize =
# {major}.{minor}.{patch}-{release}
# {major}.{minor}.{patch}

# [bumpversion:part:release]
# first_value = snapshot
# optional_value = release
# values =
# snapshot
# release

inputs:
release-type:
description: "The type of the release (major, minor or patch)."
description: "The type of the release (release, major, minor or patch). Release is a special case, where the snapshot suffix is removed."
required: true
working-directory:
description: "The directory containing the `.bumpversion.cfg` file."
Expand All @@ -25,20 +41,27 @@ outputs:
runs:
using: "composite"
steps:
- name: Set up bump2version
- name: Set up bump-my-version
run: |
pipx install bump2version
pipx install bump-my-version
shell: bash

- name: Bump version
id: bump-version
run: |
parameters=(--no-commit --no-tag ${{ inputs.release-type }})
echo "old-version=$(python -c "from configparser import ConfigParser; cfg = ConfigParser(); cfg.read('.bumpversion.cfg'); print(cfg['bumpversion']['current_version'])")" >> "$GITHUB_OUTPUT"
if [ -n "${{ inputs.new-version }}" ]; then
parameters+=(--new-version ${{ inputs.new-version }})
echo "old-version=$(bump-my-version show current_version | tail -1)" >> "$GITHUB_OUTPUT"

if [[ "${{ inputs.new-version }}" != "" ]]; then
bump-my-version --new-version ${{ inputs.new-version }}
else
bump-my-version bump ${{ inputs.release-type }}
fi
bump2version "${parameters[@]}"
echo "new-version=$(python -c "from configparser import ConfigParser; cfg = ConfigParser(); cfg.read('.bumpversion.cfg'); print(cfg['bumpversion']['current_version'])")" >> "$GITHUB_OUTPUT"
echo "new-version=$(bump-my-version show current_version | tail -1)" >> "$GITHUB_OUTPUT"
# release: a.b.c-snapshot -> a.b.c
# release a.b.c -> crash
# major: a.b.c(-snapshot)? -> a+1.0.0-snapshot
# minor: a.b.c(-snapshot)? -> a.b+1.0-snapshot
# patch: a.b.c(-snapshot)? -> a.b.c+1-snapshot
# TLDR: release removes the snapshot suffix
shell: bash
working-directory: ${{ inputs.working-directory }}
12 changes: 11 additions & 1 deletion actions/changelog-generate/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ inputs:
description: Path to the changelog file in the GitHub repository
required: false
default: "CHANGELOG.md"
checkout:
description: "Whether to checkout the repository or not."
required: false
default: "false"
clean:
description: "Clean the repository before running the action."
required: false
default: false

outputs:
merged-changelog:
Expand All @@ -26,9 +34,11 @@ runs:
using: "composite"
steps:
- name: Check out repository
uses: bakdata/ci-templates/actions/[email protected]
if: ${{ inputs.checkout }}
uses: bakdata/ci-templates/actions/checkout@tiedemann/changelog-action-dont-clean
with:
fetch-depth: 0
clean: ${{ inputs.clean }}
- name: Get config path
id: get-config-path
run: |
Expand Down
5 changes: 5 additions & 0 deletions actions/checkout/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ inputs:
description: "Whether to checkout submodules: `true` to checkout submodules or `recursive` to recursively checkout submodules."
required: false
default: "false"
clean:
description: "Clean the repository before running the action."
required: false
default: "true"

outputs:
lfs-cache-hit:
Expand All @@ -46,6 +50,7 @@ runs:
persist-credentials: ${{ inputs.persist-credentials }}
submodules: ${{ inputs.submodules }}
fetch-depth: ${{ inputs.fetch-depth }}
clean: ${{ inputs.clean }}

- name: Create LFS file list
if: ${{ inputs.lfs == 'true'}}
Expand Down
2 changes: 1 addition & 1 deletion actions/gcp-gsm-load-secrets/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ runs:
workload_identity_provider: ${{ inputs.workload-identity-provider }}
service_account: ${{ inputs.gke-service-account }}
- id: "parse_secrets"
uses: "bakdata/ci-templates/actions/parse-secrets[email protected]"
uses: "bakdata/ci-templates/actions/gcp-gsm-parse-secrets@tiedemann/changelog-action-dont-clean"
with:
project_name: ${{ inputs.gke-project-name }}
secrets_list: ${{ inputs.secrets-to-inject }}
Expand Down
10 changes: 5 additions & 5 deletions docs/actions/bump-version/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ steps:

<!-- AUTO-DOC-INPUT:START - Do not remove or modify this section -->

| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
| ----------------- | ------ | -------- | ------- | ----------------------------------------------------- |
| new-version | string | false | | |
| release-type | string | true | | The type of the release (major, minor or patch). |
| working-directory | string | false | `"."` | The directory containing the `.bumpversion.cfg` file. |
| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
| ----------------- | ------ | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------- |
| new-version | string | false | | |
| release-type | string | true | | The type of the release (release, major, minor or patch). Release is a special case, where the snapshot suffix is removed. |
| working-directory | string | false | `"."` | The directory containing the `.bumpversion.cfg` file. |

<!-- AUTO-DOC-INPUT:END -->

Expand Down
2 changes: 2 additions & 0 deletions docs/actions/changelog-generate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ steps:
| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
| -------------- | ------ | -------- | ---------------- | --------------------------------------------------- |
| changelog-file | string | false | `"CHANGELOG.md"` | Path to the changelog file in the GitHub repository |
| checkout | string | false | `"false"` | Whether to checkout the repository or not. |
| clean | string | false | `"false"` | Clean the repository before running the action. |
| github-token | string | true | | The GitHub token for committing the changes. |
| tag | string | true | | Version after bump |

Expand Down
1 change: 1 addition & 0 deletions docs/actions/checkout/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ steps:
| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
| ------------------- | ------ | -------- | ---------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| cache | string | false | `"true"` | Describes if the repository is using any LFS files |
| clean | string | false | `"true"` | Clean the repository before running the action. |
| fetch-depth | string | false | `"1"` | Number of commits to fetch. 0 indicates all history for all branches and tags |
| lfs | string | false | `"false"` | Describes if the repository is using any LFS files |
| persist-credentials | string | false | `"true"` | Whether to configure the token or SSH key with the local git config |
Expand Down
1 change: 0 additions & 1 deletion docs/workflows/bump-version-release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ jobs:
| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
| ----------------- | ------- | -------- | ------- | --------------------------------------------------------------- |
| changelog | boolean | false | `true` | Create changelog for release. |
| changelog-config | string | false | | Changelog config path. |
| release-type | string | true | | Scope of the release (major, minor or patch). |
| working-directory | string | false | `"."` | Working directory containing `.bumpversion.cfg`. (Default is .) |

Expand Down