Skip to content

Commit 61c4543

Browse files
committed
feat: new release process with PRs
Signed-off-by: Adrien Mannocci <adrien.mannocci@elastic.co>
1 parent 3b22aad commit 61c4543

12 files changed

+299
-178
lines changed

.ci/release/post-release.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
# Bash strict mode
4+
set -euo pipefail
5+
6+
# Found current script directory
7+
RELATIVE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8+
9+
# Found project directory
10+
BASE_PROJECT="$(dirname $(dirname "${RELATIVE_DIR}"))"
11+
12+
# Import dependencies
13+
source "${RELATIVE_DIR}/util.sh"
14+
15+
# Constants
16+
BASE_URL="https://repo1.maven.org/maven2/co/elastic/apm/elastic-apm-agent"
17+
CF_FILE="${BASE_PROJECT}/cloudfoundry/index.yml"
18+
19+
# Requirements
20+
check_version "${RELEASE_VERSION}"
21+
22+
echo "Set next snapshot version"
23+
./mvnw -V versions:set -DprocessAllModules=true -DgenerateBackupPoms=false -DnextSnapshot=true
24+
25+
# make script idempotent if release is already in CF descriptor
26+
set +e
27+
grep -e "^${RELEASE_VERSION}:" ${CF_FILE}
28+
[[ $? == 0 ]] && exit 0
29+
set -e
30+
echo "Update cloudfoundry version"
31+
echo "${RELEASE_VERSION}: ${BASE_URL}/${RELEASE_VERSION}/elastic-apm-agent-${RELEASE_VERSION}.jar" >> "${CF_FILE}"

.ci/release/pre-release.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
# Bash strict mode
4+
set -euo pipefail
5+
6+
# Found current script directory
7+
RELATIVE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8+
9+
# Found project directory
10+
BASE_PROJECT="$(dirname $(dirname "${RELATIVE_DIR}"))"
11+
12+
# Import dependencies
13+
source "${RELATIVE_DIR}/util.sh"
14+
15+
# Requirements
16+
check_version "${RELEASE_VERSION}"
17+
18+
echo "Set release version"
19+
./mvnw -V versions:set -DprocessAllModules=true -DgenerateBackupPoms=false -DnewVersion="${RELEASE_VERSION}"
20+
21+
echo "Prepare changelog for release"
22+
java "${BASE_PROJECT}/.ci/ReleaseChangelog.java" CHANGELOG.asciidoc "${RELEASE_VERSION}"

.ci/release/update_major_branch.sh renamed to .ci/release/update-major-branch.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,10 @@ git checkout --force ${checkout_options}
6262

6363
echo -e "\n--- move local branch ${major_branch} to match tag ${tag}"
6464
git reset --hard ${tag}
65+
66+
echo -e "\n--- create new branch with updates"
67+
git checkout -b "update-major-${v}"
68+
git push origin "update-major-${v}"
69+
70+
echo -e "\n--- create PR to update major branch"
71+
gh pr create --title="post release v${v}: update major branch" --base "${major_branch}" --head "update-major-${v}" -b "post release v${v}"

.ci/release/update_cloudfoundry.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.

