Release #1
Workflow file for this run
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
| name: Release | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| required-jobs: | |
| uses: ./.github/workflows/build-common.yml | |
| # test-latest-deps is intentionally not included in the release workflows | |
| # because any time a new library version is released to maven central | |
| # it can fail due to test code incompatibility with the new library version, | |
| # or due to slight changes in emitted telemetry | |
| # muzzle is intentionally not included in the release workflows | |
| # because any time a new library version is released to maven central it can fail, | |
| # and this is not a reason to hold up the release | |
| release: | |
| permissions: | |
| contents: write # for creating the release | |
| attestations: write # for creating the attestation | |
| id-token: write # for creating the attestation | |
| runs-on: ubuntu-latest | |
| needs: | |
| - required-jobs | |
| outputs: | |
| version: ${{ steps.create-github-release.outputs.version }} | |
| prior-version: ${{ steps.create-github-release.outputs.prior-version }} | |
| steps: | |
| - run: | | |
| if [[ $GITHUB_REF_NAME != release/* ]]; then | |
| echo this workflow should only be run against release branches | |
| exit 1 | |
| fi | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Set environment variables | |
| run: | | |
| version=$(.github/scripts/get-version.sh) | |
| if [[ $version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then | |
| major="${BASH_REMATCH[1]}" | |
| minor="${BASH_REMATCH[2]}" | |
| patch="${BASH_REMATCH[3]}" | |
| else | |
| echo "unexpected version: $version" | |
| exit 1 | |
| fi | |
| if [[ $patch == 0 ]]; then | |
| if [[ $minor == 0 ]]; then | |
| prior_major=$((major - 1)) | |
| prior_minor=$(grep -Po "^## Version $prior_major.\K[0-9]+" CHANGELOG.md | head -1) | |
| prior_version="$prior_major.$prior_minor" | |
| else | |
| prior_version="$major.$((minor - 1)).0" | |
| fi | |
| else | |
| prior_version="$major.$minor.$((patch - 1))" | |
| fi | |
| echo "VERSION=$version" >> $GITHUB_ENV | |
| echo "PRIOR_VERSION=$prior_version" >> $GITHUB_ENV | |
| # check out main branch to verify there won't be problems with merging the change log | |
| # at the end of this workflow | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| ref: main | |
| - name: Check that change log update was merged to main | |
| run: | | |
| if [[ $VERSION == *.0 ]]; then | |
| # not making a patch release | |
| if ! grep --quiet "^## Version $VERSION " CHANGELOG.md; then | |
| echo the pull request generated by prepare-release-branch.yml needs to be merged first | |
| exit 1 | |
| fi | |
| fi | |
| # back to the release branch | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| # tags are needed for the generate-release-contributors.sh script | |
| fetch-depth: 0 | |
| - name: Free disk space | |
| run: .github/scripts/gha-free-disk-space.sh | |
| - uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0 | |
| with: | |
| distribution: temurin | |
| java-version-file: .java-version | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4.3.0 | |
| - name: Build and publish artifacts | |
| env: | |
| SONATYPE_USER: ${{ secrets.SONATYPE_USER }} | |
| SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }} | |
| GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | |
| GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }} | |
| run: ./gradlew assemble spdxSbom | |
| - name: Collect SBOMs | |
| run: | | |
| mkdir sboms | |
| cp javaagent/build/spdx/*.spdx.json sboms | |
| zip opentelemetry-java-instrumentation-SBOM.zip sboms/* | |
| - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 | |
| name: Upload SBOMs | |
| with: | |
| name: opentelemetry-java-instrumentation-SBOM | |
| path: "sboms/*.json" | |
| - name: Generate release notes | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| sdk_version=$(grep -Po "val otelSdkVersion = \"\K[0-9]+.[0-9]+.[0-9]+" dependencyManagement/build.gradle.kts) | |
| # conditional blocks not indented because of the heredoc | |
| if [[ $VERSION == *.0 ]]; then | |
| cat > /tmp/release-notes.txt << EOF | |
| This release targets the OpenTelemetry SDK $sdk_version. | |
| Note that many artifacts have the \`-alpha\` suffix attached to their version number, reflecting that they are still alpha quality and will continue to have breaking changes. Please see the [VERSIONING.md](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/VERSIONING.md#opentelemetry-java-instrumentation-versioning) for more details. | |
| EOF | |
| else | |
| cat > /tmp/release-notes.txt << EOF | |
| This is a patch release on the previous $PRIOR_VERSION release, fixing the issue(s) below. | |
| EOF | |
| fi | |
| # CHANGELOG_SECTION.md is also used at the end of the release workflow | |
| # for copying the change log updates to main | |
| sed -n "0,/^## Version $VERSION /d;/^## Version /q;p" CHANGELOG.md \ | |
| > /tmp/CHANGELOG_SECTION.md | |
| # the complex perl regex is needed because markdown docs render newlines as soft wraps | |
| # while release notes render them as line breaks | |
| perl -0pe 's/(?<!\n)\n *(?!\n)(?![-*] )(?![1-9]+\. )/ /g' /tmp/CHANGELOG_SECTION.md \ | |
| >> /tmp/release-notes.txt | |
| # conditional block not indented because of the heredoc | |
| if [[ $VERSION == *.0 ]]; then | |
| cat >> /tmp/release-notes.txt << EOF | |
| ### 🙇 Thank you | |
| This release was possible thanks to the following contributors who shared their brilliant ideas and awesome pull requests: | |
| EOF | |
| .github/scripts/generate-release-contributors.sh v$PRIOR_VERSION >> /tmp/release-notes.txt | |
| fi | |
| - name: Simplify jar path for attesting and attaching | |
| run: | | |
| cp javaagent/build/libs/opentelemetry-javaagent-${VERSION}.jar opentelemetry-javaagent.jar | |
| - id: attest | |
| uses: actions/attest-build-provenance@v2 | |
| with: | |
| subject-path: | | |
| opentelemetry-javaagent.jar | |
| opentelemetry-java-instrumentation-SBOM.zip | |
| - name: Rename attestation bundle file for attaching | |
| run: | | |
| cp ${{ steps.attest.outputs.bundle-path }} attestations.intoto.jsonl | |
| - id: create-github-release | |
| name: Create GitHub release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release create --target $GITHUB_REF_NAME \ | |
| --title "Version $VERSION" \ | |
| --notes-file /tmp/release-notes.txt \ | |
| v$VERSION \ | |
| opentelemetry-javaagent.jar \ | |
| opentelemetry-java-instrumentation-SBOM.zip \ | |
| attestations.intoto.jsonl |