Auto-update OpenTelemetry SDK #11705
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
name: Auto-update OpenTelemetry SDK | |
on: | |
schedule: | |
# hourly at minute 46 | |
- cron: "46 * * * *" | |
workflow_dispatch: | |
jobs: | |
check-versions: | |
runs-on: ubuntu-latest | |
outputs: | |
current-version: ${{ steps.check-versions.outputs.current-version }} | |
latest-version: ${{ steps.check-versions.outputs.latest-version }} | |
already-opened: ${{ steps.check-versions.outputs.already-opened }} | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- id: check-versions | |
name: Check versions | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
current_version=$(grep -Po "val otelSdkVersion = \"\K[0-9]+.[0-9]+.[0-9]+" \ | |
dependencyManagement/build.gradle.kts) | |
latest_version=$(gh release view \ | |
--repo open-telemetry/opentelemetry-java \ | |
--json tagName \ | |
--jq .tagName \ | |
| sed 's/^v//') | |
matches=$(gh pr list \ | |
--author opentelemetrybot \ | |
--state open \ | |
--search "in:title \"Update the OpenTelemetry SDK version to $latest_version\"") | |
if [ ! -z "$matches" ] | |
then | |
already_opened=true | |
fi | |
echo "current-version=$current_version" >> $GITHUB_OUTPUT | |
echo "latest-version=$latest_version" >> $GITHUB_OUTPUT | |
echo "already-opened=$already_opened" >> $GITHUB_OUTPUT | |
update-otel-sdk: | |
permissions: | |
contents: write # for Git to git push | |
runs-on: ubuntu-latest | |
if: | | |
needs.check-versions.outputs.current-version != needs.check-versions.outputs.latest-version && | |
needs.check-versions.outputs.already-opened != 'true' | |
needs: | |
- check-versions | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Update version | |
env: | |
VERSION: ${{ needs.check-versions.outputs.latest-version }} | |
run: ./.github/scripts/update-sdk-version.sh $VERSION | |
- name: Use CLA approved github bot | |
run: .github/scripts/use-cla-approved-github-bot.sh | |
- name: Free disk space | |
run: .github/scripts/gha-free-disk-space.sh | |
- name: Set up JDK for running Gradle | |
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 | |
with: | |
distribution: temurin | |
java-version-file: .java-version | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2 | |
- name: Update license report | |
run: ./gradlew generateLicenseReport | |
- name: Undo license report clean | |
if: failure() | |
run: git checkout -- licenses | |
- name: Create pull request against main | |
if: success() || failure() | |
env: | |
VERSION: ${{ needs.check-versions.outputs.latest-version }} | |
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows | |
GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} | |
run: | | |
message="Update the OpenTelemetry SDK version to $VERSION" | |
body="Update the OpenTelemetry SDK version to \`$VERSION\`." | |
branch="opentelemetrybot/update-opentelemetry-sdk-to-${VERSION}" | |
git checkout -b $branch | |
git add -u | |
git add licenses | |
git commit -m "$message" | |
git push --set-upstream origin $branch | |
gh pr create --title "$message" \ | |
--body "$body" \ | |
--base main |