From 52d35ca3c6ffa6a0f7c81a77358f0fe515522f6e Mon Sep 17 00:00:00 2001 From: pat-s Date: Sat, 14 Oct 2023 23:25:39 +0200 Subject: [PATCH 1/7] init --- docs.md | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/docs.md b/docs.md index e69de29..dc4a623 100644 --- a/docs.md +++ b/docs.md @@ -0,0 +1,84 @@ +--- +name: Release Helper +icon: https://woodpecker-ci.org/img/logo.svg + +description: Plugin for semi-automated releases. +authors: Woodpecker Authors +tags: [git, release] +containerImage: woodpeckerci/plugin-ready-release-go +containerImageUrl: https://hub.docker.com/r/woodpeckerci/plugin-ready-release-go +url: https://github.com/woodpecker-ci/plugin-ready-release-go +--- + +# Introduction + +This plugin aims to help with git-based releases. +It should be run on every commit of the default branch to execute it's necessary actions. + +A Woodpecker workflow file could look like this: + +```yaml +steps: + release-helper: + image: woodpeckerci/plugin-ready-release-go:0.6.1 + settings: + release_branch: ${CI_REPO_DEFAULT_BRANCH} + forge_type: github + git_email: + github_token: + from_secret: GITHUB_TOKEN + +when: + event: push + branch: ${CI_REPO_DEFAULT_BRANCH} +``` + +## Features + +- Create automated changelog based on PRs which updates itself after each merge to the default branch +- Auto-categorization of PRs based on labels +- Automatically determines the next version +- Supports any kind of programming language, changelog tool and commit style +- Execute custom pre-release hooks + +## Overriding Settings + +To override the default settings, add a `release-config.ts` file to your repository. + +```ts +export default { + commentOnReleasedPullRequests: false, +}; +``` + +The plugin also supports executing custom prepare hooks before the plugin execution which can e.g. help to perform additional actions during a release (e.g. updating a helm chart's `appVersion` field): + +```ts +export default { + beforePrepare: async ({ exec, nextVersion }) => { + await exec(`sed -i "s/^version:.*$/version: ${nextVersion}/g" Chart.yaml`); + } +``` + +## Settings + +| Settings Name | Default | Description | +| ------------------------- | ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | +| `depth` | _none_ | If specified, uses git's `--depth` option to create a shallow clone with a limited number of commits, overwritten by partial | +| `lfs` | `true` | Set this to `false` to disable retrieval of LFS files | +| `recursive` | `false` | Clones submodules recursively | +| `skip_verify` | `false` | Skips the SSL verification | +| `tags` | `false` (except on tag event) | Fetches tags when set to true, default is false if event is not tag else true | +| `submodule_overrides` | _none_ | Override submodule urls | +| `submodule_update_remote` | `false` | Pass the --remote flag to git submodule update | +| `custom_ssl_path` | _none_ | Set path to custom cert | +| `custom_ssl_url` | _none_ | Set url to custom cert | +| `backoff` | `5sec` | Change backoff duration | +| `attempts` | `5` | Change backoff attempts | +| `branch` | $CI_COMMIT_BRANCH | Change branch name to checkout to | +| `partial` | `true` (except if tags are fetched) | Only fetch the one commit and it's blob objects to resolve all files, overwrite depth with 1 | +| `home` | | Change HOME var for commands executed, fail if it does not exist | +| `remote` | $CI_REPO_CLONE_URL | Set the git remote url | +| `sha` | $CI_COMMIT_SHA | git commit hash to retrieve (use `sha: ''` to clone the `ref`) | +| `ref` | $CI_COMMIT_REF | Set the git reference to retrieve (use `ref: refs/head/a_branch` and `sha: ''` to retrieve the head commit from the "a_branch" branch) | +| `path` | $CI_WORKSPACE | Set destination path to clone to | From 369546feb5972823e3909b2547ecf15b43c40830 Mon Sep 17 00:00:00 2001 From: Patrick Schratz Date: Sun, 15 Oct 2023 22:47:08 +0200 Subject: [PATCH 2/7] Update docs.md Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com> --- docs.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs.md b/docs.md index dc4a623..10f9aa0 100644 --- a/docs.md +++ b/docs.md @@ -58,6 +58,7 @@ export default { beforePrepare: async ({ exec, nextVersion }) => { await exec(`sed -i "s/^version:.*$/version: ${nextVersion}/g" Chart.yaml`); } +}; ``` ## Settings From 80ec84e0dcb15c02cc45635d3eaf68a7b133cf16 Mon Sep 17 00:00:00 2001 From: Anbraten Date: Fri, 10 Nov 2023 00:56:11 +0100 Subject: [PATCH 3/7] update docs --- README.md | 24 ++++++++++++++++++++++- docs.md | 58 ++++++++++++++++++++++++------------------------------- 2 files changed, 48 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 2f43c74..7aeb0dc 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,27 @@ This plugin can be executed on every push to your release branch (e.g. main) and will create a new release pull-request with all of your custom adjustments like an updated changelog as preparation for the next release. After you have merged the "release"-pull-request with all your desired changes, a new release / tag will be created for you. +## Usage + +### Woodpecker CI + +Create a new workflow like `.woodpecker/release-helper.yml`: + +```yaml +when: + event: push + branch: ${CI_REPO_DEFAULT_BRANCH} + +steps: + release-helper: + image: woodpeckerci/plugin-ready-release-go:latest + settings: + # release_branch: 'custom-release-branch' # default: main + git_email: my-email@example.org + github_token: + from_secret: GITHUB_TOKEN +``` + ## Workflow 1. Setup ready-release-go on your repository by adding a config file and a workflow file @@ -9,7 +30,8 @@ This plugin can be executed on every push to your release branch (e.g. main) and 1. You can review the pull-request and merge it when you are ready 1. The plugin will create a new release -## Interal workflow +## Internal workflow + - get latest release => tag - get all commits since commit of last tag - get all prs of those commits (if they have a pr associated) diff --git a/docs.md b/docs.md index 10f9aa0..ff3baf9 100644 --- a/docs.md +++ b/docs.md @@ -20,10 +20,9 @@ A Woodpecker workflow file could look like this: ```yaml steps: release-helper: - image: woodpeckerci/plugin-ready-release-go:0.6.1 + image: woodpeckerci/plugin-ready-release-go settings: - release_branch: ${CI_REPO_DEFAULT_BRANCH} - forge_type: github + # release_branch: 'custom-release-branch' # default: CI_REPO_DEFAULT_BRANCH git_email: github_token: from_secret: GITHUB_TOKEN @@ -37,49 +36,42 @@ when: - Create automated changelog based on PRs which updates itself after each merge to the default branch - Auto-categorization of PRs based on labels -- Automatically determines the next version +- Automatically determines the next semver version using the PR labels - Supports any kind of programming language, changelog tool and commit style -- Execute custom pre-release hooks +- Allows to execute custom hooks like pre, post-release -## Overriding Settings +## Settings + +There are two ways to configure the plugin: + +1. Most basic options can be configured via plugin settings: + +| Settings | Default | Description | +| ---------------------------- | ---------------------- | ------------------------------------------------- | +| `GITHUB_TOKEN` | _none_ | The GitHub token to use for the GitHub API | +| `GIT_EMAIL` | _none_ | The email to use for git commits | +| `RELEASE_BRANCH` | CI_REPO_DEFAULT_BRANCH | The branch used to merge the changelog to | +| `PULL_REQUEST_BRANCH_PREFIX` | `next-release/` | The prefix used for release pull-request branches | +| `DEBUG` | `false` | Enable debug logging | + +2. Using a `release-config.ts` file in your repository -To override the default settings, add a `release-config.ts` file to your repository. +Add a `release-config.ts` file to the root of your repository. Have a look at the [UserConfig](https://github.com/woodpecker-ci/plugin-ready-release-go/blob/main/src/utils/types.ts) type for all available options. + +````ts ```ts export default { commentOnReleasedPullRequests: false, }; -``` +```` -The plugin also supports executing custom prepare hooks before the plugin execution which can e.g. help to perform additional actions during a release (e.g. updating a helm chart's `appVersion` field): +The plugin also supports executing custom hooks which can e.g. help to perform additional actions during a release (e.g. updating a helm chart's `appVersion` field): ```ts export default { beforePrepare: async ({ exec, nextVersion }) => { await exec(`sed -i "s/^version:.*$/version: ${nextVersion}/g" Chart.yaml`); - } + }, }; ``` - -## Settings - -| Settings Name | Default | Description | -| ------------------------- | ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -| `depth` | _none_ | If specified, uses git's `--depth` option to create a shallow clone with a limited number of commits, overwritten by partial | -| `lfs` | `true` | Set this to `false` to disable retrieval of LFS files | -| `recursive` | `false` | Clones submodules recursively | -| `skip_verify` | `false` | Skips the SSL verification | -| `tags` | `false` (except on tag event) | Fetches tags when set to true, default is false if event is not tag else true | -| `submodule_overrides` | _none_ | Override submodule urls | -| `submodule_update_remote` | `false` | Pass the --remote flag to git submodule update | -| `custom_ssl_path` | _none_ | Set path to custom cert | -| `custom_ssl_url` | _none_ | Set url to custom cert | -| `backoff` | `5sec` | Change backoff duration | -| `attempts` | `5` | Change backoff attempts | -| `branch` | $CI_COMMIT_BRANCH | Change branch name to checkout to | -| `partial` | `true` (except if tags are fetched) | Only fetch the one commit and it's blob objects to resolve all files, overwrite depth with 1 | -| `home` | | Change HOME var for commands executed, fail if it does not exist | -| `remote` | $CI_REPO_CLONE_URL | Set the git remote url | -| `sha` | $CI_COMMIT_SHA | git commit hash to retrieve (use `sha: ''` to clone the `ref`) | -| `ref` | $CI_COMMIT_REF | Set the git reference to retrieve (use `ref: refs/head/a_branch` and `sha: ''` to retrieve the head commit from the "a_branch" branch) | -| `path` | $CI_WORKSPACE | Set destination path to clone to | From 6e3b802d6e4e32e05d7f742a82843121aa6a38ec Mon Sep 17 00:00:00 2001 From: Anbraten Date: Fri, 10 Nov 2023 01:08:37 +0100 Subject: [PATCH 4/7] add missing options --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 20e27b8..0e0a386 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,12 @@ steps: release-helper: image: woodpeckerci/plugin-ready-release-go:latest settings: - # release_branch: 'custom-release-branch' # default: main git_email: my-email@example.org github_token: from_secret: GITHUB_TOKEN + # release_branch: 'custom-release-branch' # default: main + # pull_request_branch_prefix: 'next-release/' + # debug: true ``` ## Workflow From c4072ba97fadeca16ad75f0b4225f8435ddaa6a8 Mon Sep 17 00:00:00 2001 From: Anbraten Date: Fri, 10 Nov 2023 01:16:50 +0100 Subject: [PATCH 5/7] adjust docs --- docs.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs.md b/docs.md index ff3baf9..63847e6 100644 --- a/docs.md +++ b/docs.md @@ -42,9 +42,9 @@ when: ## Settings -There are two ways to configure the plugin: +There are two parts to configure the plugin: -1. Most basic options can be configured via plugin settings: +### 1. Most basic options can be configured via plugin settings: | Settings | Default | Description | | ---------------------------- | ---------------------- | ------------------------------------------------- | @@ -54,12 +54,10 @@ There are two ways to configure the plugin: | `PULL_REQUEST_BRANCH_PREFIX` | `next-release/` | The prefix used for release pull-request branches | | `DEBUG` | `false` | Enable debug logging | -2. Using a `release-config.ts` file in your repository +### 2. Using a `release-config.ts` file in your repository Add a `release-config.ts` file to the root of your repository. Have a look at the [UserConfig](https://github.com/woodpecker-ci/plugin-ready-release-go/blob/main/src/utils/types.ts) type for all available options. -````ts - ```ts export default { commentOnReleasedPullRequests: false, From a403bddec8e238d616f456ae85bba965fe5ebfc2 Mon Sep 17 00:00:00 2001 From: Anbraten Date: Fri, 10 Nov 2023 01:17:29 +0100 Subject: [PATCH 6/7] fix lint --- docs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs.md b/docs.md index 63847e6..ecc97ea 100644 --- a/docs.md +++ b/docs.md @@ -44,7 +44,7 @@ when: There are two parts to configure the plugin: -### 1. Most basic options can be configured via plugin settings: +### 1. Most basic options can be configured via plugin settings | Settings | Default | Description | | ---------------------------- | ---------------------- | ------------------------------------------------- | From 1731293c172cc0242533c1c8216b8edd5f9be663 Mon Sep 17 00:00:00 2001 From: Anbraten Date: Fri, 10 Nov 2023 20:42:58 +0100 Subject: [PATCH 7/7] add version placeholder --- README.md | 2 +- docs.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 756f579..082f9e2 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ when: steps: release-helper: - image: woodpeckerci/plugin-ready-release-go:latest + image: woodpeckerci/plugin-ready-release-go: settings: git_email: my-email@example.org github_token: diff --git a/docs.md b/docs.md index ecc97ea..e69afdf 100644 --- a/docs.md +++ b/docs.md @@ -5,7 +5,7 @@ icon: https://woodpecker-ci.org/img/logo.svg description: Plugin for semi-automated releases. authors: Woodpecker Authors tags: [git, release] -containerImage: woodpeckerci/plugin-ready-release-go +containerImage: woodpeckerci/plugin-ready-release-go: containerImageUrl: https://hub.docker.com/r/woodpeckerci/plugin-ready-release-go url: https://github.com/woodpecker-ci/plugin-ready-release-go ---