Skip to content

Commit 80972e4

Browse files
authored
Add backport CLI (#490)
* Add backport CLI * Reformat nix files * Attempt 2 without node2nix * Remove backport node2nix task and format files * Add comment about how to regen the package-lock.json if necessary * Add CONTRIBUTING.md backport section
1 parent ff3b06d commit 80972e4

File tree

6 files changed

+10345
-1
lines changed

6 files changed

+10345
-1
lines changed

.backportrc.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"repoOwner": "redpanda-data",
3+
"repoName": "redpanda-operator",
4+
"targetBranchChoices": ["release/v2.3.x"],
5+
"targetPRLabels": ["backport"],
6+
"branchLabelMapping": {
7+
"^v(\\d+).(\\d+).\\d+$": "release/v$1.$2.x"
8+
}
9+
}

CONTRIBUTING.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ It is recommend to use [direnv](https://direnv.net/) to automatically enter the
3131
development shell when `cd`'ing into the repository. The [.envrc](./.envrc) is
3232
already configured.
3333

34+
## Backporting
35+
36+
We are currently experimenting with workflows for backporting leveraging the
37+
[backport CLI](https://github.com/sorenlouv/backport). To do a manual backport, once a PR
38+
has merged, ensure that you have a Github personal access token in
39+
`~/.backport/config.json` as documented [here](https://github.com/sorenlouv/backport/blob/v9.6.6/docs/config-file-options.md#global-config-backportconfigjson),
40+
and then run `backport --pr ###` with the PR number.
41+
42+
We will eventually try and set up an automated Github action for backports based on PR labels.
43+
3444
## CHANGELOG Management
3545

3646
Our CHANGELOG.mds are managed with [Changie](https://github.com/miniscruff/changie).
@@ -49,4 +59,4 @@ To release any project in this repository:
4959
4. Commit the resultant diff with the commit message `<project>: cut release <version>` and rebase it into master via a Pull Request.
5060
5. Tag the above commit with as `<project>/v<version>` with `git tag $(changie latest -j <project>) <commit-sha>`.
5161
- If the operator is being released, also tag the same commit as `v<version>`.
52-
6. Push the tag(s).
62+
6. Push the tag(s).

ci/backport.nix

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{ buildNpmPackage
2+
, fetchFromGitHub
3+
, lib
4+
, pkgs
5+
}:
6+
7+
buildNpmPackage rec {
8+
pname = "backport";
9+
version = "9.6.6";
10+
11+
src = fetchFromGitHub {
12+
owner = "sorenlouv";
13+
repo = "backport";
14+
rev = "v${version}";
15+
hash = "sha256-VgEOUqbsgZ0EP9dN9iRmh+V05gEUaNhKASivt0pUKIw=";
16+
};
17+
18+
dontNpmBuild = true;
19+
20+
# the compiled typescript files don't come in the release tags and neither does a package-lock.json
21+
# due to this project using yarn, so just copy over the checked in package-lock.json and generate
22+
# the typescript files prior to installation so the binary can be run.
23+
#
24+
# to generate a new package-lock.json if say the version of backport installed needs to be changed
25+
# download the version of the backport release you want to install unzip it into your system, run "npm install"
26+
# and copy the package-lock.json to "ci/files/backport-package-lock.json"
27+
preInstall = ''
28+
npx tsc
29+
'';
30+
packageLock = pkgs.writeText "package-lock.json" (builtins.readFile ./files/backport-package-lock.json);
31+
postPatch = ''
32+
cp ${packageLock} package-lock.json
33+
'';
34+
35+
npmDepsHash = "sha256-ZjmP/kCDEYHHJLFyITIPlM93TFMYDSLbrRS9MGHAEvE=";
36+
37+
meta = with lib; {
38+
description = "Backport CLI tool";
39+
mainProgram = "backport";
40+
homepage = "https://github.com/sorenlouv/backport";
41+
changelog = "https://github.com/sorenlouv/backport/releases/tag/v${version}";
42+
license = licenses.asl20;
43+
};
44+
}

0 commit comments

Comments
 (0)