Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new release process #226

Merged
merged 14 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions .ci/release.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
## This script runs the release given the different environment variables
## branch_specifier
## dry_run
## ref : git reference (commit,branch, tag, ...)
## dry_run : dry-run when set to 'true'
##
## It relies on the .buildkite/hooks/pre-command so the Vault and other tooling
## are prepared automatically by buildkite.
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
./mvnw -V -s .ci/settings.xml -Pgpg clean package --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
4 changes: 2 additions & 2 deletions .ci/snapshot.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
## This script runs the snapshot given the different environment variables
## dry_run
## dry_run : dry-run when set to 'true'
##
## It relies on the .buildkite/hooks/pre-command so the Vault and other tooling
## are prepared automatically by buildkite.
Expand All @@ -26,7 +26,7 @@ java -version
set +x
echo "--- Deploy the snapshot :package:"
if [[ "$dry_run" == "true" ]] ; then
echo './mvnw -V -s .ci/settings.xml -Pgpg clean deploy --batch-mode'
./mvnw -V -s .ci/settings.xml -Pgpg clean package --batch-mode
amannocci marked this conversation as resolved.
Show resolved Hide resolved
else
./mvnw -V -s .ci/settings.xml -Pgpg clean deploy --batch-mode | tee snapshot.txt
fi
33 changes: 33 additions & 0 deletions .github/workflows/maven-goal/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---

name: maven-goal
description: Install specific JDK and run a command

inputs:
version:
description: 'Java version'
required: true
default: '17'
distribution:
description: 'Java distribution'
required: true
default: 'temurin'
command:
description: 'Command to execute'
required: true
shell:
description: 'Default shell'
default: 'bash'
required: false

runs:
using: "composite"
steps:
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.version }}
distribution: ${{ inputs.distribution }}
cache: 'maven'
- run: ${{ inputs.command }}
shell: ${{ inputs.shell }}
98 changes: 98 additions & 0 deletions .github/workflows/pre-post-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
name: Pre/Post Release

on:
workflow_call:
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
phase:
description: 'Pre or post release phase'
type: choice
options:
- pre
- post
required: true
workflow_dispatch:
amannocci marked this conversation as resolved.
Show resolved Hide resolved
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
phase:
description: 'Pre or post release phase'
type: choice
options:
- pre
- post
default: 'pre'

env:
RELEASE_VERSION: ${{ inputs.version }}
amannocci marked this conversation as resolved.
Show resolved Hide resolved

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' }}
amannocci marked this conversation as resolved.
Show resolved Hide resolved
token: ${{ env.GITHUB_TOKEN }}

- name: Create the release tag
amannocci marked this conversation as resolved.
Show resolved Hide resolved
if: inputs.phase == 'post'
run: |
git tag "v${{ env.RELEASE_VERSION }}"
git push origin "v${{ env.RELEASE_VERSION }}"

- name: Create a ${{ inputs.phase }} release branch
run: git checkout -b ${{ inputs.phase }}-release-v${{ env.RELEASE_VERSION }}
amannocci marked this conversation as resolved.
Show resolved Hide resolved

- name: Pre bump versions
amannocci marked this conversation as resolved.
Show resolved Hide resolved
if: inputs.phase == 'pre'
uses: ./.github/workflows/maven-goal
with:
command: ./mvnw -V versions:set -DprocessAllModules=true -DgenerateBackupPoms=false -DnewVersion=${{ env.RELEASE_VERSION }}

- name: Post bump versions
amannocci marked this conversation as resolved.
Show resolved Hide resolved
if: inputs.phase == 'post'
uses: ./.github/workflows/maven-goal
with:
command: ./mvnw -V versions:set -DprocessAllModules=true -DgenerateBackupPoms=false -nextSnapshot=true

- name: Push the ${{ inputs.phase }} release branch
run: |
git add --all
git commit -m "release(${{ inputs.phase }}): ecs-logging-java v${{ env.RELEASE_VERSION }}"
amannocci marked this conversation as resolved.
Show resolved Hide resolved
git push origin ${{ inputs.phase }}-release-v${{ env.RELEASE_VERSION }}
amannocci marked this conversation as resolved.
Show resolved Hide resolved

- name: Create the ${{ inputs.phase }} release PR
run: gh pr create --title="${{ inputs.phase }} release v${{ env.RELEASE_VERSION }}" --base main --head ${{ inputs.phase }}-release-v${{ env.RELEASE_VERSION }} -b "${{ inputs.phase }} release v${{ env.RELEASE_VERSION }}"
amannocci marked this conversation as resolved.
Show resolved Hide resolved
29 changes: 21 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
---
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
amannocci marked this conversation as resolved.
Show resolved Hide resolved
dry_run:
description: If set, run a dry-run release
default: false
Expand All @@ -22,7 +23,6 @@ jobs:
release:
name: Release
runs-on: ubuntu-latest

steps:
- id: buildkite
name: Run Release
Expand All @@ -32,10 +32,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 +58,16 @@ 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"
amannocci marked this conversation as resolved.
Show resolved Hide resolved
needs:
- release
permissions:
contents: write
uses: ./.github/workflows/pre-post-release.yml
with:
ref: ${{ inputs.ref || 'main' }}
amannocci marked this conversation as resolved.
Show resolved Hide resolved
version: ${{ inputs.version }}
phase: 'post'
secrets: inherit
12 changes: 2 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ on:
permissions:
contents: read

env:
MAVEN_CONFIG: "-V -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Dhttps.protocols=TLSv1.2 -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=25"
JAVA_VERSION: 17
JAVA_DIST: adopt

jobs:

pre-commit:
Expand All @@ -36,12 +31,9 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
- uses: ./.github/workflows/maven-goal
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DIST }}
cache: 'maven'
- run: ./mvnw ${{ matrix.goal }}
command: ./mvnw ${{ matrix.goal }}
- name: Store test results
if: ${{ matrix.goal == 'test' }} && (success() || failure())
uses: actions/upload-artifact@v3
Expand Down
6 changes: 6 additions & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-V
-B
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
-Dhttps.protocols=TLSv1.2
-Dmaven.wagon.http.retryHandler.count=3
-Dmaven.wagon.httpconnectionManager.ttlSeconds=25
amannocci marked this conversation as resolved.
Show resolved Hide resolved
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
Loading