Skip to content

Commit

Permalink
feat: new release process
Browse files Browse the repository at this point in the history
Signed-off-by: Adrien Mannocci <[email protected]>
  • Loading branch information
amannocci committed Jan 29, 2024
1 parent beeba37 commit 33fd62e
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 21 deletions.
11 changes: 5 additions & 6 deletions .ci/release.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
## This script runs the release given the different environment variables
## branch_specifier
## ref
## dry_run
##
## It relies on the .buildkite/hooks/pre-command so the Vault and other tooling
Expand All @@ -19,7 +19,7 @@ clean_up () {
trap clean_up EXIT

# Avoid detached HEAD since the release plugin requires to be on a branch
git checkout -f "${branch_specifier}"
git checkout -f "${ref}"

echo "--- Debug JDK installation :coffee:"
echo $JAVA_HOME
Expand All @@ -28,9 +28,8 @@ java -version

set +x
echo "--- Release the binaries to Maven Central :maven:"
if [[ "$dry_run" == "true" ]] ; then
echo './mvnw -V release:prepare release:perform --settings .ci/settings.xml --batch-mode'
if [[ "${dry_run}" == "true" ]] ; then
echo './mvnw -V -s .ci/settings.xml -Pgpg clean deploy --batch-mode'
else
# providing settings in arguments to make sure they are propagated to the forked maven release process
./mvnw -V release:prepare release:perform --settings .ci/settings.xml -Darguments="--settings .ci/settings.xml" --batch-mode | tee release.txt
./mvnw -V -s .ci/settings.xml -Pgpg clean deploy --batch-mode | tee release.txt
fi
70 changes: 70 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
name: Prepare Release

on:
workflow_dispatch:
inputs:
ref:
description: 'Branch or tag ref to run the workflow on'
required: true
default: 'main'
version:
description: 'The version to release (e.g. 1.2.3). This workflow will automatically perform the required version bumps'
required: true

env:
JAVA_VERSION: 17
JAVA_DIST: temurin
RELEASE_VERSION: ${{ inputs.version }}

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}

jobs:
create_pr:
name: "Bump versions and create PR"
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: elastic/apm-pipeline-library/.github/actions/github-token@current
with:
url: ${{ secrets.VAULT_ADDR }}
roleId: ${{ secrets.VAULT_ROLE_ID }}
secretId: ${{ secrets.VAULT_SECRET_ID }}

- uses: elastic/apm-pipeline-library/.github/actions/setup-git@current
with:
username: ${{ env.GIT_USER }}
email: ${{ env.GIT_EMAIL }}
token: ${{ env.GITHUB_TOKEN }}

- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || 'main' }}
token: ${{ env.GITHUB_TOKEN }}

- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v3
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DIST }}
cache: 'maven'

- name: Create a prepare release branch
run: git checkout -b prepare-release-v${{ env.RELEASE_VERSION }}

- name: Bump versions
run: |
./mvnw -V versions:set -DprocessAllModules=true -DgenerateBackupPoms=false -DnewVersion=${{ env.RELEASE_VERSION }}
git add --all
git commit -m "release: ecs-logging-java v${{ env.RELEASE_VERSION }}"
- name: Push the prepare release branch
run: git push origin prepare-release-v${{ env.RELEASE_VERSION }}

- name: Create the prepare release PR
run: gh pr create --title="Prepare Release Version v${{ env.RELEASE_VERSION }}" --base main --head prepare-release-v${{ env.RELEASE_VERSION }} -b "New Release v${{ env.RELEASE_VERSION }}"
74 changes: 66 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
---
name: release
name: Release

permissions:
contents: read

on:
workflow_dispatch:
inputs:
branch_specifier:
description: The branch to release ex. main or 0.6.
ref:
description: 'Branch or tag ref to run the workflow on'
required: true
default: "main"
type: string

version:
description: 'The version to release (e.g. 1.2.3). This workflow will automatically perform the required version bumps'
required: true
dry_run:
description: If set, run a dry-run release
default: false
type: boolean

env:
JAVA_VERSION: 17
JAVA_DIST: temurin
RELEASE_VERSION: ${{ inputs.version }}

jobs:
release:
name: Release
runs-on: ubuntu-latest

steps:
- id: buildkite
name: Run Release
Expand All @@ -32,10 +37,10 @@ jobs:
vaultRoleId: ${{ secrets.VAULT_ROLE_ID }}
vaultSecretId: ${{ secrets.VAULT_SECRET_ID }}
pipeline: ecs-logging-java-release
waitFor: false
waitFor: true
printBuildLogs: false
buildEnvVars: |
branch_specifier=${{ inputs.branch_specifier || 'main' }}
ref=${{ inputs.ref || 'main' }}
dry_run=${{ inputs.dry_run || 'false' }}
- if: ${{ success() }}
Expand All @@ -58,3 +63,56 @@ jobs:
message: |
:ghost: [${{ github.repository }}] Release *${{ github.ref_name }}* didn't get triggered in Buildkite.
Build: (<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|here>)
post-release:
name: "Bump versions and create PR"
runs-on: ubuntu-latest
needs:
- release
permissions:
contents: write
steps:
- uses: elastic/apm-pipeline-library/.github/actions/github-token@current
with:
url: ${{ secrets.VAULT_ADDR }}
roleId: ${{ secrets.VAULT_ROLE_ID }}
secretId: ${{ secrets.VAULT_SECRET_ID }}

- uses: elastic/apm-pipeline-library/.github/actions/setup-git@current
with:
username: ${{ env.GIT_USER }}
email: ${{ env.GIT_EMAIL }}
token: ${{ env.GITHUB_TOKEN }}

- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || 'main' }}
token: ${{ env.GITHUB_TOKEN }}

- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v3
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DIST }}
cache: 'maven'

- name: Create the release tag
run: |
git tag "v${{ env.RELEASE_VERSION }}"
git push origin "v${{ env.RELEASE_VERSION }}"
- name: Create a post release branch
run: |
git checkout -b "post-release-v${{ env.RELEASE_VERSION }}"
- name: Bump versions
run: |
./mvnw -V versions:set -DprocessAllModules=true -DgenerateBackupPoms=false -nextSnapshot=true
git add --all
git commit -m "chore: prepare for next iteration"
- name: Push the post release branch
run: git push origin "post-release-v${{ env.RELEASE_VERSION }}"

- name: Create the post release PR
run: gh pr create --title="Post release process" --base main --head "post-release-v${{ env.RELEASE_VERSION }}" -b "Prepare for next iteration"
10 changes: 3 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,9 @@
<build>
<plugins>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>gpg</releaseProfiles>
<autoVersionSubmodules>true</autoVersionSubmodules>
<tagNameFormat>v@{project.version}</tagNameFormat>
</configuration>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.16.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
Expand Down

0 comments on commit 33fd62e

Please sign in to comment.