Skip to content

Commit 25e7389

Browse files
mergify[bot]v1v
andauthored
ci(major-release): support run major release [0-9]+.0.0 (#15329) (#15398)
(cherry picked from commit 5bab00e) Co-authored-by: Victor Martinez <[email protected]>
1 parent 31d9cc9 commit 25e7389

File tree

4 files changed

+164
-9
lines changed

4 files changed

+164
-9
lines changed

Diff for: .github/workflows/prepare-release/action.yml

+20
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ runs:
4949
VERSION: ${{ inputs.version }}
5050
shell: 'bash'
5151

52+
- name: validate version format (major only)
53+
if: ${{ inputs.type == 'major' && ! endsWith(inputs.version, '.0.0') }}
54+
run: |-
55+
FAILURE_MESSAGE='version is not a major one but a patch (only support for <major>.0.0)'
56+
echo "FAILURE_MESSAGE=${FAILURE_MESSAGE}" >> "$GITHUB_ENV"
57+
echo "::error::${FAILURE_MESSAGE}" ; exit 1
58+
shell: 'bash'
59+
5260
- name: validate version format (minor only)
5361
if: ${{ inputs.type == 'minor' && ! endsWith(inputs.version, '0') }}
5462
run: |-
@@ -65,6 +73,18 @@ runs:
6573
echo "::error::${FAILURE_MESSAGE}" ; exit 1
6674
shell: 'bash'
6775

76+
- name: validate if branch already exists (major only)
77+
if: ${{ inputs.type == 'major' }}
78+
run: |-
79+
if git ls-remote --exit-code --heads "https://github.com/${GITHUB_REPOSITORY}.git" "$BRANCH" > /dev/null ; then
80+
echo "FAILURE_MESSAGE=${FAILURE_MESSAGE}" >> "$GITHUB_ENV"
81+
echo "::error::${FAILURE_MESSAGE}" ; exit 1
82+
fi
83+
shell: 'bash'
84+
env:
85+
BRANCH: ${{ steps.generate.outputs.release-branch }}
86+
FAILURE_MESSAGE: Branch already exists. This is not a major release.
87+
6888
- name: validate if branch already exists (minor only)
6989
if: ${{ inputs.type == 'minor' }}
7090
run: |-

Diff for: .github/workflows/run-major-release.yml

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
name: run-major-release
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: 'The new version to be set, normally the version in the main branch (semver format: major.0.0)'
9+
required: true
10+
type: string
11+
12+
# Avoid concurrency so we can watch the releases correctly
13+
concurrency:
14+
group: ${{ github.workflow }}
15+
16+
permissions:
17+
contents: read
18+
19+
env:
20+
JOB_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
21+
SLACK_CHANNEL: "#apm-server"
22+
23+
jobs:
24+
prepare:
25+
runs-on: ubuntu-latest
26+
outputs:
27+
release-branch: ${{ steps.prepare.outputs.release-branch }}
28+
release-type: ${{ steps.prepare.outputs.release-type }}
29+
release-version: ${{ steps.prepare.outputs.release-version }}
30+
slack-thread: ${{ steps.prepare.outputs.slack-thread }}
31+
steps:
32+
- uses: actions/checkout@v4
33+
- id: prepare
34+
uses: ./.github/workflows/prepare-release
35+
with:
36+
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
37+
version: ${{ inputs.version }}
38+
type: 'major'
39+
40+
run-major:
41+
runs-on: ubuntu-latest
42+
needs: [ prepare ]
43+
env:
44+
RELEASE_BRANCH: ${{ needs.prepare.outputs.release-branch }}
45+
RELEASE_TYPE: ${{ needs.prepare.outputs.release-type }}
46+
RELEASE_VERSION: ${{ needs.prepare.outputs.release-version }}
47+
permissions:
48+
contents: write
49+
steps:
50+
51+
- uses: elastic/oblt-actions/slack/send@v1
52+
with:
53+
bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
54+
channel-id: ${{ env.SLACK_CHANNEL }}
55+
message: |-
56+
Feature freeze for `${{ github.repository }}@${{ env.RELEASE_VERSION }}` just started.
57+
The `${{ github.repository }}@${{ env.RELEASE_BRANCH }}` branch will be created Today.
58+
thread-timestamp: ${{ needs.prepare.outputs.slack-thread || '' }}
59+
60+
- name: Get token
61+
id: get_token
62+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
63+
with:
64+
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
65+
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
66+
permissions: >-
67+
{
68+
"contents": "write",
69+
"pull_requests": "write"
70+
}
71+
72+
- uses: actions/checkout@v4
73+
with:
74+
# 0 indicates all history for all branches and tags.
75+
fetch-depth: 0
76+
77+
# Required to use a service account, otherwise PRs created by
78+
# GitHub bot won't trigger any CI builds.
79+
# See https://github.com/peter-evans/create-pull-request/issues/48#issuecomment-537478081
80+
- name: Configure git user
81+
uses: elastic/oblt-actions/git/setup@v1
82+
with:
83+
github-token: ${{ steps.get_token.outputs.token }}
84+
85+
- name: Import GPG key
86+
uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0
87+
with:
88+
gpg_private_key: ${{ secrets.APM_SERVER_RELEASE_GPG_PRIVATE_KEY }}
89+
passphrase: ${{ secrets.APM_SERVER_RELEASE_PASSPHRASE }}
90+
git_user_signingkey: true
91+
git_commit_gpgsign: true
92+
93+
- run: make major-release
94+
env:
95+
GH_TOKEN: ${{ steps.get_token.outputs.token }}
96+
97+
- if: success()
98+
uses: elastic/oblt-actions/slack/send@v1
99+
with:
100+
bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
101+
channel-id: ${{ env.SLACK_CHANNEL }}
102+
message: |-
103+
`${{ github.repository }}@${{ env.RELEASE_BRANCH }}` is now available.
104+
The docs and other references are updated. You can start using it.
105+
thread-timestamp: ${{ needs.prepare.outputs.slack-thread || '' }}
106+
107+
- if: failure()
108+
uses: elastic/oblt-actions/slack/send@v1
109+
with:
110+
bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
111+
channel-id: ${{ env.SLACK_CHANNEL }}
112+
message: |-
113+
:fire: Something went wrong with the release. See <${{ env.JOB_URL }}|logs>.
114+
thread-timestamp: ${{ needs.prepare.outputs.slack-thread || '' }}

Diff for: dev_docs/RELEASES.md

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ For patch releases, only the version on the existing major and minor version bra
2828
* The PR should be merged the day before release.
2929
* For **minor releases**: run the [`run-minor-release`](https://github.com/elastic/apm-server/actions/workflows/run-minor-release.yml) workflow (In "Use workflow from", select `main` branch. Then in "The version", specify the minor release version the release is for).
3030
This workflow will: create a new release branch using the stack version (X.Y); update the changelog for the release branch and open a PR targeting the release branch titled `<major>.<minor>: update docs`; create a PR on `main` titled `<major>.<minor>: update docs, mergify, versions and changelogs`. Before merging them compare commits between latest minor and the new minor versions and ensure all relevant PRs have been included in the Changelog. If not, amend it in both PRs. Request and wait a PR review from the team before merging. After it's merged add your PR to the documentation release issue in the [`elastic/dev`](https://github.com/elastic/dev/issues?q=is%3Aissue%20state%3Aopen%20label%3Adocs) repo ([Sample Issue](https://github.com/elastic/dev/issues/2895)).
31+
* For **major releases**: run the [`run-major-release`](https://github.com/elastic/apm-server/actions/workflows/run-major-release.yml) workflow (In "Use workflow from", select `main` branch. Then in "The version", specify the major release version the release is for).
32+
This workflow will: create a new release branch using the stack version (X.Y); update the changelog for the release branch and open a PR targeting the release branch titled `<major>.<minor>: update docs`; create a PR on `main` titled `<major>.0: update docs, mergify, versions and changelogs`. Before merging them compare commits between latest minor and the new major versions and ensure all relevant PRs have been included in the Changelog. If not, amend it in both PRs. Request and wait a PR review from the team before merging. After it's merged add your PR to the documentation release issue in the [`elastic/dev`](https://github.com/elastic/dev/issues?q=is%3Aissue%20state%3Aopen%20label%3Adocs) repo ([Sample Issue](https://github.com/elastic/dev/issues/2895)).
3133
* The Release Manager will ping the team to align the release process
3234

3335
* Update dependencies

Diff for: release.mk

+28-9
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,20 @@ ifeq ($(RELEASE_TYPE),minor)
5858
# NOTE: as long as 8.x is the branch to run releases, then we use base branch 8.x
5959
# when 8.x is not available then we use the main base branch.
6060
BASE_BRANCH ?= 8.x
61+
UPDATE_MERGIFY = true
6162
endif
6263

6364
ifeq ($(RELEASE_TYPE),patch)
6465
BASE_BRANCH ?= $(RELEASE_BRANCH)
6566
LATEST_RELEASE ?= $(RELEASE_BRANCH).$(shell expr $(PROJECT_PATCH_VERSION) - 1)
6667
endif
6768

69+
ifeq ($(RELEASE_TYPE),major)
70+
BASE_BRANCH ?= main
71+
CHANGELOG_BRANCH = main
72+
UPDATE_MERGIFY = true
73+
endif
74+
6875
#######################
6976
## Templates
7077
#######################
@@ -135,8 +142,10 @@ minor-release:
135142
$(MAKE) create-commit COMMIT_MESSAGE="docs: Update changelogs for $(RELEASE_BRANCH) release"
136143

137144
# NOTE: as long as 8.x is the branch to run releases, then we update mergify
138-
# when 8.x is not available then this conditional and the update-mergify should be removed..
139-
ifeq ($(BASE_BRANCH),8.x)
145+
# when 8.x is not available then this conditional and the update-mergify should be removed.
146+
# We use a specific PR for mergify, it used to be part of the `update-` PR but it was separated.
147+
# to support 8.x and main releases.
148+
ifeq ($(UPDATE_MERGIFY),true)
140149
@echo "INFO: Create feature branch for mergify changes. Target branch $(RELEASE_BRANCH)"
141150
$(MAKE) create-branch NAME=mergify-$(RELEASE_BRANCH) BASE=main
142151
$(MAKE) update-mergify VERSION=$(RELEASE_BRANCH)
@@ -146,26 +155,36 @@ endif
146155
@echo "INFO: Create feature branch and update the versions. Target branch $(BASE_BRANCH)"
147156
$(MAKE) create-branch NAME=update-$(RELEASE_VERSION) BASE=$(BASE_BRANCH)
148157
# NOTE: as long as main is the branch to run releases, then we update mergify
149-
# when 8.x is not available then this conditional should be removed and the update-mergify should be kept.
150-
ifeq ($(BASE_BRANCH),main)
151-
$(MAKE) update-mergify VERSION=$(RELEASE_BRANCH)
152-
endif
158+
# TODO: when 8.x is not available then this conditional should be removed and the update-mergify should be kept.
159+
#ifeq ($(BASE_BRANCH),main)
160+
# $(MAKE) update-mergify VERSION=$(RELEASE_BRANCH)
161+
#endif
153162
$(MAKE) update-version VERSION=$(NEXT_PROJECT_MINOR_VERSION)
154163
$(MAKE) create-commit COMMIT_MESSAGE="[Release] update version $(NEXT_PROJECT_MINOR_VERSION)"
155164
$(MAKE) rename-changelog VERSION=$(RELEASE_BRANCH)
156165
$(MAKE) create-commit COMMIT_MESSAGE="[Release] update changelogs for $(RELEASE_BRANCH) release"
157166

158167
@echo "INFO: Push changes to $(PROJECT_OWNER)/apm-server and create the relevant Pull Requests"
159168
git push origin $(RELEASE_BRANCH)
160-
# NOTE: as long as 8.x is the branch to run releases, then we update mergify
161-
# when 8.x is not available then this conditional and its content should be removed.
162-
ifeq ($(BASE_BRANCH),8.x)
169+
ifeq ($(UPDATE_MERGIFY),true)
163170
$(MAKE) create-pull-request BRANCH=mergify-$(RELEASE_BRANCH) TARGET_BRANCH=main TITLE="$(RELEASE_BRANCH): mergify" BODY="Merge as soon as the GitHub checks are green." BACKPORT_LABEL=backport-skip
164171
endif
165172
$(MAKE) create-pull-request BRANCH=update-$(RELEASE_VERSION) TARGET_BRANCH=$(BASE_BRANCH) TITLE="$(RELEASE_BRANCH): update docs, versions and changelogs" BODY="Merge as soon as the GitHub checks are green" BACKPORT_LABEL=backport-skip
166173
# NOTE: as long as 8.x is the branch to run releases, then we use main as target with the backport label.
167174
# when 8.x is not available then we use TARGET_BRANCH=$(RELEASE_BRANCH)
175+
ifeq ($(BASE_BRANCH),8.x)
176+
@echo "INFO: As long as 8.x is supported, we need to create a PR also in main"
168177
$(MAKE) create-pull-request BRANCH=changelog-$(RELEASE_BRANCH) TARGET_BRANCH=main TITLE="$(RELEASE_BRANCH): update docs" BODY="Merge as soon as $(TARGET_BRANCH) branch is created and the GitHub checks are green. And the PR in main for the Mergify changes has been merged." BACKPORT_LABEL=backport-$(RELEASE_BRANCH)
178+
endif
179+
180+
# This is the contract with the GitHub action .github/workflows/run-major-release.yml.
181+
# The GitHub action will provide the below environment variables:
182+
# - RELEASE_VERSION
183+
#
184+
.PHONY: major-release
185+
major-release:
186+
# NOTE: major release uses minor-release with BASE_BRANCH=main and CHANGELOG_BRANCH=main
187+
$(MAKE) minor-release
169188

170189
# This is the contract with the GitHub action .github/workflows/run-patch-release.yml
171190
# The GitHub action will provide the below environment variables:

0 commit comments

Comments
 (0)