diff --git a/.golangci.yml b/.golangci.yml index 104cf923ce..ce610eb8be 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -91,8 +91,8 @@ linters: min-occurrences: 2 gomoddirectives: - # Allow local `replace` directives. Default is false. - replace-local: false + # Allow local `replace` directives (e.g. dev-tools submodule in go.mod). + replace-local: true gomodguard: blocked: # List of blocked modules. diff --git a/Dockerfile b/Dockerfile index 04ef6931f8..ea683ba431 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,7 @@ WORKDIR /fleet-server # pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change COPY go.mod go.sum ./ +COPY dev-tools/go.mod dev-tools/go.sum ./dev-tools/ RUN go mod download && go mod verify RUN go install github.com/magefile/mage # Uses version from go.mod implicitly ENV PATH="$PATH:/go/bin" diff --git a/Dockerfile.build b/Dockerfile.build index 4cb027053d..00ac2a8935 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -13,6 +13,7 @@ USER fleet-server WORKDIR /fleet-server/ # pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change COPY go.mod go.sum ./ +COPY dev-tools/go.mod dev-tools/go.sum ./dev-tools/ RUN go mod download && go mod verify RUN go install github.com/magefile/mage # uses version in go.mod diff --git a/Dockerfile.fips b/Dockerfile.fips index 8adae79231..a773061d6e 100644 --- a/Dockerfile.fips +++ b/Dockerfile.fips @@ -10,6 +10,7 @@ WORKDIR /fleet-server/ # pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change COPY go.mod go.sum ./ +COPY dev-tools/go.mod dev-tools/go.sum ./dev-tools/ # GOFIPS140 must be set before go mod download so that the golang.org/fips140 module is cached during image build. # Without this, the module would be fetched at build time by the host user who lacks write access to the module cache. ENV GOFIPS140=certified @@ -32,6 +33,7 @@ FROM docker.elastic.co/beats-dev/golang-crossbuild:${GO_VERSION}-${SUFFIX} AS bu WORKDIR /fleet-server ENV PATH="$PATH:/go/bin" COPY go.mod go.sum ./ +COPY dev-tools/go.mod dev-tools/go.sum ./dev-tools/ RUN go mod download && go mod verify RUN go install github.com/magefile/mage # uses version in go.mod diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 0000000000..12c7aa9227 --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,95 @@ +# Fleet-Server Release Automation + +Mage-based release workflows for Fleet Server, replacing the former ingest-dev +[`fleet-server.mak`](https://github.com/elastic/ingest-dev/blob/main/release_scripts/fleet-server.mak) +Makefile process. Package layout matches beats and elastic-agent under +`dev-tools/mage/release/`. + +## Quick start + +```bash +export PROJECT_OWNER="your-user" +export CURRENT_RELEASE="9.6.0" +export GITHUB_TOKEN=$(gh auth token) +export DRY_RUN=true + +# Major/minor after feature freeze +mage release:runMajorMinor + +# Next patch + backport PRs (run after runMajorMinor) +mage release:runNextRelease + +# Patch release on an existing release branch +export RELEASE_BRANCH="9.6" +export CURRENT_RELEASE="9.6.2" +mage release:runPatch + +git diff +go test ./dev-tools/mage/release/... -count=1 +``` + +Use plain `X.Y.Z` semver for `CURRENT_RELEASE` (no `-test` or `-SNAPSHOT` suffixes). + +## Workflow alignment + +| Former (ingest-dev) | Mage command | PRs produced | +|---|---|---| +| `prepare-major-minor-release` + `create-branch-major-minor-release` | `mage release:runMajorMinor` | Push release branch; PR `bump-version-` → `main` | +| `prepare-next-release` + `create-prs-next-release` | `mage release:runNextRelease` | PR `update-version-next-` → release branch; PR `add-backport-next-` → `main` | +| `prepare-patch-release` + `create-prs-patch-release` | `mage release:runPatch` | PR `update-docs-version-` → release branch | + +## Environment variables + +| Variable | Required | Default | Description | +|---|---|---|---| +| `CURRENT_RELEASE` | yes | — | Version to release (`9.6.0`) | +| `GITHUB_TOKEN` | yes (unless dry run) | — | GitHub API token | +| `DRY_RUN` | no | `false` | Prepare branches locally without push/PR | +| `BASE_BRANCH` | no | `main` | Base branch for major/minor | +| `RELEASE_BRANCH` | no | inferred | Release branch (e.g. `9.6`) | +| `NEXT_RELEASE` | no | patch+1 | Next patch on release branch | +| `NEXT_PROJECT_MINOR_VERSION` | no | minor+1 | Next minor for main bump | +| `PROJECT_OWNER` | no | `elastic` | GitHub owner | +| `PROJECT_REPO` | no | `fleet-server` | GitHub repository | +| `PROJECT_REVIEWERS` | no | `elastic/elastic-agent-control-plane` | PR reviewers | + +## Files updated + +- `version/version.go` — `DefaultVersion` +- `.mergify.yml` — backport rule (next-release workflow) + +## Idempotency + +Release steps are safe to re-run after partial failure or CI retry: + +| Step | Re-run behavior | +|---|---| +| `UpdateVersion` | No-op when version already matches | +| `UpdateMergify` | No-op when backport rule already exists | +| Branch creation | Reuses existing branch | +| `CommitAll` | Skips when worktree is clean | +| `Push` | Succeeds when remote is up to date | +| `CreatePR` | Returns existing open PR for same head/base | + +## Package layout + +``` +dev-tools/mage/release/ +├── config.go # Env loading and version inference +├── release.go # UpdateVersion +├── mergify.go # UpdateMergify +├── workflows.go # RunMajorMinor, RunNextRelease, RunPatch +├── git.go # Branch, commit, push helpers +├── github.go # PR creation and labels +└── README.md # Maintainer reference +``` + +See `dev-tools/mage/release/README.md` for detailed command mapping. + +## Testing + +```bash +cd dev-tools && go test ./mage/release/... -count=1 +``` + +Discard local workflow changes after review with `git reset --hard HEAD`. diff --git a/dev-tools/go.mod b/dev-tools/go.mod index c475b0fdae..d7b80fad00 100644 --- a/dev-tools/go.mod +++ b/dev-tools/go.mod @@ -13,33 +13,56 @@ tool ( ) require ( + github.com/go-git/go-git/v5 v5.12.0 + github.com/google/go-github/v68 v68.0.0 +) + +require ( + dario.cat/mergo v1.0.0 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/ProtonMail/go-crypto v1.0.0 // indirect github.com/aclements/go-moremath v0.0.0-20210112150236-f10218a38794 // indirect + github.com/cloudflare/circl v1.3.7 // indirect github.com/cyphar/filepath-securejoin v0.2.5 // indirect github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 // indirect github.com/elastic/go-json-schema-generate v0.0.0-20220323152209-ec19b88f6b5e // indirect github.com/elastic/go-licenser v0.4.2 // indirect + github.com/emirpasic/gods v1.18.1 // indirect github.com/getkin/kin-openapi v0.132.0 // indirect + github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect + github.com/go-git/go-billy/v5 v5.5.0 // indirect github.com/go-openapi/jsonpointer v0.21.0 // indirect github.com/go-openapi/swag v0.23.0 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/google/go-querystring v1.1.0 // indirect github.com/google/licenseclassifier v0.0.0-20200402202327-879cb1424de0 // indirect + github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/jstemmer/go-junit-report v1.0.0 // indirect + github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/oapi-codegen/oapi-codegen/v2 v2.5.0 // indirect github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 // indirect github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 // indirect github.com/perimeterx/marshmallow v1.1.5 // indirect - github.com/sergi/go-diff v1.1.0 // indirect + github.com/pjbgf/sha1cd v0.3.0 // indirect + github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect + github.com/skeema/knownhosts v1.2.2 // indirect github.com/speakeasy-api/jsonpath v0.6.0 // indirect github.com/speakeasy-api/openapi-overlay v0.10.2 // indirect github.com/vmware-labs/yaml-jsonpath v0.3.2 // indirect + github.com/xanzy/ssh-agent v0.3.3 // indirect go.elastic.co/go-licence-detector v0.7.0 // indirect + golang.org/x/crypto v0.38.0 // indirect golang.org/x/mod v0.24.0 // indirect + golang.org/x/net v0.40.0 // indirect golang.org/x/perf v0.0.0-20250305200902-02a15fd477ba // indirect golang.org/x/sync v0.14.0 // indirect - golang.org/x/text v0.23.0 // indirect + golang.org/x/sys v0.33.0 // indirect + golang.org/x/text v0.25.0 // indirect golang.org/x/tools v0.33.0 // indirect + gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/dev-tools/go.sum b/dev-tools/go.sum index 8355f27cc1..7a40c2b16a 100644 --- a/dev-tools/go.sum +++ b/dev-tools/go.sum @@ -1,8 +1,23 @@ +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78= +github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/aclements/go-moremath v0.0.0-20210112150236-f10218a38794 h1:xlwdaKcTNVW4PtpQb8aKA4Pjy0CdJHEqvFbAnvR5m2g= github.com/aclements/go-moremath v0.0.0-20210112150236-f10218a38794/go.mod h1:7e+I0LQFUI9AXWxOfsQROs9xPhoJtbsyWcjJqDd4KPY= +github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= +github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= +github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= +github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= +github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= github.com/cyphar/filepath-securejoin v0.2.5 h1:6iR5tXJ/e6tJZzzdMc1km3Sa7RRIVBKAK32O2s7AYfo= github.com/cyphar/filepath-securejoin v0.2.5/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -15,11 +30,25 @@ github.com/elastic/go-json-schema-generate v0.0.0-20220323152209-ec19b88f6b5e h1 github.com/elastic/go-json-schema-generate v0.0.0-20220323152209-ec19b88f6b5e/go.mod h1:w6t176CDaF2cZXwuQtFA5T+trYjvo5OYxLbBwAE7gxU= github.com/elastic/go-licenser v0.4.2 h1:bPbGm8bUd8rxzSswFOqvQh1dAkKGkgAmrPxbUi+Y9+A= github.com/elastic/go-licenser v0.4.2/go.mod h1:W8eH6FaZDR8fQGm+7FnVa7MxI1b/6dAqxz+zPB8nm5c= +github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU= +github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/getkin/kin-openapi v0.132.0 h1:3ISeLMsQzcb5v26yeJrBcdTCEQTag36ZjaGk7MIRUwk= github.com/getkin/kin-openapi v0.132.0/go.mod h1:3OlG51PCYNsPByuiMB0t4fjnNlIDnaEDsjiKUV8nL58= +github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE= +github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= +github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= +github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= +github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= +github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= +github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= +github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY= github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= @@ -27,6 +56,8 @@ github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM= github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= @@ -40,18 +71,27 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-github/v68 v68.0.0 h1:ZW57zeNZiXTdQ16qrDiZ0k6XucrxZ2CGmoTvcCyQG6s= +github.com/google/go-github/v68 v68.0.0/go.mod h1:K9HAUBovM2sLwM408A18h+wd9vqdLOEqTUCbnRIcx68= +github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= +github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/licenseclassifier v0.0.0-20200402202327-879cb1424de0 h1:OggOMmdI0JLwg1FkOKH9S7fVHF0oEm8PX6S8kAdpOps= github.com/google/licenseclassifier v0.0.0-20200402202327-879cb1424de0/go.mod h1:qsqn2hxC+vURpyBRygGUuinTO42MFRLcsmQ/P8v94+M= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jstemmer/go-junit-report v1.0.0 h1:8X1gzZpR+nVQLAht+L/foqOeX2l9DTZoaIPbEQHxsds= github.com/jstemmer/go-junit-report v1.0.0/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= +github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -82,22 +122,32 @@ github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= -github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw= github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= +github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= +github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s= github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw= +github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= +github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= +github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A= +github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= github.com/speakeasy-api/jsonpath v0.6.0 h1:IhtFOV9EbXplhyRqsVhHoBmmYjblIRh5D1/g8DHMXJ8= github.com/speakeasy-api/jsonpath v0.6.0/go.mod h1:ymb2iSkyOycmzKwbEAYPJV/yi2rSmvBCLZJcyD+VVWw= github.com/speakeasy-api/openapi-overlay v0.10.2 h1:VOdQ03eGKeiHnpb1boZCGm7x8Haj6gST0P3SGTX95GU= github.com/speakeasy-api/openapi-overlay v0.10.2/go.mod h1:n0iOU7AqKpNFfEt6tq7qYITC4f0yzVVdFw0S7hukemg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= @@ -107,13 +157,24 @@ github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4d github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/vmware-labs/yaml-jsonpath v0.3.2 h1:/5QKeCBGdsInyDCyVNLbXyilb61MXGi9NP674f9Hobk= github.com/vmware-labs/yaml-jsonpath v0.3.2/go.mod h1:U6whw1z03QyqgWdgXxvVnQ90zN1BWz5V+51Ewf8k+rQ= +github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= +github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.elastic.co/go-licence-detector v0.7.0 h1:qC31sfyfNcNx/zMYcLABU0ac3MbGHZgksCAb5lMDUMg= go.elastic.co/go-licence-detector v0.7.0/go.mod h1:f5ty8pjynzQD8BcS+s0qtlOGKc35/HKQxCVi8SHhV5k= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= +golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -121,8 +182,14 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= golang.org/x/perf v0.0.0-20250305200902-02a15fd477ba h1:0iM7SkkyXtZKGBWfn+ka1Rj6VOCRyFMkEHaCWsaR7no= @@ -130,6 +197,8 @@ golang.org/x/perf v0.0.0-20250305200902-02a15fd477ba/go.mod h1:YEhzh+7vn0fUjydWE golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -137,28 +206,47 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= +golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= +golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= -golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= +golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc= golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -180,6 +268,8 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/dev-tools/mage/release/README.md b/dev-tools/mage/release/README.md new file mode 100644 index 0000000000..7e645ecf67 --- /dev/null +++ b/dev-tools/mage/release/README.md @@ -0,0 +1,66 @@ +# Fleet Server release automation + +Mage-based release workflows for Fleet Server, aligned with the former +[`release_scripts/fleet-server.mak`](https://github.com/elastic/ingest-dev/blob/main/release_scripts/fleet-server.mak) +process and the package layout used in beats and elastic-agent. + +## Commands + +| Mage command | Former Makefile target | Description | +|---|---|---| +| `mage release:runMajorMinor` | `prepare-major-minor-release` + `create-branch-major-minor-release` | Push release branch; open bump-main PR | +| `mage release:runNextRelease` | `prepare-next-release` + `create-prs-next-release` | Open next patch + backport PRs | +| `mage release:runPatch` | `prepare-patch-release` + `create-prs-patch-release` | Open patch version PR into release branch | +| `mage release:updateVersion ` | `update-version` | Update `version/version.go` only | +| `mage release:updateMergify ` | `update-mergify` | Append backport rule to `.mergify.yml` | + +## Environment variables + +| Variable | Required | Default | Description | +|---|---|---|---| +| `CURRENT_RELEASE` | yes | — | Release version (`X.Y.Z`) | +| `GITHUB_TOKEN` | yes (unless `DRY_RUN=true`) | — | Token for push and PR creation | +| `DRY_RUN` | no | `false` | Prepare branches locally without push/PR | +| `BASE_BRANCH` | no | `main` | Base branch for major/minor | +| `RELEASE_BRANCH` | no | inferred from `CURRENT_RELEASE` | Release branch (e.g. `9.6`) | +| `NEXT_RELEASE` | no | inferred patch+1 | Next patch version on release branch | +| `NEXT_PROJECT_MINOR_VERSION` | no | inferred minor+1 | Next minor version for main bump | +| `LATEST_RELEASE` | no | inferred patch-1 | Previous patch (patch workflow) | +| `PROJECT_OWNER` | no | `elastic` | GitHub owner | +| `PROJECT_REPO` | no | `fleet-server` | GitHub repository | +| `PROJECT_REVIEWERS` | no | `elastic/elastic-agent-control-plane` | PR reviewers | + +## Files updated + +- `version/version.go` — `DefaultVersion` +- `.mergify.yml` — backport rule (next-release workflow only) + +Fleet Server has no K8s/docs manifest updates in the former Makefile process. + +## Local testing + +```bash +export PROJECT_OWNER="your-user" +export CURRENT_RELEASE="9.6.0" +export GITHUB_TOKEN=$(gh auth token) +export DRY_RUN=true + +mage release:runMajorMinor +git diff + +mage release:runNextRelease +git diff + +export RELEASE_BRANCH="9.6" +export CURRENT_RELEASE="9.6.2" +mage release:runPatch +git diff + +go test ./dev-tools/mage/release/... -count=1 +``` + +Discard local changes after review with `git reset --hard HEAD`. + +## Idempotency + +Workflow steps are safe to re-run: existing branches are reused, empty commits are skipped, open PRs are rediscovered, and file updates no-op when already applied. diff --git a/dev-tools/mage/release/config.go b/dev-tools/mage/release/config.go new file mode 100644 index 0000000000..13cabdece3 --- /dev/null +++ b/dev-tools/mage/release/config.go @@ -0,0 +1,192 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License 2.0; +// you may not use this file except in compliance with the Elastic License 2.0. + +package release + +import ( + "fmt" + "os" + "strconv" + "strings" +) + +// ReleaseConfig holds the configuration for release operations. +type ReleaseConfig struct { + CurrentRelease string + LatestRelease string + NextRelease string + NextProjectMinorVersion string + NextProjectMinorOnly string + + BaseBranch string + ReleaseBranch string + + ProjectOwner string + ProjectRepo string + GitHubToken string + ProjectReviewers []string + + GitAuthorName string + GitAuthorEmail string + + DryRun bool +} + +// LoadConfigFromEnv loads release configuration from environment variables. +func LoadConfigFromEnv() (*ReleaseConfig, error) { + currentRelease := os.Getenv("CURRENT_RELEASE") + if currentRelease == "" { + return nil, fmt.Errorf("CURRENT_RELEASE environment variable is required") + } + + latestRelease, err := inferLatestRelease(currentRelease) + if err != nil { + return nil, fmt.Errorf("failed to infer LATEST_RELEASE: %w", err) + } + + nextRelease, err := inferNextRelease(currentRelease) + if err != nil { + return nil, fmt.Errorf("failed to infer NEXT_RELEASE: %w", err) + } + + nextProjectMinorVersion, err := inferNextProjectMinorVersion(currentRelease) + if err != nil { + return nil, fmt.Errorf("failed to infer next project minor version: %w", err) + } + + releaseBranch := inferReleaseBranch(currentRelease) + + if envLatest := os.Getenv("LATEST_RELEASE"); envLatest != "" { + latestRelease = envLatest + } + if envNext := os.Getenv("NEXT_RELEASE"); envNext != "" { + nextRelease = envNext + } + if envBranch := os.Getenv("RELEASE_BRANCH"); envBranch != "" { + releaseBranch = envBranch + } + if envNextMinor := os.Getenv("NEXT_PROJECT_MINOR_VERSION"); envNextMinor != "" { + nextProjectMinorVersion = envNextMinor + } + + nextProjectMinorOnly := inferNextProjectMinorOnly(nextProjectMinorVersion) + + cfg := &ReleaseConfig{ + CurrentRelease: currentRelease, + LatestRelease: latestRelease, + NextRelease: nextRelease, + NextProjectMinorVersion: nextProjectMinorVersion, + NextProjectMinorOnly: nextProjectMinorOnly, + BaseBranch: getEnvOrDefault("BASE_BRANCH", "main"), + ReleaseBranch: releaseBranch, + ProjectOwner: getEnvOrDefault("PROJECT_OWNER", "elastic"), + ProjectRepo: getEnvOrDefault("PROJECT_REPO", "fleet-server"), + GitHubToken: os.Getenv("GITHUB_TOKEN"), + GitAuthorName: getEnvOrDefault("GITHUB_USERNAME", getEnvOrDefault("GIT_AUTHOR_NAME", "elasticmachine")), + GitAuthorEmail: getEnvOrDefault("GITHUB_EMAIL", getEnvOrDefault("GIT_AUTHOR_EMAIL", "infra-root+elasticmachine@elastic.co")), + DryRun: parseDryRun(os.Getenv("DRY_RUN")), + } + + reviewers := getEnvOrDefault("PROJECT_REVIEWERS", "elastic/elastic-agent-control-plane") + cfg.ProjectReviewers = strings.Split(reviewers, ",") + + return cfg, nil +} + +// LoadReleaseConfigFromEnv is a deprecated alias for LoadConfigFromEnv. +func LoadReleaseConfigFromEnv() (*ReleaseConfig, error) { + return LoadConfigFromEnv() +} + +func getEnvOrDefault(key, defaultValue string) string { + if value := os.Getenv(key); value != "" { + return value + } + return defaultValue +} + +func parseDryRun(value string) bool { + if value == "" { + return false + } + if parsed, err := strconv.ParseBool(value); err == nil { + return parsed + } + return strings.EqualFold(value, "true") +} + +func inferLatestRelease(currentRelease string) (string, error) { + parts := strings.Split(currentRelease, ".") + if len(parts) < 3 { + return "", fmt.Errorf("invalid version format: %s (expected major.minor.patch)", currentRelease) + } + + patch, err := strconv.Atoi(parts[2]) + if err != nil { + return "", fmt.Errorf("invalid patch version: %s", parts[2]) + } + + if patch == 0 { + return "", nil + } + + return fmt.Sprintf("%s.%s.%d", parts[0], parts[1], patch-1), nil +} + +func inferNextRelease(currentRelease string) (string, error) { + parts := strings.Split(currentRelease, ".") + if len(parts) < 3 { + return "", fmt.Errorf("invalid version format: %s (expected major.minor.patch)", currentRelease) + } + + patch, err := strconv.Atoi(parts[2]) + if err != nil { + return "", fmt.Errorf("invalid patch version: %s", parts[2]) + } + + return fmt.Sprintf("%s.%s.%d", parts[0], parts[1], patch+1), nil +} + +func inferNextProjectMinorVersion(currentRelease string) (string, error) { + parts := strings.Split(currentRelease, ".") + if len(parts) < 3 { + return "", fmt.Errorf("invalid version format: %s (expected major.minor.patch)", currentRelease) + } + + minor, err := strconv.Atoi(parts[1]) + if err != nil { + return "", fmt.Errorf("invalid minor version: %s", parts[1]) + } + + return fmt.Sprintf("%s.%d.0", parts[0], minor+1), nil +} + +func inferNextProjectMinorOnly(nextProjectMinorVersion string) string { + parts := strings.Split(nextProjectMinorVersion, ".") + if len(parts) >= 2 { + return parts[0] + "." + parts[1] + } + return nextProjectMinorVersion +} + +func inferReleaseBranch(currentRelease string) string { + parts := strings.Split(currentRelease, ".") + if len(parts) >= 2 { + return parts[0] + "." + parts[1] + } + return "" +} + +// Validate checks if the configuration is valid. +func (c *ReleaseConfig) Validate() error { + if c.CurrentRelease == "" { + return fmt.Errorf("CurrentRelease is required") + } + + if !c.DryRun && c.GitHubToken == "" { + return fmt.Errorf("GITHUB_TOKEN is required when not in dry-run mode") + } + + return nil +} diff --git a/dev-tools/mage/release/config_test.go b/dev-tools/mage/release/config_test.go new file mode 100644 index 0000000000..e9df19b426 --- /dev/null +++ b/dev-tools/mage/release/config_test.go @@ -0,0 +1,130 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License 2.0; +// you may not use this file except in compliance with the Elastic License 2.0. + +package release + +import ( + "os" + "testing" +) + +func TestInferLatestRelease(t *testing.T) { + tests := []struct { + name string + current string + want string + wantErr bool + }{ + {name: "patch release", current: "9.6.2", want: "9.6.1"}, + {name: "x.y.0 returns empty", current: "9.6.0", want: ""}, + {name: "invalid version", current: "9.6", wantErr: true}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := inferLatestRelease(tt.current) + if (err != nil) != tt.wantErr { + t.Fatalf("inferLatestRelease() error = %v, wantErr %v", err, tt.wantErr) + } + if got != tt.want { + t.Fatalf("inferLatestRelease() = %q, want %q", got, tt.want) + } + }) + } +} + +func TestInferNextRelease(t *testing.T) { + got, err := inferNextRelease("9.6.0") + if err != nil { + t.Fatalf("inferNextRelease() failed: %v", err) + } + if got != "9.6.1" { + t.Fatalf("inferNextRelease() = %q, want 9.6.1", got) + } +} + +func TestInferNextProjectMinorVersion(t *testing.T) { + got, err := inferNextProjectMinorVersion("9.6.0") + if err != nil { + t.Fatalf("inferNextProjectMinorVersion() failed: %v", err) + } + if got != "9.7.0" { + t.Fatalf("inferNextProjectMinorVersion() = %q, want 9.7.0", got) + } +} + +func TestLoadConfigFromEnv(t *testing.T) { + tests := []struct { + name string + envVars map[string]string + wantErr bool + wantCheck func(*testing.T, *ReleaseConfig) + }{ + { + name: "defaults applied", + envVars: map[string]string{ + "CURRENT_RELEASE": "9.6.0", + }, + wantErr: false, + wantCheck: func(t *testing.T, cfg *ReleaseConfig) { + if cfg.ReleaseBranch != "9.6" { + t.Errorf("ReleaseBranch = %s, want 9.6", cfg.ReleaseBranch) + } + if cfg.NextRelease != "9.6.1" { + t.Errorf("NextRelease = %s, want 9.6.1", cfg.NextRelease) + } + if cfg.NextProjectMinorVersion != "9.7.0" { + t.Errorf("NextProjectMinorVersion = %s, want 9.7.0", cfg.NextProjectMinorVersion) + } + if cfg.ProjectOwner != "elastic" { + t.Errorf("ProjectOwner = %s, want elastic", cfg.ProjectOwner) + } + if cfg.ProjectRepo != "fleet-server" { + t.Errorf("ProjectRepo = %s, want fleet-server", cfg.ProjectRepo) + } + }, + }, + { + name: "missing CURRENT_RELEASE", + envVars: map[string]string{}, + wantErr: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + os.Clearenv() + for k, v := range tt.envVars { + os.Setenv(k, v) + } + + cfg, err := LoadConfigFromEnv() + if (err != nil) != tt.wantErr { + t.Fatalf("LoadConfigFromEnv() error = %v, wantErr %v", err, tt.wantErr) + } + if !tt.wantErr && tt.wantCheck != nil { + tt.wantCheck(t, cfg) + } + }) + } +} + +func TestParseDryRun(t *testing.T) { + tests := []struct { + input string + want bool + }{ + {input: "", want: false}, + {input: "true", want: true}, + {input: "TRUE", want: true}, + {input: "false", want: false}, + {input: "1", want: true}, + } + + for _, tt := range tests { + if got := parseDryRun(tt.input); got != tt.want { + t.Errorf("parseDryRun(%q) = %v, want %v", tt.input, got, tt.want) + } + } +} diff --git a/dev-tools/mage/release/git.go b/dev-tools/mage/release/git.go new file mode 100644 index 0000000000..a212e4a2cc --- /dev/null +++ b/dev-tools/mage/release/git.go @@ -0,0 +1,324 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License 2.0; +// you may not use this file except in compliance with the Elastic License 2.0. + +package release + +import ( + "errors" + "fmt" + "os" + "time" + + "github.com/go-git/go-git/v5" + "github.com/go-git/go-git/v5/config" + "github.com/go-git/go-git/v5/plumbing" + "github.com/go-git/go-git/v5/plumbing/object" + "github.com/go-git/go-git/v5/plumbing/storer" + "github.com/go-git/go-git/v5/plumbing/transport/http" +) + +// GitRepo wraps go-git Repository with helper methods. +type GitRepo struct { + repo *git.Repository + path string +} + +// OpenRepo opens a git repository at the specified path. +func OpenRepo(path string) (*GitRepo, error) { + repo, err := git.PlainOpen(path) + if err != nil { + return nil, fmt.Errorf("failed to open repository: %w", err) + } + + return &GitRepo{ + repo: repo, + path: path, + }, nil +} + +// BranchExists reports whether a local branch exists. +func (g *GitRepo) BranchExists(branchName string) (bool, error) { + _, err := g.repo.Reference(plumbing.NewBranchReferenceName(branchName), true) + if err == nil { + return true, nil + } + if errors.Is(err, plumbing.ErrReferenceNotFound) { + return false, nil + } + return false, fmt.Errorf("failed to check branch %s: %w", branchName, err) +} + +// CreateBranch creates a new branch from the current HEAD. +func (g *GitRepo) CreateBranch(branchName string) error { + exists, err := g.BranchExists(branchName) + if err != nil { + return err + } + if exists { + fmt.Printf("Branch already exists: %s\n", branchName) + return nil + } + + headRef, err := g.repo.Head() + if err != nil { + return fmt.Errorf("failed to get HEAD: %w", err) + } + + refName := plumbing.NewBranchReferenceName(branchName) + ref := plumbing.NewHashReference(refName, headRef.Hash()) + + err = g.repo.Storer.SetReference(ref) + if err != nil { + return fmt.Errorf("failed to create branch %s: %w", branchName, err) + } + + fmt.Printf("Created branch: %s\n", branchName) + return nil +} + +// EnsureBranchFrom checks out baseBranch and creates or checks out branchName from that point. +func (g *GitRepo) EnsureBranchFrom(baseBranch, branchName string) error { + if err := g.CheckoutBranch(baseBranch); err != nil { + return fmt.Errorf("failed to checkout base branch %s: %w", baseBranch, err) + } + + exists, err := g.BranchExists(branchName) + if err != nil { + return err + } + if exists { + return g.CheckoutBranch(branchName) + } + + if err := g.CreateBranch(branchName); err != nil { + return err + } + return g.CheckoutBranch(branchName) +} + +// EnsureBranch checks out an existing local or remote branch, or creates it from HEAD. +func (g *GitRepo) EnsureBranch(branchName string) error { + exists, err := g.BranchExists(branchName) + if err != nil { + return err + } + if exists { + return g.CheckoutBranch(branchName) + } + + remoteRef, err := g.repo.Reference(plumbing.NewRemoteReferenceName("origin", branchName), true) + if err == nil { + localRef := plumbing.NewHashReference(plumbing.NewBranchReferenceName(branchName), remoteRef.Hash()) + if err := g.repo.Storer.SetReference(localRef); err != nil { + return fmt.Errorf("failed to create local branch %s from origin: %w", branchName, err) + } + fmt.Printf("Created local branch from origin: %s\n", branchName) + return g.CheckoutBranch(branchName) + } + if !errors.Is(err, plumbing.ErrReferenceNotFound) { + return fmt.Errorf("failed to check remote branch %s: %w", branchName, err) + } + + if err := g.CreateBranch(branchName); err != nil { + return err + } + return g.CheckoutBranch(branchName) +} + +// CheckoutBranch checks out an existing branch. +func (g *GitRepo) CheckoutBranch(branchName string) error { + currentBranch, err := g.GetCurrentBranch() + if err == nil && currentBranch == branchName { + fmt.Printf("Already on branch: %s\n", branchName) + return nil + } + + w, err := g.repo.Worktree() + if err != nil { + return fmt.Errorf("failed to get worktree: %w", err) + } + + err = w.Checkout(&git.CheckoutOptions{ + Branch: plumbing.NewBranchReferenceName(branchName), + }) + if err != nil { + return fmt.Errorf("failed to checkout branch %s: %w", branchName, err) + } + + fmt.Printf("Checked out branch: %s\n", branchName) + return nil +} + +// CommitAll stages all changes and creates a commit. +func (g *GitRepo) CommitAll(message, authorName, authorEmail string) (bool, error) { + w, err := g.repo.Worktree() + if err != nil { + return false, fmt.Errorf("failed to get worktree: %w", err) + } + + status, err := w.Status() + if err != nil { + return false, fmt.Errorf("failed to get status: %w", err) + } + if status.IsClean() { + fmt.Println("No changes to commit") + return false, nil + } + + err = w.AddGlob(".") + if err != nil { + return false, fmt.Errorf("failed to stage changes: %w", err) + } + + commit, err := w.Commit(message, &git.CommitOptions{ + Author: &object.Signature{ + Name: authorName, + Email: authorEmail, + When: time.Now(), + }, + }) + if err != nil { + return false, fmt.Errorf("failed to commit: %w", err) + } + + fmt.Printf("Created commit: %s\n", commit.String()) + return true, nil +} + +// HasCommitsAheadOf reports whether HEAD has commits not reachable from baseBranch. +func (g *GitRepo) HasCommitsAheadOf(baseBranch string) (bool, error) { + headRef, err := g.repo.Head() + if err != nil { + return false, fmt.Errorf("failed to get HEAD: %w", err) + } + + baseRef, err := g.repo.Reference(plumbing.NewBranchReferenceName(baseBranch), true) + if err != nil { + if errors.Is(err, plumbing.ErrReferenceNotFound) { + return true, nil + } + return false, fmt.Errorf("failed to get base branch %s: %w", baseBranch, err) + } + + if headRef.Hash() == baseRef.Hash() { + return false, nil + } + + commitIter, err := g.repo.Log(&git.LogOptions{From: headRef.Hash()}) + if err != nil { + return false, fmt.Errorf("failed to walk commits: %w", err) + } + defer commitIter.Close() + + foundBase := false + err = commitIter.ForEach(func(c *object.Commit) error { + if c.Hash == baseRef.Hash() { + foundBase = true + return storer.ErrStop + } + return nil + }) + if err != nil && !errors.Is(err, storer.ErrStop) { + return false, fmt.Errorf("failed to compare commits with %s: %w", baseBranch, err) + } + + if foundBase { + return true, nil + } + + return headRef.Hash() != baseRef.Hash(), nil +} + +// Push pushes the current branch to the remote. +func (g *GitRepo) Push(remoteName string) error { + token := os.Getenv("GITHUB_TOKEN") + if token == "" { + return fmt.Errorf("GITHUB_TOKEN environment variable is required for pushing") + } + + currentBranch, err := g.GetCurrentBranch() + if err != nil { + return err + } + + refSpec := config.RefSpec(fmt.Sprintf("refs/heads/%s:refs/heads/%s", currentBranch, currentBranch)) + + err = g.repo.Push(&git.PushOptions{ + RemoteName: remoteName, + RefSpecs: []config.RefSpec{refSpec}, + Auth: &http.BasicAuth{ + Username: "git", + Password: token, + }, + }) + if err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) { + return fmt.Errorf("failed to push: %w", err) + } + + fmt.Printf("Pushed branch %s to remote: %s\n", currentBranch, remoteName) + return nil +} + +// GetCurrentBranch returns the name of the current branch. +func (g *GitRepo) GetCurrentBranch() (string, error) { + headRef, err := g.repo.Head() + if err != nil { + return "", fmt.Errorf("failed to get HEAD: %w", err) + } + + if !headRef.Name().IsBranch() { + return "", fmt.Errorf("HEAD is not a branch") + } + + return headRef.Name().Short(), nil +} + +// IsClean checks if the working directory is clean. +func (g *GitRepo) IsClean() (bool, error) { + w, err := g.repo.Worktree() + if err != nil { + return false, fmt.Errorf("failed to get worktree: %w", err) + } + + status, err := w.Status() + if err != nil { + return false, fmt.Errorf("failed to get status: %w", err) + } + + return status.IsClean(), nil +} + +// SetRemoteURL sets the URL for a remote. +func (g *GitRepo) SetRemoteURL(remoteName, url string) error { + _, err := g.repo.Remote(remoteName) + if errors.Is(err, git.ErrRemoteNotFound) { + _, err = g.repo.CreateRemote(&config.RemoteConfig{ + Name: remoteName, + URLs: []string{url}, + }) + if err != nil { + return fmt.Errorf("failed to create remote: %w", err) + } + fmt.Printf("Created remote %s: %s\n", remoteName, url) + return nil + } else if err != nil { + return fmt.Errorf("failed to get remote: %w", err) + } + + err = g.repo.DeleteRemote(remoteName) + if err != nil { + return fmt.Errorf("failed to delete remote: %w", err) + } + + _, err = g.repo.CreateRemote(&config.RemoteConfig{ + Name: remoteName, + URLs: []string{url}, + }) + if err != nil { + return fmt.Errorf("failed to recreate remote: %w", err) + } + + fmt.Printf("Updated remote %s: %s\n", remoteName, url) + return nil +} diff --git a/dev-tools/mage/release/git_test.go b/dev-tools/mage/release/git_test.go new file mode 100644 index 0000000000..fc101a967e --- /dev/null +++ b/dev-tools/mage/release/git_test.go @@ -0,0 +1,160 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License 2.0; +// you may not use this file except in compliance with the Elastic License 2.0. + +package release + +import ( + "os" + "path/filepath" + "strings" + "testing" + + "github.com/go-git/go-git/v5" + "github.com/go-git/go-git/v5/plumbing/object" +) + +func createTestGitRepo(t *testing.T) (*GitRepo, string) { + t.Helper() + + tmpDir := t.TempDir() + + repo, err := git.PlainInit(tmpDir, false) + if err != nil { + t.Fatalf("failed to init repo: %v", err) + } + + w, err := repo.Worktree() + if err != nil { + t.Fatalf("failed to get worktree: %v", err) + } + + testFile := filepath.Join(tmpDir, "README.md") + err = os.WriteFile(testFile, []byte("# Test Repo"), 0o644) + if err != nil { + t.Fatalf("failed to write test file: %v", err) + } + + _, err = w.Add("README.md") + if err != nil { + t.Fatalf("failed to add file: %v", err) + } + + _, err = w.Commit("Initial commit", &git.CommitOptions{ + Author: &object.Signature{ + Name: "Test User", + Email: "test@example.com", + }, + }) + if err != nil { + t.Fatalf("failed to create initial commit: %v", err) + } + + return &GitRepo{repo: repo, path: tmpDir}, tmpDir +} + +func TestEnsureBranchFrom(t *testing.T) { + gitRepo, tmpDir := createTestGitRepo(t) + + origDir, _ := os.Getwd() + defer func() { + _ = os.Chdir(origDir) + }() + if err := os.Chdir(tmpDir); err != nil { + t.Fatalf("failed to change to temp directory: %v", err) + } + + if err := gitRepo.EnsureBranchFrom("master", "9.6"); err != nil { + t.Fatalf("EnsureBranchFrom() failed: %v", err) + } + + branch, err := gitRepo.GetCurrentBranch() + if err != nil { + t.Fatalf("GetCurrentBranch() failed: %v", err) + } + if branch != "9.6" { + t.Fatalf("expected branch 9.6, got %s", branch) + } + + if err := gitRepo.EnsureBranchFrom("master", "9.6"); err != nil { + t.Fatalf("second EnsureBranchFrom() failed: %v", err) + } +} + +func TestCommitAllNoChanges(t *testing.T) { + gitRepo, _ := createTestGitRepo(t) + + committed, err := gitRepo.CommitAll("Empty commit", "Test Author", "test@example.com") + if err != nil { + t.Errorf("CommitAll() with no changes error = %v", err) + } + if committed { + t.Error("CommitAll() should not commit when there are no changes") + } +} + +func TestSetRemoteURLIdempotent(t *testing.T) { + gitRepo, _ := createTestGitRepo(t) + remoteURL := "https://github.com/test/repo.git" + + err := gitRepo.SetRemoteURL("origin", remoteURL) + if err != nil { + t.Fatalf("first SetRemoteURL() failed: %v", err) + } + + err = gitRepo.SetRemoteURL("origin", remoteURL) + if err != nil { + t.Fatalf("second SetRemoteURL() failed: %v", err) + } + + remote, err := gitRepo.repo.Remote("origin") + if err != nil { + t.Fatalf("failed to get remote: %v", err) + } + if len(remote.Config().URLs) == 0 || remote.Config().URLs[0] != remoteURL { + t.Errorf("SetRemoteURL() URL = %v, want %s", remote.Config().URLs, remoteURL) + } +} + +func TestBranchNameHelpers(t *testing.T) { + if got := bumpVersionBranchName("9.7.0"); got != "bump-version-9.7.0" { + t.Fatalf("bumpVersionBranchName() = %q", got) + } + if got := nextVersionBranchName("9.6.1"); got != "update-version-next-9.6.1" { + t.Fatalf("nextVersionBranchName() = %q", got) + } + if got := backportNextBranchName("9.7.0"); got != "add-backport-next-9.7.0" { + t.Fatalf("backportNextBranchName() = %q", got) + } + if got := patchDocsBranchName("9.6.2"); got != "update-docs-version-9.6.2" { + t.Fatalf("patchDocsBranchName() = %q", got) + } +} + +func TestIsReleaseWritablePath(t *testing.T) { + if !isReleaseWritablePath("version/version.go") { + t.Fatal("version/version.go should be writable") + } + if isReleaseWritablePath("main.go") { + t.Fatal("main.go should not be writable") + } +} + +func TestBranchNameHelpersUnique(t *testing.T) { + names := []string{ + bumpVersionBranchName("9.7.0"), + nextVersionBranchName("9.6.1"), + backportNextBranchName("9.7.0"), + patchDocsBranchName("9.6.2"), + } + seen := make(map[string]struct{}, len(names)) + for _, name := range names { + if _, ok := seen[name]; ok { + t.Fatalf("duplicate branch helper name: %s", name) + } + seen[name] = struct{}{} + if strings.TrimSpace(name) == "" { + t.Fatal("branch helper returned empty name") + } + } +} diff --git a/dev-tools/mage/release/github.go b/dev-tools/mage/release/github.go new file mode 100644 index 0000000000..5a6a8058e2 --- /dev/null +++ b/dev-tools/mage/release/github.go @@ -0,0 +1,160 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License 2.0; +// you may not use this file except in compliance with the Elastic License 2.0. + +package release + +import ( + "context" + "errors" + "fmt" + "os" + "strings" + + "github.com/google/go-github/v68/github" +) + +// GitHubClient wraps the GitHub API client. +type GitHubClient struct { + client *github.Client + ctx context.Context +} + +// PROptions holds options for creating a pull request. +type PROptions struct { + Owner string + Repo string + Title string + Head string + Base string + Body string + Draft bool + Reviewers []string + Labels []string +} + +// NewGitHubClient creates a new GitHub API client. +func NewGitHubClient(token string) *GitHubClient { + return &GitHubClient{ + client: github.NewClient(nil).WithAuthToken(token), + ctx: context.Background(), + } +} + +// NewGitHubClientFromEnv creates a GitHub client using GITHUB_TOKEN env var. +func NewGitHubClientFromEnv() (*GitHubClient, error) { + token := os.Getenv("GITHUB_TOKEN") + if token == "" { + return nil, fmt.Errorf("GITHUB_TOKEN environment variable not set") + } + return NewGitHubClient(token), nil +} + +// CreatePR creates a pull request, or returns an existing open PR with the same head and base. +func (gh *GitHubClient) CreatePR(opts PROptions) (*github.PullRequest, error) { + existingPR, found, err := gh.FindOpenPR(opts.Owner, opts.Repo, opts.Head, opts.Base) + if err != nil { + return nil, err + } + if found { + fmt.Printf("Open PR already exists #%d: %s\n", existingPR.GetNumber(), existingPR.GetHTMLURL()) + gh.ensurePRLabels(opts.Owner, opts.Repo, existingPR.GetNumber(), opts.Labels) + return existingPR, nil + } + + newPR := &github.NewPullRequest{ + Title: github.Ptr(opts.Title), + Head: github.Ptr(opts.Head), + Base: github.Ptr(opts.Base), + Body: github.Ptr(opts.Body), + Draft: github.Ptr(opts.Draft), + } + + pr, _, err := gh.client.PullRequests.Create(gh.ctx, opts.Owner, opts.Repo, newPR) + if err != nil { + return nil, fmt.Errorf("failed to create PR: %w", err) + } + + if len(opts.Reviewers) > 0 { + reviewersReq := github.ReviewersRequest{ + Reviewers: opts.Reviewers, + } + _, _, err = gh.client.PullRequests.RequestReviewers(gh.ctx, opts.Owner, opts.Repo, pr.GetNumber(), reviewersReq) + if err != nil { + fmt.Printf("Warning: failed to add reviewers: %v\n", err) + } + } + + gh.ensurePRLabels(opts.Owner, opts.Repo, pr.GetNumber(), opts.Labels) + + fmt.Printf("Created PR #%d: %s\n", pr.GetNumber(), pr.GetHTMLURL()) + return pr, nil +} + +// FindOpenPR returns an open pull request for the given head and base branches, if one exists. +func (gh *GitHubClient) FindOpenPR(owner, repo, head, base string) (*github.PullRequest, bool, error) { + headQuery := head + if !strings.Contains(head, ":") { + headQuery = fmt.Sprintf("%s:%s", owner, head) + } + + prs, _, err := gh.client.PullRequests.List(gh.ctx, owner, repo, &github.PullRequestListOptions{ + State: "open", + Head: headQuery, + Base: base, + ListOptions: github.ListOptions{ + PerPage: 1, + }, + }) + if err != nil { + return nil, false, fmt.Errorf("failed to list pull requests: %w", err) + } + if len(prs) == 0 { + return nil, false, nil + } + + return prs[0], true, nil +} + +func (gh *GitHubClient) ensurePRLabels(owner, repo string, number int, labels []string) { + if len(labels) == 0 { + return + } + if err := gh.AddLabels(owner, repo, number, labels); err != nil { + fmt.Printf("Warning: failed to add labels: %v\n", err) + } +} + +// AddLabels adds labels to a pull request or issue. +func (gh *GitHubClient) AddLabels(owner, repo string, number int, labels []string) error { + _, _, err := gh.client.Issues.AddLabelsToIssue(gh.ctx, owner, repo, number, labels) + if err != nil { + return fmt.Errorf("failed to add labels: %w", err) + } + + fmt.Printf("Added labels to #%d: %v\n", number, labels) + return nil +} + +// GetDefaultBranch gets the default branch for a repository. +func (gh *GitHubClient) GetDefaultBranch(owner, repo string) (string, error) { + repository, _, err := gh.client.Repositories.Get(gh.ctx, owner, repo) + if err != nil { + return "", fmt.Errorf("failed to get repository: %w", err) + } + + return repository.GetDefaultBranch(), nil +} + +// BranchExists checks if a branch exists in the remote repository. +func (gh *GitHubClient) BranchExists(owner, repo, branch string) (bool, error) { + _, _, err := gh.client.Repositories.GetBranch(gh.ctx, owner, repo, branch, 0) + if err != nil { + var ghErr *github.ErrorResponse + if errors.As(err, &ghErr) && ghErr.Response != nil && ghErr.Response.StatusCode == 404 { + return false, nil + } + return false, fmt.Errorf("failed to check branch: %w", err) + } + return true, nil +} diff --git a/dev-tools/mage/release/mergify.go b/dev-tools/mage/release/mergify.go new file mode 100644 index 0000000000..11e45a6c1f --- /dev/null +++ b/dev-tools/mage/release/mergify.go @@ -0,0 +1,85 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License 2.0; +// you may not use this file except in compliance with the Elastic License 2.0. + +package release + +import ( + "fmt" + "os" + "strings" + + "gopkg.in/yaml.v3" +) + +const mergifyPath = ".mergify.yml" + +// UpdateMergify adds a new backport rule to .mergify.yml. +func UpdateMergify(version string) error { + safePath, err := validateRepoRelativePath(mergifyPath) + if err != nil { + return err + } + + content, err := os.ReadFile(safePath) + if err != nil { + return fmt.Errorf("failed to read %s: %w", safePath, err) + } + + var config map[string]interface{} + if err := yaml.Unmarshal(content, &config); err != nil { + return fmt.Errorf("failed to parse %s: %w", safePath, err) + } + + parts := strings.Split(version, ".") + if len(parts) < 2 { + return fmt.Errorf("invalid version format: %s (expected X.Y.Z)", version) + } + branchVersion := fmt.Sprintf("%s.%s", parts[0], parts[1]) + + rules, ok := config["pull_request_rules"].([]interface{}) + if !ok { + return fmt.Errorf("pull_request_rules not found or invalid format") + } + + label := fmt.Sprintf("backport-%s", branchVersion) + for _, rule := range rules { + ruleMap, ok := rule.(map[string]interface{}) + if !ok { + continue + } + name, ok := ruleMap["name"].(string) + if ok && strings.Contains(name, branchVersion) { + fmt.Printf("Backport rule for %s already exists\n", branchVersion) + return nil + } + } + + newRule := map[string]interface{}{ + "name": fmt.Sprintf("backport patches to %s branch", branchVersion), + "conditions": []interface{}{ + "merged", + fmt.Sprintf("label=%s", label), + }, + "actions": map[string]interface{}{ + "backport": map[string]interface{}{ + "branches": []interface{}{branchVersion}, + }, + }, + } + + rules = append(rules, newRule) + config["pull_request_rules"] = rules + + output, err := yaml.Marshal(config) + if err != nil { + return fmt.Errorf("failed to marshal YAML: %w", err) + } + + if err := writeRepoFile(safePath, output); err != nil { + return fmt.Errorf("failed to write %s: %w", safePath, err) + } + + fmt.Printf("Added backport rule for %s to %s\n", branchVersion, safePath) + return nil +} diff --git a/dev-tools/mage/release/release.go b/dev-tools/mage/release/release.go new file mode 100644 index 0000000000..c9a77c3908 --- /dev/null +++ b/dev-tools/mage/release/release.go @@ -0,0 +1,86 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License 2.0; +// you may not use this file except in compliance with the Elastic License 2.0. + +package release + +import ( + "fmt" + "os" + "path/filepath" + "regexp" + "strings" +) + +const versionGoPath = "version/version.go" + +func validateRepoRelativePath(path string) (string, error) { + if path == "" { + return "", fmt.Errorf("path must not be empty") + } + if filepath.IsAbs(path) { + return "", fmt.Errorf("absolute path not allowed: %s", path) + } + + cleaned := filepath.Clean(path) + if cleaned == ".." || strings.HasPrefix(cleaned, ".."+string(os.PathSeparator)) { + return "", fmt.Errorf("path escapes repository root: %s", path) + } + + return cleaned, nil +} + +func isReleaseWritablePath(path string) bool { + switch filepath.ToSlash(path) { + case versionGoPath, ".mergify.yml": + return true + default: + return false + } +} + +func writeRepoFile(relPath string, content []byte) error { + safePath, err := validateRepoRelativePath(relPath) + if err != nil { + return err + } + + if !isReleaseWritablePath(safePath) { + return fmt.Errorf("unsupported file path: %s", relPath) + } + + return os.WriteFile(safePath, content, 0o644) //nolint:gosec // safePath is validated and allowlisted for release automation files +} + +// UpdateVersion updates the version in version/version.go. +func UpdateVersion(newVersion string) error { + versionFile, err := validateRepoRelativePath(versionGoPath) + if err != nil { + return err + } + + content, err := os.ReadFile(versionFile) + if err != nil { + return fmt.Errorf("failed to read %s: %w", versionFile, err) + } + + re := regexp.MustCompile(`(const\s+DefaultVersion\s*=\s*)"[^"]+"`) + contentStr := string(content) + alreadyAtVersion := regexp.MustCompile(`const\s+DefaultVersion\s*=\s*"` + regexp.QuoteMeta(newVersion) + `"`) + if alreadyAtVersion.MatchString(contentStr) { + fmt.Printf("Version already set to %s in %s\n", newVersion, versionFile) + return nil + } + + newContent := re.ReplaceAllString(contentStr, `${1}"`+newVersion+`"`) + if newContent == contentStr { + return fmt.Errorf("version pattern not found in %s", versionFile) + } + + if err := writeRepoFile(versionFile, []byte(newContent)); err != nil { + return fmt.Errorf("failed to write %s: %w", versionFile, err) + } + + fmt.Printf("Updated version to %s in %s\n", newVersion, versionFile) + return nil +} diff --git a/dev-tools/mage/release/release_test.go b/dev-tools/mage/release/release_test.go new file mode 100644 index 0000000000..3f7b9cd5d8 --- /dev/null +++ b/dev-tools/mage/release/release_test.go @@ -0,0 +1,229 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License 2.0; +// you may not use this file except in compliance with the Elastic License 2.0. + +package release + +import ( + "os" + "path/filepath" + "strings" + "testing" +) + +func TestUpdateVersion(t *testing.T) { + tests := []struct { + name string + initial string + newVersion string + wantErr bool + wantContent string + }{ + { + name: "update version successfully", + initial: `const DefaultVersion = "9.4.0"`, + newVersion: "9.5.0", + wantErr: false, + wantContent: `const DefaultVersion = "9.5.0"`, + }, + { + name: "update with different spacing", + initial: `const DefaultVersion = "9.4.0"`, + newVersion: "9.5.0", + wantErr: false, + wantContent: `const DefaultVersion = "9.5.0"`, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tmpDir := t.TempDir() + versionDir := filepath.Join(tmpDir, "version") + err := os.Mkdir(versionDir, 0o755) + if err != nil { + t.Fatalf("failed to create version dir: %v", err) + } + + versionFile := filepath.Join(versionDir, "version.go") + initialContent := `// Copyright header + +package version + +` + tt.initial + ` +` + err = os.WriteFile(versionFile, []byte(initialContent), 0o644) + if err != nil { + t.Fatalf("failed to write initial file: %v", err) + } + + origDir, _ := os.Getwd() + defer func() { + _ = os.Chdir(origDir) + }() + if err := os.Chdir(tmpDir); err != nil { + t.Fatalf("failed to change to temp directory: %v", err) + } + + err = UpdateVersion(tt.newVersion) + + if (err != nil) != tt.wantErr { + t.Errorf("UpdateVersion() error = %v, wantErr %v", err, tt.wantErr) + return + } + + if !tt.wantErr { + content, err := os.ReadFile(versionFile) + if err != nil { + t.Fatalf("failed to read updated file: %v", err) + } + + if !strings.Contains(string(content), tt.wantContent) { + t.Errorf("UpdateVersion() content = %s, want to contain %s", string(content), tt.wantContent) + } + } + }) + } +} + +func TestUpdateVersionIdempotent(t *testing.T) { + tmpDir := t.TempDir() + versionDir := filepath.Join(tmpDir, "version") + err := os.Mkdir(versionDir, 0o755) + if err != nil { + t.Fatalf("failed to create version dir: %v", err) + } + + versionFile := filepath.Join(versionDir, "version.go") + initialContent := `package version + +const DefaultVersion = "9.4.0" +` + err = os.WriteFile(versionFile, []byte(initialContent), 0o644) + if err != nil { + t.Fatalf("failed to write initial file: %v", err) + } + + origDir, _ := os.Getwd() + defer func() { + _ = os.Chdir(origDir) + }() + if err := os.Chdir(tmpDir); err != nil { + t.Fatalf("failed to change to temp directory: %v", err) + } + + err = UpdateVersion("9.5.0") + if err != nil { + t.Fatalf("first UpdateVersion() failed: %v", err) + } + + content1, err := os.ReadFile(versionFile) + if err != nil { + t.Fatalf("failed to read file after first update: %v", err) + } + + err = UpdateVersion("9.5.0") + if err != nil { + t.Fatalf("second UpdateVersion() failed: %v", err) + } + + content2, err := os.ReadFile(versionFile) + if err != nil { + t.Fatalf("failed to read file after second update: %v", err) + } + + if string(content1) != string(content2) { + t.Error("UpdateVersion() is not idempotent - content changed on second run") + } +} + +func TestUpdateMergify(t *testing.T) { + tmpDir := t.TempDir() + mergifyFile := filepath.Join(tmpDir, ".mergify.yml") + + initialContent := `pull_request_rules: + - name: backport patches to 9.3 branch + conditions: + - merged + - label=backport-9.3 + actions: + backport: + branches: + - "9.3" +` + err := os.WriteFile(mergifyFile, []byte(initialContent), 0o644) + if err != nil { + t.Fatalf("failed to write initial file: %v", err) + } + + origDir, _ := os.Getwd() + defer func() { + _ = os.Chdir(origDir) + }() + if err := os.Chdir(tmpDir); err != nil { + t.Fatalf("failed to change to temp directory: %v", err) + } + + err = UpdateMergify("9.5.0") + if err != nil { + t.Fatalf("UpdateMergify() failed: %v", err) + } + + content, err := os.ReadFile(mergifyFile) + if err != nil { + t.Fatalf("failed to read updated file: %v", err) + } + + contentStr := string(content) + if !strings.Contains(contentStr, "backport patches to 9.5 branch") { + t.Errorf("UpdateMergify() missing rule name for 9.5") + } + if !strings.Contains(contentStr, "9.3") { + t.Error("UpdateMergify() removed existing rules") + } +} + +func TestUpdateMergifyIdempotent(t *testing.T) { + tmpDir := t.TempDir() + mergifyFile := filepath.Join(tmpDir, ".mergify.yml") + + initialContent := `pull_request_rules: + - name: backport patches to 9.5 branch + conditions: + - merged + - label=backport-9.5 + actions: + backport: + branches: + - "9.5" +` + err := os.WriteFile(mergifyFile, []byte(initialContent), 0o644) + if err != nil { + t.Fatalf("failed to write initial file: %v", err) + } + + origDir, _ := os.Getwd() + defer func() { + _ = os.Chdir(origDir) + }() + if err := os.Chdir(tmpDir); err != nil { + t.Fatalf("failed to change to temp directory: %v", err) + } + + err = UpdateMergify("9.5.0") + if err != nil { + t.Fatalf("first UpdateMergify() failed: %v", err) + } + + content1, _ := os.ReadFile(mergifyFile) + + err = UpdateMergify("9.5.0") + if err != nil { + t.Fatalf("second UpdateMergify() failed: %v", err) + } + + content2, _ := os.ReadFile(mergifyFile) + + if string(content1) != string(content2) { + t.Error("UpdateMergify() is not idempotent - content changed on second run") + } +} diff --git a/dev-tools/mage/release/workflows.go b/dev-tools/mage/release/workflows.go new file mode 100644 index 0000000000..5ffdb352da --- /dev/null +++ b/dev-tools/mage/release/workflows.go @@ -0,0 +1,375 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License 2.0; +// you may not use this file except in compliance with the Elastic License 2.0. + +package release + +import ( + "fmt" + "strings" + + "github.com/google/go-github/v68/github" +) + +// PR label sets match vault-bot release PRs for fleet-server. +var ( + bumpMainPRLabels = []string{"backport-skip", "skip-changelog"} + nextReleasePRLabels = []string{"Team:Automation", "release", "skip-changelog"} + backportNextPRLabels = []string{"Team:Automation", "release", "impact:critical", "skip-changelog"} + patchReleasePRLabels = []string{"Team:Automation", "release", "docs", "in progress", "skip-changelog"} +) + +func checkRequirements(cfg *ReleaseConfig) error { + parts := strings.Split(cfg.CurrentRelease, ".") + if len(parts) < 2 { + return fmt.Errorf("invalid version format: %s", cfg.CurrentRelease) + } + + repo, err := OpenRepo(".") + if err != nil { + return err + } + + clean, err := repo.IsClean() + if err != nil { + return err + } + if !clean { + return fmt.Errorf("working directory is not clean. Please commit or stash changes first") + } + + return nil +} + +// RunMajorMinorRelease creates the release branch and opens the main-branch version bump PR. +func RunMajorMinorRelease(cfg *ReleaseConfig) error { + fmt.Println("=== Starting Major/Minor Release Workflow ===") + + if err := cfg.Validate(); err != nil { + return err + } + if err := checkRequirements(cfg); err != nil { + return err + } + + repo, err := OpenRepo(".") + if err != nil { + return err + } + + releaseBranch := cfg.ReleaseBranch + bumpBranch := bumpVersionBranchName(cfg.NextProjectMinorVersion) + + fmt.Printf("Creating release branch: %s from %s\n", releaseBranch, cfg.BaseBranch) + if err := repo.EnsureBranchFrom(cfg.BaseBranch, releaseBranch); err != nil { + return err + } + if err := UpdateVersion(cfg.CurrentRelease); err != nil { + return err + } + if _, err := repo.CommitAll("[Release] update version", cfg.GitAuthorName, cfg.GitAuthorEmail); err != nil { + return err + } + + fmt.Printf("\n--- Creating PR: Bump main to %s ---\n", cfg.NextProjectMinorVersion) + if err := repo.EnsureBranchFrom(cfg.BaseBranch, bumpBranch); err != nil { + return err + } + if err := UpdateVersion(cfg.NextProjectMinorVersion); err != nil { + return err + } + bumpCommitMsg := fmt.Sprintf("Bump version to %s", cfg.NextProjectMinorVersion) + if _, err := repo.CommitAll(bumpCommitMsg, cfg.GitAuthorName, cfg.GitAuthorEmail); err != nil { + return err + } + + bumpPROpts := PROptions{ + Owner: cfg.ProjectOwner, + Repo: cfg.ProjectRepo, + Title: fmt.Sprintf("Bump the version on main to %s", cfg.NextProjectMinorVersion), + Head: bumpBranch, + Base: cfg.BaseBranch, + Body: bumpMainPRBody(cfg.NextProjectMinorVersion), + Reviewers: cfg.ProjectReviewers, + Labels: bumpMainPRLabels, + } + + if cfg.DryRun { + fmt.Println("\nDRY RUN: Skipping push and PR creation") + fmt.Printf("Release branch prepared: %s\n", releaseBranch) + fmt.Printf("Bump branch prepared: %s\n", bumpBranch) + fmt.Println("Review changes with 'git diff'") + return nil + } + + if err := repo.CheckoutBranch(releaseBranch); err != nil { + return err + } + if err := repo.Push("origin"); err != nil { + return err + } + + gh := NewGitHubClient(cfg.GitHubToken) + bumpPR, err := finalizePR(repo, gh, bumpBranch, cfg.BaseBranch, bumpPROpts) + if err != nil { + return err + } + + fmt.Printf("\n=== Major/Minor Release Workflow Complete ===\n") + fmt.Printf("Release branch pushed: %s\n", releaseBranch) + if bumpPR != nil { + fmt.Printf("Bump main PR: %s\n", bumpPR.GetHTMLURL()) + } else { + fmt.Println("Bump main PR: not created (already up to date)") + } + fmt.Println("\nRun 'mage release:runNextRelease' to open next-release and backport PRs") + + return nil +} + +// RunNextRelease opens PRs for the next patch version and mergify backport rule. +func RunNextRelease(cfg *ReleaseConfig) error { + fmt.Println("=== Starting Next Release Workflow ===") + + if err := cfg.Validate(); err != nil { + return err + } + if err := checkRequirements(cfg); err != nil { + return err + } + + repo, err := OpenRepo(".") + if err != nil { + return err + } + + releaseBranch := cfg.ReleaseBranch + nextVersionBranch := nextVersionBranchName(cfg.NextRelease) + backportBranch := backportNextBranchName(cfg.NextProjectMinorVersion) + backportLabel := fmt.Sprintf("backport-%s", cfg.ReleaseBranch) + + fmt.Printf("Using release branch: %s\n", releaseBranch) + + fmt.Printf("\n--- Creating PR 1: Update version to %s ---\n", cfg.NextRelease) + if err := repo.EnsureBranchFrom(releaseBranch, nextVersionBranch); err != nil { + return err + } + if err := UpdateVersion(cfg.NextRelease); err != nil { + return err + } + nextCommitMsg := fmt.Sprintf("[Release] Update version to %s", cfg.NextRelease) + if _, err := repo.CommitAll(nextCommitMsg, cfg.GitAuthorName, cfg.GitAuthorEmail); err != nil { + return err + } + + fmt.Printf("\n--- Creating PR 2: Add backport rule for %s ---\n", cfg.ReleaseBranch) + if err := repo.EnsureBranchFrom(cfg.BaseBranch, backportBranch); err != nil { + return err + } + if err := UpdateMergify(cfg.CurrentRelease); err != nil { + return err + } + if _, err := repo.CommitAll("[Release] add-backport-next", cfg.GitAuthorName, cfg.GitAuthorEmail); err != nil { + return err + } + + nextPROpts := PROptions{ + Owner: cfg.ProjectOwner, + Repo: cfg.ProjectRepo, + Title: fmt.Sprintf("[Release] Update version to %s", cfg.NextRelease), + Head: nextVersionBranch, + Base: releaseBranch, + Body: nextReleasePRBody(cfg.NextRelease, cfg.CurrentRelease), + Reviewers: cfg.ProjectReviewers, + Labels: nextReleasePRLabels, + } + + backportLabels := append([]string(nil), backportNextPRLabels...) + backportLabels = append(backportLabels, backportLabel) + + backportPROpts := PROptions{ + Owner: cfg.ProjectOwner, + Repo: cfg.ProjectRepo, + Title: fmt.Sprintf("backport: Add %s branch", cfg.ReleaseBranch), + Head: backportBranch, + Base: cfg.BaseBranch, + Body: backportNextPRBody(cfg.ReleaseBranch), + Reviewers: cfg.ProjectReviewers, + Labels: backportLabels, + } + + if cfg.DryRun { + fmt.Println("\nDRY RUN: Skipping push and PR creation") + fmt.Printf("Next version branch prepared: %s\n", nextVersionBranch) + fmt.Printf("Backport branch prepared: %s\n", backportBranch) + fmt.Println("Review changes with 'git diff'") + return nil + } + + gh := NewGitHubClient(cfg.GitHubToken) + + backportPR, err := finalizePR(repo, gh, backportBranch, cfg.BaseBranch, backportPROpts) + if err != nil { + return err + } + + nextPR, err := finalizePR(repo, gh, nextVersionBranch, releaseBranch, nextPROpts) + if err != nil { + return err + } + + fmt.Printf("\n=== Next Release Workflow Complete ===\n") + if backportPR != nil { + fmt.Printf("Backport PR: %s\n", backportPR.GetHTMLURL()) + } else { + fmt.Println("Backport PR: not created (already up to date)") + } + if nextPR != nil { + fmt.Printf("Next version PR: %s\n", nextPR.GetHTMLURL()) + } else { + fmt.Println("Next version PR: not created (already up to date)") + } + + return nil +} + +// RunPatchRelease opens a version bump PR into the release branch. +func RunPatchRelease(cfg *ReleaseConfig) error { + fmt.Println("=== Starting Patch Release Workflow ===") + + if err := cfg.Validate(); err != nil { + return err + } + if err := checkRequirements(cfg); err != nil { + return err + } + + repo, err := OpenRepo(".") + if err != nil { + return err + } + + releaseBranch := cfg.ReleaseBranch + if releaseBranch == "" { + releaseBranch = inferReleaseBranch(cfg.CurrentRelease) + } + + patchBranch := patchDocsBranchName(cfg.CurrentRelease) + fmt.Printf("Using release branch: %s\n", releaseBranch) + fmt.Printf("\n--- Creating PR: Patch version %s ---\n", cfg.CurrentRelease) + + if err := repo.EnsureBranchFrom(releaseBranch, patchBranch); err != nil { + return err + } + if err := UpdateVersion(cfg.CurrentRelease); err != nil { + return err + } + if _, err := repo.CommitAll("[Release] update version", cfg.GitAuthorName, cfg.GitAuthorEmail); err != nil { + return err + } + + patchPROpts := PROptions{ + Owner: cfg.ProjectOwner, + Repo: cfg.ProjectRepo, + Title: fmt.Sprintf("docs: update docs versions %s", cfg.CurrentRelease), + Head: patchBranch, + Base: releaseBranch, + Body: patchReleasePRBody(cfg.CurrentRelease), + Reviewers: cfg.ProjectReviewers, + Labels: patchReleasePRLabels, + } + + if cfg.DryRun { + fmt.Println("\nDRY RUN: Skipping push and PR creation") + fmt.Printf("Patch branch prepared: %s\n", patchBranch) + fmt.Println("Review changes with 'git diff'") + return nil + } + + gh := NewGitHubClient(cfg.GitHubToken) + patchPR, err := finalizePR(repo, gh, patchBranch, releaseBranch, patchPROpts) + if err != nil { + return err + } + + fmt.Printf("\n=== Patch Release Workflow Complete ===\n") + if patchPR != nil { + fmt.Printf("Patch PR: %s\n", patchPR.GetHTMLURL()) + } else { + fmt.Println("Patch PR: not created (already up to date)") + } + + return nil +} + +func bumpVersionBranchName(nextMinorVersion string) string { + return fmt.Sprintf("bump-version-%s", nextMinorVersion) +} + +func nextVersionBranchName(nextRelease string) string { + return fmt.Sprintf("update-version-next-%s", nextRelease) +} + +func backportNextBranchName(nextProjectMinorVersion string) string { + return fmt.Sprintf("add-backport-next-%s", nextProjectMinorVersion) +} + +func patchDocsBranchName(version string) string { + return fmt.Sprintf("update-docs-version-%s", version) +} + +func bumpMainPRBody(nextMinorVersion string) string { + return fmt.Sprintf("Bump the version on main to %s.", nextMinorVersion) +} + +func nextReleasePRBody(nextRelease, currentRelease string) string { + return fmt.Sprintf(`Updates references to the new release %s. + +Merge after the release %s. +`, nextRelease, currentRelease) +} + +func backportNextPRBody(releaseBranch string) string { + return fmt.Sprintf(`Merge as soon as %s branch was created. + +Auto-merge is not yet supported, see https://github.com/Mergifyio/mergify-engine/discussions/2821 +`, releaseBranch) +} + +func patchReleasePRBody(version string) string { + return fmt.Sprintf(`Updates docs versions to %s. + +Merge before the final Release build. +`, version) +} + +func finalizePR(repo *GitRepo, gh *GitHubClient, branchName, baseBranch string, opts PROptions) (*github.PullRequest, error) { + if err := repo.CheckoutBranch(branchName); err != nil { + return nil, err + } + + existingPR, found, err := gh.FindOpenPR(opts.Owner, opts.Repo, opts.Head, opts.Base) + if err != nil { + return nil, err + } + if found { + gh.ensurePRLabels(opts.Owner, opts.Repo, existingPR.GetNumber(), opts.Labels) + fmt.Printf("Open PR already exists #%d: %s\n", existingPR.GetNumber(), existingPR.GetHTMLURL()) + return existingPR, nil + } + + ahead, err := repo.HasCommitsAheadOf(baseBranch) + if err != nil { + return nil, err + } + if !ahead { + fmt.Printf("No new commits on %s compared to %s; skipping push and PR creation\n", branchName, baseBranch) + return nil, nil + } + + if err := repo.Push("origin"); err != nil { + return nil, err + } + + return gh.CreatePR(opts) +} diff --git a/go.mod b/go.mod index 8194052df3..0c5b89ccca 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( github.com/elastic/elastic-agent-client/v7 v7.18.1 github.com/elastic/elastic-agent-libs v0.46.0 github.com/elastic/elastic-agent-system-metrics v0.14.4 + github.com/elastic/fleet-server/dev-tools v0.0.0 github.com/elastic/go-elasticsearch/v8 v8.19.6 github.com/elastic/go-ucfg v0.9.1 github.com/fxamacker/cbor/v2 v2.9.2 @@ -48,11 +49,15 @@ require ( ) require ( + dario.cat/mergo v1.0.0 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect + github.com/ProtonMail/go-crypto v1.0.0 // indirect github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect github.com/armon/go-radix v1.0.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/cloudflare/circl v1.3.7 // indirect + github.com/cyphar/filepath-securejoin v0.2.5 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/elastic/elastic-transport-go/v8 v8.9.0 // indirect @@ -60,31 +65,44 @@ require ( github.com/elastic/go-sysinfo v1.15.1 // indirect github.com/elastic/go-windows v1.0.2 // indirect github.com/elastic/gosigar v0.14.3 // indirect + github.com/emirpasic/gods v1.18.1 // indirect github.com/fatih/color v1.15.0 // indirect + github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect + github.com/go-git/go-billy/v5 v5.5.0 // indirect + github.com/go-git/go-git/v5 v5.12.0 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/google/go-github/v68 v68.0.0 // indirect + github.com/google/go-querystring v1.1.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/josharian/intern v1.0.0 // indirect + github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/prometheus/client_model v0.6.2 // indirect github.com/prometheus/common v0.66.1 // indirect github.com/prometheus/procfs v0.16.1 // indirect + github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect github.com/shirou/gopsutil/v4 v4.24.7 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect + github.com/skeema/knownhosts v1.2.2 // indirect github.com/spf13/pflag v1.0.9 // indirect github.com/stretchr/objx v0.5.2 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/x448/float16 v0.8.4 // indirect + github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect go.elastic.co/ecszap v1.0.3 // indirect @@ -98,6 +116,9 @@ require ( golang.org/x/sys v0.47.0 // indirect golang.org/x/text v0.40.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 // indirect + gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect howett.net/plist v1.0.1 // indirect ) + +replace github.com/elastic/fleet-server/dev-tools => ./dev-tools diff --git a/go.sum b/go.sum index b0ba129255..94a4295590 100644 --- a/go.sum +++ b/go.sum @@ -1,25 +1,40 @@ +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Pallinder/go-randomdata v1.2.0 h1:DZ41wBchNRb/0GfsePLiSwb0PHZmT67XY00lCDlaYPg= github.com/Pallinder/go-randomdata v1.2.0/go.mod h1:yHmJgulpD2Nfrm0cR9tI/+oAgRqCQQixsA8HyRZfV9Y= +github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78= +github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= +github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= +github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= +github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= +github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= +github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI= github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE= github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= +github.com/cyphar/filepath-securejoin v0.2.5 h1:6iR5tXJ/e6tJZzzdMc1km3Sa7RRIVBKAK32O2s7AYfo= +github.com/cyphar/filepath-securejoin v0.2.5/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -55,14 +70,28 @@ github.com/elastic/go-windows v1.0.2 h1:yoLLsAsV5cfg9FLhZ9EXZ2n2sQFKeDYrHenkcivY github.com/elastic/go-windows v1.0.2/go.mod h1:bGcDpBzXgYSqM0Gx3DM4+UxFj300SZLixie9u9ixLM8= github.com/elastic/gosigar v0.14.3 h1:xwkKwPia+hSfg9GqrCUKYdId102m9qTJIIr7egmK/uo= github.com/elastic/gosigar v0.14.3/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= +github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU= +github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fxamacker/cbor/v2 v2.9.2 h1:X4Ksno9+x3cz0TZv69ec1hxP/+tymuR8PXQJyDwfh78= github.com/fxamacker/cbor/v2 v2.9.2/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= +github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE= +github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8= github.com/go-chi/chi/v5 v5.3.0 h1:halUjDxhshgXHMrao5bB8eNBXo/rnzwr8m5m36glehM= github.com/go-chi/chi/v5 v5.3.0/go.mod h1:R+tYY2hNuVUUjxoPtqUdgBqevM9s9njzkTLutVsOCto= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= +github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= +github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= +github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= +github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= +github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= +github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -74,11 +103,18 @@ github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/uuid/v5 v5.4.0 h1:EfbpCTjqMuGyq5ZJwxqzn3Cbr2d0rUZU7v5ycAk/e/0= github.com/gofrs/uuid/v5 v5.4.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/go-github/v68 v68.0.0 h1:ZW57zeNZiXTdQ16qrDiZ0k6XucrxZ2CGmoTvcCyQG6s= +github.com/google/go-github/v68 v68.0.0/go.mod h1:K9HAUBovM2sLwM408A18h+wd9vqdLOEqTUCbnRIcx68= +github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= +github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/pprof v0.0.0-20230426061923-93006964c1fc h1:AGDHt781oIcL4EFk7cPnvBUYTwU8BEU6GDTO3ZMn1sE= github.com/google/pprof v0.0.0-20230426061923-93006964c1fc/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -93,14 +129,21 @@ github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE= +github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= +github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= @@ -134,6 +177,8 @@ github.com/oapi-codegen/nullable v1.1.0 h1:eAh8JVc5430VtYVnq00Hrbpag9PFRGWLjxR1/ github.com/oapi-codegen/nullable v1.1.0/go.mod h1:KUZ3vUzkmEKY90ksAmit2+5juDIhIZhfDl+0PwOQlFY= github.com/oapi-codegen/runtime v1.4.2 h1:GMxFVYLzoYLua+/KvzgSphkyK1lLTReQI9Vf4hvATKE= github.com/oapi-codegen/runtime v1.4.2/go.mod h1:GwV7hC2hviaMzj+ITfHVRESK5J2W/GefVwIND/bMGvU= +github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= +github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/open-telemetry/opamp-go v0.23.0 h1:k7h7w/muprut9/DAhUC4anX4v7hIdgO02gIsSjV4uq0= github.com/open-telemetry/opamp-go v0.23.0/go.mod h1:DIIVdkLefdqPW5L+4I2twmAicVrTB0Bp5XJAfedZzAM= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= @@ -142,6 +187,8 @@ github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJw github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0= github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y= +github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= +github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -165,12 +212,17 @@ github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWR github.com/rs/zerolog v1.35.1 h1:m7xQeoiLIiV0BCEY4Hs+j2NG4Gp2o2KPKmhnnLiazKI= github.com/rs/zerolog v1.35.1/go.mod h1:EjML9kdfa/RMA7h/6z6pYmq1ykOuA8/mjWaEvGI+jcw= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/shirou/gopsutil/v4 v4.24.7 h1:V9UGTK4gQ8HvcnPKf6Zt3XHyQq/peaekfxpJ2HSocJk= github.com/shirou/gopsutil/v4 v4.24.7/go.mod h1:0uW/073rP7FYLOkvxolUQM5rMOLTNmRXnFKafpb71rw= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= +github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A= +github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY= @@ -179,6 +231,7 @@ github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKk github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -190,8 +243,11 @@ github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+F github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= +github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= +github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.elastic.co/apm/module/apmchiv5/v2 v2.7.12 h1:X8UdMuAw5B44Mg497Wiwbm57HSiYOVNeXDEX8qh84lU= @@ -243,10 +299,22 @@ golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU= golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= golang.org/x/sys v0.0.0-20180810173357-98c5dad5d1a0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -257,23 +325,10 @@ golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs= golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY= golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= -golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4= -gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 h1:RmoJA1ujG+/lRGNfUnOMfhCy5EipVMyvUE+KNbPbTlw= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= -google.golang.org/grpc v1.82.0 h1:vguDnZUPjE26w09A63VoxZPnvPjB5Riyc0mkXPFmAIU= -google.golang.org/grpc v1.82.0/go.mod h1:yzTZ1TB1Z3SG+LIYaI+WiE8D5+PZ3ArnrSp8zF3+/ZA= -google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= -google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/mcuadros/go-syslog.v2 v2.3.0 h1:kcsiS+WsTKyIEPABJBJtoG0KkOS6yzvJ+/eZlhD79kk= gopkg.in/mcuadros/go-syslog.v2 v2.3.0/go.mod h1:l5LPIyOOyIdQquNg+oU6Z3524YwrcqEm0aKH+5zpt2U= +gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/magefile.go b/magefile.go index 02c5f7a2fc..a013cd8a1f 100644 --- a/magefile.go +++ b/magefile.go @@ -46,6 +46,7 @@ import ( "github.com/elastic/elastic-agent-libs/logp" "github.com/elastic/elastic-agent-libs/transport/tlscommon" + "github.com/elastic/fleet-server/dev-tools/mage/release" "github.com/elastic/fleet-server/v7/version" ) @@ -356,6 +357,9 @@ type Test mg.Namespace // Docker is the namespace for docker related tasks. type Docker mg.Namespace +// Release is the namespace for release automation. +type Release mg.Namespace + // envToBool reads the env var string s and parses it as a bool. func envToBool(s string) bool { v, ok := os.LookupEnv(s) @@ -2294,3 +2298,40 @@ func (Test) CloudE2ERun() error { err = errors.Join(err, os.WriteFile(filepath.Join("build", "test-cloude2e.out"), b.Bytes(), 0o644)) return err } + +// UpdateVersion updates the version in version/version.go. +func (Release) UpdateVersion(version string) error { + return release.UpdateVersion(version) +} + +// UpdateMergify adds a new backport rule to .mergify.yml. +func (Release) UpdateMergify(version string) error { + return release.UpdateMergify(version) +} + +// RunMajorMinor orchestrates the major/minor release workflow after feature freeze. +func (Release) RunMajorMinor() error { + cfg, err := release.LoadConfigFromEnv() + if err != nil { + return err + } + return release.RunMajorMinorRelease(cfg) +} + +// RunNextRelease opens next-release and backport PRs onto the release branch. +func (Release) RunNextRelease() error { + cfg, err := release.LoadConfigFromEnv() + if err != nil { + return err + } + return release.RunNextRelease(cfg) +} + +// RunPatch orchestrates the complete patch release workflow. +func (Release) RunPatch() error { + cfg, err := release.LoadConfigFromEnv() + if err != nil { + return err + } + return release.RunPatchRelease(cfg) +}