-
Notifications
You must be signed in to change notification settings - Fork 81
feat: new release process #226
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
33fd62e
feat: new release process
amannocci 1a83544
feat: use a global maven config file
amannocci 318fdc4
chore: execute package goal for dry-run release
amannocci ae99e97
ci: align pr title creation for release
amannocci bef4e60
ci: add parameter documentations in CI scripts
amannocci aab1f0a
ci: centralize maven goal execution
amannocci 736f187
fix: use directly java-version without file
amannocci 531e321
ci: refactor using a reusable workflow
amannocci 0b8e19d
refactor: avoid duplicate hardcode branch name
amannocci d436d1e
ci: create summary file in any case
amannocci 0579f47
feat: validate tag before anything
amannocci 8648221
chore: apply suggestions
amannocci 7c29217
fix: validate correctly tags
amannocci 16f61a6
chore: add validation for tag and project version
amannocci File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
--- | ||
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 | ||
|
||
env: | ||
RELEASE_VERSION: ${{ inputs.version }} | ||
BRANCH_NAME: ${{ inputs.phase }}-release-v${{ inputs.version }} | ||
|
||
permissions: | ||
contents: read | ||
|
||
concurrency: | ||
group: ${{ github.workflow }} | ||
|
||
jobs: | ||
validate-tag: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Validate tag does not exist on current commit | ||
SylvainJuge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
uses: ./.github/workflows/validate-tag | ||
with: | ||
tag: v${{ env.RELEASE_VERSION }} | ||
|
||
create-pr: | ||
name: "Bump versions and create PR" | ||
runs-on: ubuntu-latest | ||
needs: | ||
- validate-tag | ||
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 }} | ||
token: ${{ env.GITHUB_TOKEN }} | ||
|
||
- name: Create the release tag (post phase) | ||
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 ${{ env.BRANCH_NAME }} | ||
|
||
- name: Set release version (pre release) | ||
if: inputs.phase == 'pre' | ||
uses: ./.github/workflows/maven-goal | ||
with: | ||
command: ./mvnw -V versions:set -DprocessAllModules=true -DgenerateBackupPoms=false -DnewVersion=${{ env.RELEASE_VERSION }} | ||
|
||
- name: Set next snapshot version (post release) | ||
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 "${{ inputs.phase }} release: ecs-logging-java v${{ env.RELEASE_VERSION }}" | ||
git push origin ${{ env.BRANCH_NAME }} | ||
|
||
- name: Create the ${{ inputs.phase }} release PR | ||
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 }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
name: Pre 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 | ||
|
||
concurrency: | ||
group: ${{ github.workflow }} | ||
|
||
jobs: | ||
pre-release: | ||
name: "Bump versions and create PR" | ||
uses: ./.github/workflows/pre-post-release.yml | ||
with: | ||
ref: ${{ inputs.ref }} | ||
version: ${{ inputs.version }} | ||
phase: 'pre' | ||
secrets: inherit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,48 @@ | ||
--- | ||
name: release | ||
|
||
permissions: | ||
contents: read | ||
name: Release | ||
|
||
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 | ||
type: boolean | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
validate-tag: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Validate tag does not exist on current commit | ||
uses: ./.github/workflows/validate-tag | ||
with: | ||
tag: v${{ env.RELEASE_VERSION }} | ||
- name: Validate tag match current version | ||
run: | | ||
if [ "$(mvn -q help:evaluate -Dexpression=project.version -DforceStdout)" != "${{ env.RELEASE_VERSION }}" ]; then | ||
echo "Tag should match pom.xml project.version" | ||
exit 1 | ||
fi | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we should probably do an extra verification step to ensure that the maven project version is the one we expect from the parameters. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ref: 16f61a6 |
||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
|
||
needs: | ||
- validate-tag | ||
steps: | ||
- id: buildkite | ||
name: Run Release | ||
|
@@ -32,10 +52,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 }} | ||
dry_run=${{ inputs.dry_run || 'false' }} | ||
|
||
- if: ${{ success() }} | ||
|
@@ -58,3 +78,15 @@ 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 | ||
uses: ./.github/workflows/pre-post-release.yml | ||
if: inputs.dry_run == 'false' | ||
with: | ||
ref: ${{ inputs.ref }} | ||
version: ${{ inputs.version }} | ||
phase: 'post' | ||
secrets: inherit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
|
||
name: validate-tag | ||
description: Validate tag format | ||
|
||
inputs: | ||
tag: | ||
description: 'Tag to validate' | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Validate tag does not exist on current commit | ||
id: validate-tag | ||
shell: 'bash' | ||
run: | | ||
if ! [ $(echo "${{ inputs.tag }}" | grep -P "(\d{1,2})\.(\d{1,2})\.(\d{1,2})") ]; then | ||
echo "Tag should be a SemVer format" | ||
exit 1 | ||
fi | ||
if [ $(git tag -l "${{ inputs.tag }}") ]; then | ||
echo "The tag ${{ inputs.tag }} already exists" | ||
exit 1 | ||
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-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
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.