-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: support release in
dry-run
mode (#142)
- Loading branch information
Showing
8 changed files
with
199 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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 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,16 @@ | ||
agents: | ||
provider: "gcp" | ||
|
||
steps: | ||
- label: "Build and publish release" | ||
key: "release" | ||
commands: .ci/release.sh | ||
artifact_paths: | ||
- "release.txt" | ||
- "agent/build/libs/elastic-otel-javaagent-*.jar" | ||
- "build/dry-run-maven-repo.tgz" | ||
|
||
notify: | ||
- slack: "#apm-agent-java" | ||
if: 'build.state != "passed"' | ||
|
This file contains 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,43 @@ | ||
#!/usr/bin/env bash | ||
## This script runs the release given the different environment variables | ||
## dry_run | ||
## | ||
## It relies on the .buildkite/hooks/pre-command so the Vault and other tooling | ||
## are prepared automatically by buildkite. | ||
## | ||
|
||
set -eo pipefail | ||
|
||
# Make sure we delete this folder before leaving even in case of failure | ||
clean_up () { | ||
ARG=$? | ||
echo "--- Deleting tmp workspace" | ||
rm -rf $TMP_WORKSPACE | ||
exit $ARG | ||
} | ||
trap clean_up EXIT | ||
|
||
echo "--- JDK installation info :coffee:" | ||
echo $JAVA_HOME | ||
echo $PATH | ||
java -version | ||
|
||
publishArg='' | ||
if [[ "$dry_run" == "true" ]] ; then | ||
echo "--- Build and publish the release :package: (dry-run)" | ||
publishArg='publishAllPublicationsToDryRunRepository' | ||
else | ||
echo "--- Build and publish the release :package:" | ||
### TODO: changeme | ||
publishArg='assemble' | ||
fi | ||
|
||
./gradlew \ | ||
--console=plain \ | ||
clean ${publishArg} \ | ||
| tee release.txt | ||
|
||
if [[ "$dry_run" == "true" ]] ; then | ||
echo "--- Archive the dry-run repository :package: (dry-run)" | ||
tar czvf ./build/dry-run-maven-repo.tgz -C ./build/dry-run-maven-repo/ . | tee release.txt | ||
fi |
This file contains 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 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,39 @@ | ||
## CI/CD | ||
|
||
There are three main stages that run on GitHub actions: | ||
|
||
* Build | ||
* Unit Test | ||
* Release | ||
|
||
### Scenarios | ||
|
||
* Tests should be triggered on branch, tag, and PR basis. | ||
* Commits that are only affecting the docs files should not trigger any test or similar stages that are not required. | ||
* Automated release in the CI gets triggered through a GitHub workflow. | ||
* **This is not the case yet**, but if Github secrets are required, Pull Requests from forked repositories won't run any build accessing those secrets. If needed, create a feature branch (opened directly on the upstream project). | ||
|
||
### How do you interact with the CI? | ||
|
||
#### On a PR basis | ||
|
||
Once a PR has been opened, then there are two different ways you can trigger builds in the CI: | ||
|
||
1. Git commit based | ||
2. UI-based, any Elasticians can force a build through the GitHub UI | ||
|
||
#### Branches | ||
|
||
Whenever a merge to the main or branches, the whole workflow will be compiled and tested on Linux and Windows. | ||
|
||
### Release process | ||
|
||
This process has been fully automated, and it gets triggered manually when the [release](https://github.com/elastic/elastic-otel-java/actions/workflows/release.yml) workflow is being run. It runs a Buildkite pipeline in charge of generating and publishing the artifacts; for further details, please go to [the Buildkite folder](../../.buildkite/README.md). | ||
|
||
The tag release follows the naming convention: `v.<major>.<minor>.<patch>`, where `<major>`, `<minor>` and `<patch>`. | ||
|
||
The release automation raises a Pull Request with the next version. | ||
|
||
### OpenTelemetry | ||
|
||
A GitHub workflow is responsible for populating the workflows regarding jobs and steps. Those details can be seen [here](https://ela.st/oblt-ci-cd-stats) (**NOTE**: only available for Elasticians). |
This file contains 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,65 @@ | ||
--- | ||
name: release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
dry_run: | ||
description: If set, run a dry-run release | ||
default: false | ||
type: boolean | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- id: buildkite | ||
name: Run Release | ||
uses: elastic/apm-pipeline-library/.github/actions/buildkite@current | ||
with: | ||
vaultUrl: ${{ secrets.VAULT_ADDR }} | ||
vaultRoleId: ${{ secrets.VAULT_ROLE_ID }} | ||
vaultSecretId: ${{ secrets.VAULT_SECRET_ID }} | ||
pipeline: elastic-otel-java-release | ||
waitFor: true | ||
printBuildLogs: false | ||
buildEnvVars: | | ||
dry_run=${{ inputs.dry_run || 'false' }} | ||
- if: ${{ success() && ! inputs.dry_run }} | ||
uses: elastic/apm-pipeline-library/.github/actions/slack-message@current | ||
with: | ||
url: ${{ secrets.VAULT_ADDR }} | ||
roleId: ${{ secrets.VAULT_ROLE_ID }} | ||
secretId: ${{ secrets.VAULT_SECRET_ID }} | ||
channel: "#apm-agent-java" | ||
message: | | ||
:runner: [${{ github.repository }}] Release *${{ github.ref_name }}* has been triggered in Buildkite: (<${{ steps.buildkite.outputs.build }}|build>) | ||
- if: ${{ failure() && ! inputs.dry_run }} | ||
uses: elastic/apm-pipeline-library/.github/actions/slack-message@current | ||
with: | ||
url: ${{ secrets.VAULT_ADDR }} | ||
roleId: ${{ secrets.VAULT_ROLE_ID }} | ||
secretId: ${{ secrets.VAULT_SECRET_ID }} | ||
channel: "#apm-agent-java" | ||
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: Post Release | ||
needs: release | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- if: ${{ ! inputs.dry_run }} | ||
run: echo "TODO" |
This file contains 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