.ci/release/util.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
check_version() {
44
v=${1:-}
55

6-
if [[ "${v}" == "" ]]; then
7-
echo "usage $0 <version>" # here $0 will be the calling script
8-
echo "where <version> in format '1.2.3'"
6+
if [ -z "${v}" ]; then
7+
>&2 echo "The environment variable 'RELEASE_VERSION' isn't defined"
98
exit 1
109
fi
11-
12-
if [[ ! "$v" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
13-
echo "invalid version format '${v}'"
10+
if [[ ! "${v}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
11+
echo "The environment variable 'RELEASE_VERSION' should respect SemVer format"
1412
exit 1
1513
fi
1614
}

.ci/release/wait_maven_artifact_published.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
3+
name: Pre/Post Release
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
ref:
9+
description: 'Branch or tag ref to run the workflow on'
10+
type: string
11+
required: true
12+
default: 'main'
13+
version:
14+
description: 'The version to release (e.g. 1.2.3). This workflow will automatically perform the required version bumps'
15+
type: string
16+
required: true
17+
phase:
18+
description: 'Pre or post release phase'
19+
type: string # valid values are 'pre' or 'post'
20+
required: true
21+
22+
env:
23+
RELEASE_VERSION: ${{ inputs.version }}
24+
BRANCH_NAME: ${{ inputs.phase }}-release-v${{ inputs.version }}
25+
26+
permissions:
27+
contents: read
28+
29+
jobs:
30+
validate-tag:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
- name: Validate release tag does not exist in repo
38+
uses: ./.github/workflows/validate-tag
39+
with:
40+
tag: v${{ env.RELEASE_VERSION }}
41+
42+
create-pr:
43+
name: "Bump versions and create PR"
44+
runs-on: ubuntu-latest
45+
needs:
46+
- validate-tag
47+
permissions:
48+
contents: write
49+
steps:
50+
- uses: elastic/apm-pipeline-library/.github/actions/github-token@current
51+
with:
52+
url: ${{ secrets.VAULT_ADDR }}
53+
roleId: ${{ secrets.VAULT_ROLE_ID }}
54+
secretId: ${{ secrets.VAULT_SECRET_ID }}
55+
56+
- uses: elastic/apm-pipeline-library/.github/actions/setup-git@current
57+
with:
58+
username: ${{ env.GIT_USER }}
59+
email: ${{ env.GIT_EMAIL }}
60+
token: ${{ env.GITHUB_TOKEN }}
61+
62+
- uses: actions/checkout@v4
63+
with:
64+
ref: ${{ inputs.ref }}
65+
token: ${{ env.GITHUB_TOKEN }}
66+
67+
- name: Create the release tag (post phase)
68+
if: inputs.phase == 'post'
69+
run: |
70+
git tag "v${{ env.RELEASE_VERSION }}"
71+
git push origin "v${{ env.RELEASE_VERSION }}"
72+
73+
- name: Create a ${{ inputs.phase }} release branch
74+
run: git checkout -b ${{ env.BRANCH_NAME }}
75+
76+
- name: Perform pre release changes
77+
if: inputs.phase == 'pre'
78+
uses: ./.github/workflows/maven-goal-jdk
79+
with:
80+
command: ./.ci/release/pre-release.sh
81+
82+
- name: Perform post release changes
83+
if: inputs.phase == 'post'
84+
uses: ./.github/workflows/maven-goal
85+
with:
86+
command: ./.ci/release/post-release.sh
87+
88+
- name: Push the ${{ inputs.phase }} release branch
89+
run: |
90+
git add --all
91+
git commit -m "${{ inputs.phase }} release: elastic-apm-agent v${{ env.RELEASE_VERSION }}"
92+
git push origin ${{ env.BRANCH_NAME }}
93+
94+
- name: Create the ${{ inputs.phase }} release PR
95+
run: gh pr create --title="${{ inputs.phase }} release v${{ env.RELEASE_VERSION }}" --base main --head ${{ env.BRANCH_NAME }} -b "${{ inputs.phase }} release v${{ env.RELEASE_VERSION }}"
96+
env:
97+
GH_TOKEN: ${{ env.GITHUB_TOKEN }}

.github/workflows/pre-release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
3+
name: Pre release
4+
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
ref:
9+
description: 'Branch or tag ref to run the workflow on'
10+
required: true
11+
default: 'main'
12+
version:
13+
description: 'The version to release (e.g. 1.2.3). This workflow will automatically perform the required version bumps'
14+
required: true
15+
16+
permissions:
17+
contents: read
18+
19+
concurrency:
20+
group: ${{ github.workflow }}
21+
22+
jobs:
23+
pre-release:
24+
name: "Bump versions and create PR"
25+
uses: ./.github/workflows/pre-post-release.yml
26+
permissions:
27+
contents: write
28+
with:
29+
ref: ${{ inputs.ref }}
30+
version: ${{ inputs.version }}
31+
phase: 'pre'
32+
secrets: inherit

0 commit comments

Comments
 (0)