123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- # Releases a new major / minor / patch version from a release branch
- name: Release Build
- on:
- workflow_dispatch:
- jobs:
- test:
- uses: ./.github/workflows/reusable-test.yml
- # testLatestDeps 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
- smoke-test:
- uses: ./.github/workflows/reusable-smoke-test.yml
- # 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
- examples:
- uses: ./.github/workflows/reusable-examples.yml
- release:
- needs: [ test, smoke-test, examples ]
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- with:
- ref: ${{ github.ref_name }}
- # tags are needed for the generate-release-contributors.sh script
- fetch-depth: 0
- - name: Set up JDK for running Gradle
- uses: actions/setup-java@v2
- with:
- distribution: temurin
- java-version: 17
- - name: Build and publish artifacts
- uses: gradle/gradle-build-action@v2
- with:
- arguments: assemble publishToSonatype closeAndReleaseSonatypeStagingRepository
- env:
- SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
- SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }}
- GRGIT_USER: ${{ github.actor }}
- GRGIT_PASS: ${{ secrets.GITHUB_TOKEN }}
- GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
- GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
- - name: Build and publish gradle plugins
- uses: gradle/gradle-build-action@v2
- env:
- SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
- SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }}
- GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
- GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
- GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
- GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
- with:
- # Don't use publishToSonatype since we don't want to publish the marker artifact
- arguments: build publishPlugins publishPluginMavenPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository
- build-root-directory: gradle-plugins
- - name: Set versions
- id: set-versions
- run: |
- v=$(grep -Eo "[0-9]+.[0-9]+.[0-9]+" version.gradle.kts | head -1)
- if [[ $v =~ ([0-9]+).([0-9]+).([0-9]+) ]]; then
- major="${BASH_REMATCH[1]}"
- minor="${BASH_REMATCH[2]}"
- patch="${BASH_REMATCH[3]}"
- else
- echo "unexpected version: $v"
- 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="$prior_major.$prior_minor"
- else
- prior="$major.$((minor - 1)).0"
- fi
- else
- prior="$major.$minor.$((patch - 1))"
- fi
- echo "::set-output name=release-version::$v"
- echo "::set-output name=prior-version::$prior"
- echo "::set-output name=patch-version::$patch"
- - name: Generate release notes
- if: ${{ steps.set-versions.outputs.patch-version == 0 }}
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
- cat > release-notes.txt << EOF
- Note that all artifacts other than \`io.opentelemetry.javaagent:opentelemetry-javaagent\` 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
- sed -n '/^## Version ${{ steps.set-versions.outputs.release-version }}/,/^## Version /p' CHANGELOG.md \
- | tail -n +2 \
- | head -n -1 \
- | perl -0pe 's/^\n+//g' \
- | perl -0pe 's/\n+$/\n/g' \
- | sed -r 's,\[#([0-9]+)]\(https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/[0-9]+\),#\1,' \
- | perl -0pe 's/\n +/ /g' \
- >> release-notes.txt
- cat >> 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${{ steps.set-versions.outputs.prior-version }} v${{ steps.set-versions.outputs.release-version }} >> release-notes.txt
- - name: Generate patch release notes
- if: ${{ steps.set-versions.outputs.patch-version != 0 }}
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
- cat > release-notes.txt << EOF
- This is a patch release on the previous ${{ steps.set-versions.outputs.prior-version }} release, fixing the issue(s) below.
- EOF
- sed -n '/^## Version ${{ steps.set-versions.outputs.release-version }}/,/^## Version /p' CHANGELOG.md \
- | tail -n +2 \
- | head -n -1 \
- | perl -0pe 's/^\n+//g' \
- | perl -0pe 's/\n+$/\n/g' \
- | sed -r 's,\[#([0-9]+)]\(https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/[0-9]+\),#\1,' \
- | perl -0pe 's/\n +/ /g' \
- >> release-notes.txt
- - name: Create GitHub release
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
- cp javaagent/build/libs/opentelemetry-javaagent-${{ steps.set-versions.outputs.release-version }}.jar opentelemetry-javaagent.jar
- gh release create --target ${{ github.ref_name }} \
- --title "Version ${{ steps.set-versions.outputs.release-version }}" \
- --notes-file release-notes.txt \
- --discussion-category announcements \
- v${{ steps.set-versions.outputs.release-version }} \
- opentelemetry-javaagent.jar
|