Skip to content

Commit fe3aa21

Browse files
SylvainJugemacroscopeapp[bot]obltmachine
authored
[ci] generate upstream update changelog (#1037)
* add step to generate changelog for upstream * add wip changelog generation * split in two workflows * push script closer to final form * remove gradle wrapper * (via SylvainJuge): Fix checkout ref to use workflow_run.head_sha instead of undefined input (#1038) * Fix checkout ref to use workflow_run.head_sha instead of undefined inputs.ref * Fix workflow_run event context references in changelog-submit-upstream-update workflow * Add missing BRANCH_NAME env var to changelog workflow step * Fix variable reference from ${pr_id} to ${PR_NUMBER} in changelog workflow --------- Co-authored-by: macroscopeapp[bot] <170038800+macroscopeapp[bot]@users.noreply.github.com> * Update .github/workflows/changelg-submit-upstream-update.yml Co-authored-by: macroscopeapp[bot] <170038800+macroscopeapp[bot]@users.noreply.github.com> * wip * fix stuff * fix fork * fix things again * push with detached head * fix fork condition * fix branch name * avoid temp folder * another try to get the branch name * printf debug * another try * try with git implicit user/ref * try it another way * Add changelog for upstream update * add condition to skip if already present * using bash syntax for if * remove changelog to test again * cleanup * remove useless output dir * wip: debug changelog submit filtering * add todos * handle review feedback * fix pebkc * try again * try to merge in two workflows * validate for upstream update * rename steps * try a better approach * simpler naming for jobs * try to fix condition * Add changelog for upstream update * remove unused env variable * try to fix things * swap things again * yolo debugging * try something else * try to fix things again * add quotes for extra safety * remove generated changelog * move inline script to its own file * make script more strict * remove github token * fix path to changelog script * make script executable * generate changelog entry * remove generated changelog --------- Co-authored-by: macroscopeapp[bot] <170038800+macroscopeapp[bot]@users.noreply.github.com> Co-authored-by: obltmachine <obltmachine@users.noreply.github.com>
1 parent 2835c09 commit fe3aa21

5 files changed

Lines changed: 104 additions & 19 deletions

File tree

.ci/changelog-upstream-update.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
# this script creates and pushes a changelog entry for the upstream otel dependencies.
4+
# it relies on the following environment variables:
5+
# PR_TITLE: pull-request title (used in the changelog title)
6+
# PR_URL: pull-request URL (used in the changelog entry to link to the PR)
7+
# PR_NUMBER: pull-request number (used to name the changelog entry file)
8+
9+
description="- $("./gradlew" -q changelogUpstreamDependenciesOneLiner)"
10+
docs-builder changelog add \
11+
--concise \
12+
--title "${PR_TITLE}" \
13+
--type enhancement \
14+
--prs "${PR_URL}" \
15+
--products "edot-java NEXT ga" \
16+
--description "${description}"
17+
18+
# will overwrite any prior update, if there is any
19+
mv -v "./docs/changelog/${PR_NUMBER}.yaml" "./docs/changelog/upstream-update.yaml"
20+
21+
if [[ -z "$(git status --porcelain)" ]]; then
22+
echo "No changes to commit"
23+
else
24+
git add --all .
25+
git commit -m "generate changelog entry"
26+
git push
27+
fi
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: changelog-init
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
- edited
10+
- labeled
11+
- unlabeled
12+
13+
permissions:
14+
contents: read
15+
16+
concurrency:
17+
group: changelog-init-${{ github.event.pull_request.number }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
22+
# with upstream update PRs:
23+
# - we want to automatically generate changelog
24+
# - we do this only for update PRs which are not on a fork and have the expected label
25+
# - we need to do this before the "validate" job, which should pass and make changelog-submit to be skipped (as the changelog already exists)
26+
# this is because changelog-submit is triggered by workflow_run and otherwise we can't control ordering.
27+
upstream-update:
28+
permissions:
29+
contents: write
30+
pull-requests: write
31+
if: >
32+
contains(github.event.pull_request.labels.*.name, 'changelog:upstream-update')
33+
&& github.event.pull_request.head.repo.fork == false
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v6
38+
with:
39+
ref: ${{ github.head_ref }}
40+
- name: Git setup
41+
uses: elastic/oblt-actions/git/setup@v1
42+
- name: Docs builder setup
43+
uses: elastic/docs-actions/docs-builder/setup@v1
44+
45+
- name: Generate changelog entry
46+
env:
47+
PR_NUMBER: ${{ github.event.pull_request.number }}
48+
PR_TITLE: ${{ github.event.pull_request.title }}
49+
PR_URL: ${{ github.event.pull_request.html_url }}
50+
run: .ci/changelog-upstream-update.sh
51+
52+
validate:
53+
# needs to execute even if init-upstream-update is skipped
54+
if: ${{ always() }}
55+
# needs to execute after init-upstream-update
56+
needs: [ upstream-update ]
57+
uses: elastic/docs-actions/.github/workflows/changelog-validate.yml@v1

.github/workflows/changelog-submit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: changelog-submit
22

33
on:
44
workflow_run:
5-
workflows: [changelog-validate]
5+
workflows: [changelog-init]
66
types:
77
- completed
88

.github/workflows/changelog-validate.yml

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

build.gradle.kts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,25 @@ tasks {
6666
}
6767
}
6868

69+
/**
70+
* Used from within our release automation as part of the changelog generation.
71+
*/
72+
register("changelogUpstreamDependenciesOneLiner") {
73+
dependsOn(printDependencyVersions)
74+
doLast {
75+
val agentVer = getResolvedDependency("io.opentelemetry.javaagent:opentelemetry-javaagent")!!.version
76+
val sdkVer = getResolvedDependency("io.opentelemetry:opentelemetry-sdk")!!.version
77+
val semconvVer = libs.versions.opentelemetrySemconv.get()
78+
val contribVer = libs.versions.opentelemetryContribAlpha.get().replace("-alpha", "") // -alpha suffix is only on artifact, not release tag
79+
var result = ""
80+
result += "javaagent:[$agentVer](https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/tag/v$agentVer)"
81+
result += " sdk:[$sdkVer](https://github.com/open-telemetry/opentelemetry-java/releases/tag/v$sdkVer)"
82+
result += " semconv:[$semconvVer](https://github.com/open-telemetry/semantic-conventions-java/releases/tag/v$semconvVer)"
83+
result += " contrib:[$contribVer](https://github.com/open-telemetry/opentelemetry-java-contrib/releases/tag/v$contribVer)"
84+
println(result)
85+
}
86+
}
87+
6988
register("currentVersion") {
7089
doLast {
7190
println(project.version)

0 commit comments

Comments
 (0)