diff --git a/.github/scripts/generate-release-contributors.sh b/.github/scripts/generate-release-contributors.sh new file mode 100644 index 0000000000..58cdf2f339 --- /dev/null +++ b/.github/scripts/generate-release-contributors.sh @@ -0,0 +1,82 @@ +#!/bin/bash -e + +# shellcheck disable=SC2016 +# shellcheck disable=SC2086 + +from_version=$1 +to_version=$2 + +# get the date of the first commit on main that wasn't in the from_version +from=$(git log --reverse --pretty=format:"%cI" $from_version..HEAD | head -1) + +# get the last commit on main that was in the to_version +to=$(git merge-base HEAD $to_version | xargs git log -1 --pretty=format:"%cI") + +contributors1=$(gh api graphql --paginate -F q="repo:$GITHUB_REPOSITORY is:pr base:main is:merged merged:$from..$to" -f query=' +query($q: String!, $endCursor: String) { + search(query: $q, type: ISSUE, first: 100, after: $endCursor) { + edges { + node { + ... on PullRequest { + author { login } + reviews(first: 100) { + nodes { + author { login } + } + } + comments(first: 100) { + nodes { + author { login } + } + } + closingIssuesReferences(first: 100) { + nodes { + author { login } + } + } + } + } + } + pageInfo { + hasNextPage + endCursor + } + } +}' --jq '.data.search.edges.[].node.author.login, + .data.search.edges.[].node.reviews.nodes.[].author.login, + .data.search.edges.[].node.comments.nodes.[].author.login, + .data.search.edges.[].node.closingIssuesReferences.nodes.[].author.login') + +# this query captures authors of issues which have had PRs in the current range reference the issue +# but not necessarily through closingIssuesReferences (e.g. addressing just a part of an issue) +contributors2=$(gh api graphql --paginate -F q="repo:$GITHUB_REPOSITORY is:pr base:main is:merged merged:$from..$to" -f query=' +query($q: String!, $endCursor: String) { + search(query: $q, type: ISSUE, first: 100, after: $endCursor) { + edges { + node { + ... on PullRequest { + body + } + } + } + pageInfo { + hasNextPage + endCursor + } + } +} +' --jq '.data.search.edges.[].node.body' \ + | grep -oE "#[0-9]{4,}|issues/[0-9]{4,}" \ + | grep -oE "[0-9]{4,}" \ + | xargs -I{} gh issue view {} --json 'author,url' --jq '[.author.login,.url]' \ + | grep -v '/pull/' \ + | sed 's/^\["//' \ + | sed 's/".*//') + +echo $contributors1 $contributors2 \ + | sed 's/ /\n/g' \ + | sort -uf \ + | grep -v linux-foundation-easycla \ + | grep -v github-actions \ + | grep -v dependabot \ + | sed 's/^/@/' diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml new file mode 100644 index 0000000000..8efe7254bb --- /dev/null +++ b/.github/workflows/backport.yml @@ -0,0 +1,38 @@ +name: Backport +on: + workflow_dispatch: + inputs: + number: + description: "The pull request # to backport" + required: true + +jobs: + backport: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + # history is needed in order to do cherry-pick + fetch-depth: 0 + + - name: Set git user + run: | + git config user.name opentelemetry-java-bot + git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com + + - name: Create pull request + env: + NUMBER: ${{ github.event.inputs.number }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + commit=$(gh pr view $NUMBER --json mergeCommit --jq .mergeCommit.oid) + title=$(gh pr view $NUMBER --json title --jq .title) + url=$(gh pr view $NUMBER --json url --jq .url) + + git cherry-pick $commit + git push origin HEAD:backport-$NUMBER-to-$GITHUB_REF_NAME + + gh pr create --title "[$GITHUB_REF_NAME] $title" \ + --body "Clean cherry-pick of #$NUMBER to the $GITHUB_REF_NAME branch." \ + --head backport-$NUMBER-to-$GITHUB_REF_NAME \ + --base $GITHUB_REF_NAME diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index baff2c24cb..037f253bd8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ on: push: branches: - main - - v[0-9]+.[0-9]+.x + - release/* workflow_dispatch: jobs: diff --git a/.github/workflows/docker-test-containers.yml b/.github/workflows/docker-test-containers-daily.yml similarity index 95% rename from .github/workflows/docker-test-containers.yml rename to .github/workflows/docker-test-containers-daily.yml index fbef9f3afc..304373e8b3 100644 --- a/.github/workflows/docker-test-containers.yml +++ b/.github/workflows/docker-test-containers-daily.yml @@ -1,4 +1,4 @@ -name: Copy test container docker images +name: Copy test container docker images (daily) on: schedule: diff --git a/.github/workflows/patch-release-build.yml b/.github/workflows/patch-release-build.yml deleted file mode 100644 index 4e2469b5b2..0000000000 --- a/.github/workflows/patch-release-build.yml +++ /dev/null @@ -1,97 +0,0 @@ -# Releases a patch by cherrypicking commits into a release branch based on the previous -# release tag. -name: Patch Release Build -on: - workflow_dispatch: - inputs: - version: - description: The version to tag the release with, e.g., 1.2.1, 1.2.2 - required: true - commits: - description: Comma separated list of commit shas to cherrypick, leave blank if changes have already been merged into the release branch - required: false - -jobs: - prepare-release-branch: - runs-on: ubuntu-20.04 - outputs: - release-branch-name: ${{ steps.parse-release-branch.outputs.release-branch-name }} - steps: - - id: parse-release-branch - name: Parse release branch name - run: | - # Sets the release-branch-name output to the version number with the last non-period element replaced with an 'x' and preprended with v. - echo "::set-output name=release-branch-name::$(echo '${{ github.event.inputs.version }}' | sed -E 's/([^.]+)\.([^.]+)\.([^.]+)/v\1.\2.x/')" - # Sets the release-tag-name output to the version number with the last non-period element replace with a '0' and prepended with v - echo "::set-output name=release-tag-name::$(echo '${{ github.event.inputs.version }}' | sed -E 's/([^.]+)\.([^.]+)\.([^.]+)/v\1.\2.0/')" - - - id: checkout-release-branch - name: Check out release branch - continue-on-error: true - uses: actions/checkout@v3 - with: - ref: ${{ steps.parse-release-branch.outputs.release-branch-name }} - - - id: checkout-release-tag - name: Check out release tag - if: ${{ steps.checkout-release-branch.outcome == 'failure' }} - uses: actions/checkout@v3 - with: - ref: ${{ steps.parse-release-branch.outputs.release-tag-name }} - - - name: Create release branch - if: ${{ steps.checkout-release-tag.outcome == 'success' }} - run: | - git checkout -b ${{ steps.parse-release-branch.outputs.release-branch-name }} - git push --set-upstream origin ${{ steps.parse-release-branch.outputs.release-branch-name }} - - build: - runs-on: ubuntu-20.04 - needs: prepare-release-branch - steps: - - name: Checkout release branch - uses: actions/checkout@v3 - with: - ref: ${{ needs.prepare-release-branch.outputs.release-branch-name }} - - - uses: actions/setup-java@v2 - with: - distribution: temurin - java-version: 17 - - - name: Set up git name - run: | - git config user.name github-actions - git config user.email github-actions@github.com - - - name: Cherrypicks - if: ${{ github.event.inputs.commits != '' }} - run: | - git fetch origin main - echo ${{ github.event.inputs.commits }} | sed -n 1'p' | tr ',' '\n' | while read word; do - # Trim whitespaces and cherrypick - echo $word | sed 's/ *$//g' | sed 's/^ *//g' | git cherry-pick --stdin - done - - - uses: gradle/gradle-build-action@v2 - with: - arguments: | - build - -Prelease.version=${{ github.event.inputs.version }} - - - uses: gradle/gradle-build-action@v2 - name: Publish artifacts - with: - arguments: | - final - closeAndReleaseSonatypeStagingRepository - -Prelease.version=${{ github.event.inputs.version }} - env: - GRGIT_USER: ${{ github.actor }} - GRGIT_PASS: ${{ secrets.GITHUB_TOKEN }} - SONATYPE_USER: ${{ secrets.SONATYPE_USER }} - SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }} - GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} - GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }} - - - run: git push diff --git a/.github/workflows/prepare-patch-release.yml b/.github/workflows/prepare-patch-release.yml new file mode 100644 index 0000000000..3da2cf4728 --- /dev/null +++ b/.github/workflows/prepare-patch-release.yml @@ -0,0 +1,43 @@ +name: Prepare patch release +on: + workflow_dispatch: + +jobs: + prepare-patch-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set environment variables + run: | + prior_version=$(grep -Eo "[0-9]+.[0-9]+.[0-9]+" version.gradle.kts | head -1) + if [[ $prior_version =~ ([0-9]+.[0-9]+).([0-9]+) ]]; then + major_minor="${BASH_REMATCH[1]}" + patch="${BASH_REMATCH[2]}" + else + echo "unexpected version: $prior_version" + exit 1 + fi + echo "VERSION=$major_minor.$((patch + 1))" >> $GITHUB_ENV + echo "PRIOR_VERSION=$prior_version" >> $GITHUB_ENV + + - name: Bump version + run: | + sed -ri "s/$PRIOR_VERSION/$VERSION/" version.gradle.kts + + - name: Set git user + run: | + git config user.name opentelemetry-java-bot + git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com + + - name: Create pull request + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + msg="Prepare release $VERSION" + git commit -a -m "$msg" + git push origin HEAD:prepare-release-$VERSION + gh pr create --title "[$GITHUB_REF_NAME] $msg" \ + --body "$msg" \ + --head prepare-release-$VERSION \ + --base $GITHUB_REF_NAME diff --git a/.github/workflows/prepare-release-branch.yml b/.github/workflows/prepare-release-branch.yml new file mode 100644 index 0000000000..ebe5aaa905 --- /dev/null +++ b/.github/workflows/prepare-release-branch.yml @@ -0,0 +1,78 @@ +name: Prepare release branch +on: + workflow_dispatch: + +jobs: + create-pull-request-against-release-branch: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Create release branch + id: create-release-branch + run: | + version=$(grep -Eo "[0-9]+.[0-9]+.0-SNAPSHOT" version.gradle.kts | sed 's/-SNAPSHOT//') + release_branch_name=$(echo $version | sed -E 's,([0-9]+)\.([0-9]+)\.0,release/v\1.\2.x,') + + git push origin HEAD:$release_branch_name + + echo "VERSION=$version" >> $GITHUB_ENV + echo "RELEASE_BRANCH_NAME=$release_branch_name" >> $GITHUB_ENV + + - name: Bump version + run: | + sed -ri "s/$VERSION-SNAPSHOT/$VERSION/" version.gradle.kts + sed -ri "s/$VERSION-alpha-SNAPSHOT/$VERSION-alpha/" version.gradle.kts + + - name: Set git user + run: | + git config user.name opentelemetry-java-bot + git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com + + - name: Create pull request against release branch + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + msg="Prepare release $VERSION" + git commit -a -m "$msg" + git push origin HEAD:prepare-release-$VERSION + gh pr create --title "[$RELEASE_BRANCH_NAME] $msg" \ + --body "$msg" \ + --head prepare-release-$VERSION \ + --base $RELEASE_BRANCH_NAME + + create-pull-request-against-main: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Bump snapshot version + run: | + version=$(grep -Eo "[0-9]+.[0-9]+.0-SNAPSHOT" version.gradle.kts | sed 's/-SNAPSHOT//') + if [[ $version =~ ([0-9]+).([0-9]+).0 ]]; then + major="${BASH_REMATCH[1]}" + minor="${BASH_REMATCH[2]}" + else + echo "unexpected version: $version" + exit 1 + fi + next_version="$major.$((minor + 1)).0" + sed -ri "s/$version-SNAPSHOT/$next_version-SNAPSHOT/" version.gradle.kts + sed -ri "s/$version-apha-SNAPSHOT/$next_version-apha-SNAPSHOT/" version.gradle.kts + + - name: Set git user + run: | + git config user.name opentelemetry-java-bot + git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com + + - name: Create pull request against main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + msg="Bump version" + git commit -a -m "$msg" + git push origin HEAD:bump-snapshot-version + gh pr create --title "$msg" \ + --body "$msg" \ + --head bump-snapshot-version \ + --base main diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml deleted file mode 100644 index 1c5d8d769b..0000000000 --- a/.github/workflows/release-build.yml +++ /dev/null @@ -1,41 +0,0 @@ -# Releases a new minor / major version from the HEAD of the main branch -name: Release Build -on: - workflow_dispatch: - inputs: - version: - description: The version to tag the release with, e.g., 1.2.0, 1.2.1-alpha.1 - required: true - -jobs: - build: - name: Build and release - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-java@v2 - with: - distribution: temurin - java-version: 17 - - - uses: gradle/gradle-build-action@v2 - with: - arguments: | - build - -Prelease.version=${{ github.event.inputs.version }} - - - uses: gradle/gradle-build-action@v2 - name: Publish artifacts - with: - arguments: | - final - closeAndReleaseSonatypeStagingRepository - -Prelease.version=${{ github.event.inputs.version }} - env: - GRGIT_USER: ${{ github.actor }} - GRGIT_PASS: ${{ secrets.GITHUB_TOKEN }} - SONATYPE_USER: ${{ secrets.SONATYPE_USER }} - SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }} - GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} - GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..49b601ee6f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,125 @@ +name: Release +on: + workflow_dispatch: + +jobs: + release: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + + - 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 }} + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }} + + - name: Set versions + id: set-versions + run: | + version=$(grep -Eo "[0-9]+.[0-9]+.[0-9]+" version.gradle.kts | head -1) + 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 + + - name: Generate release notes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if [[ $version == *.0 ]]; then + cat > release-notes.txt << EOF + This release targets the OpenTelemetry SDK $VERSION. + + EOF + else + cat > release-notes.txt << EOF + This is a patch release on the previous $PRIOR_VERSION release, fixing the issue(s) below. + + EOF + fi + + sed -n "/^## Version $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/$GITHUB_REPOSITORY/(pull|issues)/[0-9]+\),#\1," \ + | perl -0pe 's/\n +/ /g' \ + >> release-notes.txt + + if [[ $version == *.0 ]]; then + 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$PRIOR_VERSION v$VERSION >> release-notes.txt + fi + + - name: Create GitHub release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create --target $GITHUB_REF_NAME \ + --title "Version $VERSION" \ + --notes-file release-notes.txt \ + --discussion-category announcements \ + v$VERSION + + - uses: actions/checkout@v3 + with: + ref: main + # history is needed in order to generate the patch + fetch-depth: 0 + + - name: Set git user + run: | + git config user.name opentelemetry-java-bot + git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com + + # this step should be last since it will fail if there have been conflicting + # change log updates introduced on the main branch + - name: Create pull request to merge any change log updates to main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git format-patch --stdout main..$GITHUB_REF_NAME CHANGELOG.md > patch + if [ -s patch ]; then + git apply patch + msg="Merge change log updates from $GITHUB_REF_NAME to main" + git commit -a -m "$msg" + git push origin HEAD:merge-change-log-updates-to-main + gh pr create --title "$msg" \ + --body "$msg" \ + --head merge-change-log-updates-to-main \ + --base main + fi diff --git a/RELEASING.md b/RELEASING.md index 13215aafae..36d48d2572 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -1,34 +1,51 @@ # OpenTelemetry Release Process -## Starting the Release - Before releasing, it is a good idea to run `./gradlew japicmp` on the main branch and verify that there are no unexpected public API changes seen in the `docs/apidiffs/current_vs_latest` directory. -Open the release build workflow in your browser [here](https://github.com/open-telemetry/opentelemetry-java/actions/workflows/release-build.yml). - -You will see a button that says "Run workflow". Press the button, enter the version number you want -to release in the input field that pops up, and then press "Run workflow". - -This triggers the release process, which builds the artifacts. It will not automatically update the -documentation, because the Github Actions cannot push changes to the main branch. - -## Announcement - -Once the GitHub workflow completes, go to -Github [release page](https://github.com/open-telemetry/opentelemetry-java/releases), press -`Draft a new release` to write release notes about the new release. If there is already a draft -release notes, just point it at the created tag. Click "Create a discussion for this release" and -select category "Announcements" to create a corresponding discussion upon publish. - -You can use `git log upstream/v$MAJOR.$((MINOR-1)).x..upstream/v$MAJOR.$MINOR.x --graph --first-parent` +When preparing the change log, you can use +`git log upstream/v$MAJOR.$((MINOR-1)).x..upstream/v$MAJOR.$MINOR.x --graph --first-parent` or the Github [compare tool](https://github.com/open-telemetry/opentelemetry-java/compare/) to view a summary of all commits since last release as a reference. -In addition, you can refer to -[CHANGELOG.md](https://github.com/open-telemetry/opentelemetry-java/blob/main/CHANGELOG.md) -for a list of major changes since last release. +## Preparing a new major or minor release + +* Close the release milestone if there is one. +* Merge a pull request to `main` updating the `CHANGELOG.md`. +* Run the [Prepare release branch workflow](.github/workflows/prepare-release-branch.yml). +* Review and merge the two pull requests that it creates + (one is targeted to the release branch and one is targeted to the `main` branch). + +## Preparing a new patch release + +All patch releases should include only bug-fixes, and must avoid adding/modifying the public APIs. + +In general, patch releases are only made for regressions, memory leaks and deadlocks. + +* Backport pull request(s) to the release branch + * Run the [Backport workflow](.github/workflows/backport.yml). + * Press the "Run workflow" button, then select the release branch from the dropdown list, + e.g. `release/v1.9.x`, then enter the pull request number that you want to backport, + then click the "Run workflow" button below that. + * Review and merge the backport pull request that it generates +* Merge a pull request to the release branch updating the `CHANGELOG.md` +* Run the [Prepare patch release workflow](.github/workflows/prepare-patch-release.yml). + * Press the "Run workflow" button, then select the release branch from the dropdown list, + e.g. `release/v1.9.x`, and click the "Run workflow" button below that. +* Review and merge the pull request that it creates + +## Making the release + +Run the [Release workflow](.github/workflows/release.yml). + +* Press the "Run workflow" button, then select the release branch from the dropdown list, + e.g. `release/v1.9.x`, and click the "Run workflow" button below that. +* This workflow will publish the artifacts to maven central and will publish a GitHub release with + release notes based on the change log and with the javaagent jar attached. +* Lastly, if there were any change log updates in the release branch that need to be merged back to + the main branch, the workflow will create a pull request if the updates can be cleanly applied, + or it will fail this last step if the updates cannot be cleanly applied. ## Update release versions in documentations and CHANGELOG files @@ -52,65 +69,6 @@ Finally, update the [website docs][] to refer to the newly released version. [website docs]: https://github.com/open-telemetry/opentelemetry.io/tree/main/content/en/docs/instrumentation/java -## Patch Release - -All patch releases should include only bug-fixes, and must avoid -adding/modifying the public APIs. - -Open the patch release build workflow in your browser [here](https://github.com/open-telemetry/opentelemetry-java/actions/workflows/patch-release-build.yml). - -You will see a button that says "Run workflow". Press the button, enter the version number you want -to release in the input field for version that pops up and the commits you want to cherrypick for the -patch as a comma-separated list. Then, press "Run workflow". - -If the commits cannot be cleanly applied to the release branch, for example because it has diverged -too much from main, then the workflow will fail before building. In this case, you will need to -prepare the release branch manually. - -This example will assume patching into release branch `v1.2.x` from a git repository with remotes -named `origin` and `upstream`. - -``` -$ git remote -v -origin git@github.com:username/opentelemetry-java.git (fetch) -origin git@github.com:username/opentelemetry-java.git (push) -upstream git@github.com:open-telemetry/opentelemetry-java.git (fetch) -upstream git@github.com:open-telemetry/opentelemetry-java.git (push) -``` - -First, checkout the release branch - -``` -git fetch upstream v1.2.x -git checkout upstream/v1.2.x -``` - -If the release branch does not exist, checkout the tag, create the release branch from it, and push -it to the `upstream`. - -``` -git fetch upstream v1.2.0 -git checkout v1.2.0 -git checkout -b v1.2.x -git push upstream v1.2.x -``` - -Apply cherrypicks manually and commit. It is ok to apply multiple cherrypicks in a single commit. -Use a commit message such as "Manual cherrypick for commits commithash1, commithash2". - -After committing the change, push to your fork's branch. - -``` -git push origin v1.2.x -``` - -Create a PR to have code review and merge this into upstream's release branch. As this was not -applied automatically, we need to do code review to make sure the manual cherrypick is correct. - -After it is merged, Run the patch release workflow again, but leave the commits input field blank. -The release will be made with the current state of the release branch, which is what you prepared -above. - ## Credentials The following credentials are required for publishing (and automatically set in Circle CI): diff --git a/build.gradle.kts b/build.gradle.kts index 5f610770b5..1a62793c79 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,10 +1,8 @@ -import nebula.plugin.release.git.opinion.Strategies import java.time.Duration plugins { id("com.github.ben-manes.versions") id("io.github.gradle-nexus.publish-plugin") - id("nebula.release") id("otel.spotless-conventions") } @@ -18,25 +16,7 @@ if (!JavaVersion.current().isJava11Compatible()) { ) } -// Nebula plugin will not configure if .git doesn't exist, let's allow building on it by stubbing it -// out. This supports building from the zip archive downloaded from GitHub. -var releaseTask: TaskProvider -if (file(".git").exists()) { - release { - defaultVersionStrategy = Strategies.getSNAPSHOT() - } - - nebulaRelease { - addReleaseBranchPattern("""v\d+\.\d+\.x""") - } - - releaseTask = tasks.named("release") - releaseTask.configure { - mustRunAfter("snapshotSetup", "finalSetup") - } -} else { - releaseTask = tasks.register("release") -} +apply(from = "version.gradle.kts") nexusPublishing { packageGroup.set("io.opentelemetry") diff --git a/buildSrc/src/main/kotlin/otel.publish-conventions.gradle.kts b/buildSrc/src/main/kotlin/otel.publish-conventions.gradle.kts index 144b4930ca..cc8cf3a0f5 100644 --- a/buildSrc/src/main/kotlin/otel.publish-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/otel.publish-conventions.gradle.kts @@ -8,12 +8,6 @@ plugins { publishing { publications { register("mavenPublication") { - val release = findProperty("otel.release") - if (release != null) { - val versionParts = version.split('-').toMutableList() - versionParts[0] += "-$release" - version = versionParts.joinToString("-") - } groupId = "io.opentelemetry" afterEvaluate { // not available until evaluated. @@ -63,14 +57,6 @@ publishing { } } -afterEvaluate { - val publishToSonatype by tasks.getting - val release by rootProject.tasks.existing - release.configure { - finalizedBy(publishToSonatype) - } -} - if (System.getenv("CI") != null) { signing { useInMemoryPgpKeys(System.getenv("GPG_PRIVATE_KEY"), System.getenv("GPG_PASSWORD")) diff --git a/docs/common-github-actions-practices.md b/docs/common-github-actions-practices.md index 7855bb8d11..7d4f1a5158 100644 --- a/docs/common-github-actions-practices.md +++ b/docs/common-github-actions-practices.md @@ -27,6 +27,7 @@ Once we agree and implement, will share more broadly across OpenTelemetry - [Prepare patch](#prepare-patch) - [Backporting pull requests to a release branch](#backporting-pull-requests-to-a-release-branch) - [Release](#release) +- [Sending a pull request to another repository](#sending-a-pull-request-to-another-repository) - [Workflow file naming conventions](#workflow-file-naming-conventions) - [Workflow YAML style guide](#workflow-yaml-style-guide) @@ -213,7 +214,9 @@ requests if new misspellings are added to the misspell dictionary. Specification repo uses https://github.com/DavidAnson/markdownlint. -Go repo uses https://github.com/avto-dev/markdown-lint. +Go, JavaScript repos use https://github.com/avto-dev/markdown-lint github action. + +C++ uses markdownlint-cli (which is same that is used by avto-dev/markdown-lint github action). TODO @@ -343,13 +346,13 @@ Here's some sample `RELEASING.md` documentation that goes with the automation be * Backport pull request(s) to the release branch * Run the [Backport workflow](.github/workflows/backport.yml). * Press the "Run workflow" button, then select the release branch from the dropdown list, - e.g. `v1.9.x`, then enter the pull request number that you want to backport, + e.g. `release/v1.9.x`, then enter the pull request number that you want to backport, then click the "Run workflow" button below that. * Review and merge the backport pull request that it generates * Merge a pull request to the release branch updating the `CHANGELOG.md` * Run the [Prepare patch release workflow](.github/workflows/prepare-patch-release.yml). * Press the "Run workflow" button, then select the release branch from the dropdown list, - e.g. `v1.9.x`, and click the "Run workflow" button below that. + e.g. `release/v1.9.x`, and click the "Run workflow" button below that. * Review and merge the pull request that it creates ## Making the release @@ -357,7 +360,7 @@ Here's some sample `RELEASING.md` documentation that goes with the automation be Run the [Release workflow](.github/workflows/release.yml). * Press the "Run workflow" button, then select the release branch from the dropdown list, - e.g. `v1.9.x`, and click the "Run workflow" button below that. + e.g. `release/v1.9.x`, and click the "Run workflow" button below that. * This workflow will publish the artifacts to maven central and will publish a GitHub release with release notes based on the change log. * Lastly, if there were any change log updates in the release branch that need to be merged back @@ -381,7 +384,9 @@ This is what we use in the OpenTelemetry Java repositories: ### Prepare release branch -The specifics depend a lot on your specific version bumping needs. +Uses release branch naming convention `release/v*`. + +The specifics below depend a lot on your specific version bumping needs. For OpenTelemetry Java repositories, the version in the `main` branch always ends with `-SNAPSHOT`, so preparing the release branch involves @@ -397,38 +402,25 @@ on: workflow_dispatch: jobs: - prepare-release-branch: + create-pull-request-against-release-branch: runs-on: ubuntu-latest - outputs: - release-branch-name: ${{ steps.set-release-branch-name.outputs.release-branch-name }} steps: - uses: actions/checkout@v3 - - name: Set release branch name - id: set-release-branch-name - run: | - version=$(...) <-- get the version that is planned to be released - release_branch_name=$(echo $version | sed -E 's/([0-9]+)\.([0-9]+)\.0/v\1.\2.x/') - echo "::set-output name=release-branch-name::$release_branch_name" - - name: Create release branch - env: - RELEASE_BRANCH_NAME: ${{ steps.set-release-branch-name.outputs.release-branch-name }} + id: create-release-branch run: | - git push origin HEAD:$RELEASE_BRANCH_NAME + version=$(...) <-- get the version that is planned to be released + release_branch_name=$(echo $version | sed -E 's,([0-9]+)\.([0-9]+)\.0,release/v\1.\2.x,') - create-pull-request-against-release-branch: - needs: prepare-release-branch - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ needs.prepare-release-branch.outputs.release-branch-name }} + git push origin HEAD:$release_branch_name - - name: Bump version on release branch + echo "VERSION=$version" >> $GITHUB_ENV + echo "RELEASE_BRANCH_NAME=$release_branch_name" >> $GITHUB_ENV + + - name: Bump version run: | - version=$(...) <-- get the minor version that is planning to be released - .github/scripts/update-versions.sh $version-SNAPSHOT $version + .github/scripts/update-versions.sh $VERSION-SNAPSHOT $VERSION - name: Set up git name run: | @@ -439,20 +431,16 @@ jobs: - name: Create pull request against release branch env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RELEASE_BRANCH_NAME: ${{ needs.prepare-release-branch.outputs.release-branch-name }} run: | - msg="Prepare release branch $RELEASE_BRANCH_NAME" + msg="Prepare release $VERSION" git commit -a -m "$msg" - git push origin HEAD:prepare-release-branch-$RELEASE_BRANCH_NAME - gh pr create --title "$msg" \ + git push origin HEAD:prepare-release-$VERSION + gh pr create --title "[$RELEASE_BRANCH_NAME] $msg" \ --body "$msg" \ - --head prepare-release-branch-$RELEASE_BRANCH_NAME \ + --head prepare-release-$VERSION \ --base $RELEASE_BRANCH_NAME create-pull-request-against-main: - needs: - - prepare-release-branch - - create-pull-request-against-release-branch runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -507,8 +495,7 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set versions - id: set-versions + - name: Set environment variables run: | prior_version=$(...) <-- get the prior release version if [[ $prior_version =~ ([0-9]+.[0-9]+).([0-9]+) ]]; then @@ -518,13 +505,10 @@ jobs: echo "unexpected version: $prior_version" exit 1 fi - echo "::set-output name=release-version::$major_minor.$((patch + 1))" - echo "::set-output name=prior-release-version::$prior_version" + echo "VERSION=$major_minor.$((patch + 1))" >> $GITHUB_ENV + echo "PRIOR_VERSION=$prior_version" >> $GITHUB_ENV - name: Bump version - env: - VERSION: ${{ needs.set-versions.outputs.release-version }} - PRIOR_VERSION: ${{ needs.set-versions.outputs.prior-release-version }} run: | .github/scripts/update-versions.sh $PRIOR_VERSION $VERSION @@ -536,15 +520,14 @@ jobs: - name: Create pull request env: - VERSION: ${{ needs.set-versions.outputs.release-version }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - msg="Prepare patch release $VERSION" + msg="Prepare release $VERSION" git commit -a -m "$msg" - git push origin HEAD:prepare-patch-release-$VERSION - gh pr create --title "$msg" \ + git push origin HEAD:prepare-release-$VERSION + gh pr create --title "[$GITHUB_REF_NAME] $msg" \ --body "$msg" \ - --head prepare-patch-release-$VERSION \ + --head prepare-release-$VERSION \ --base $GITHUB_REF_NAME ``` @@ -600,8 +583,7 @@ jobs: #### Autogenerating the release notes ```yaml - - name: Set versions - id: set-versions + - name: Set environment variables run: | version=$(...) <-- get the current version (the one that is being released) if [[ $version =~ ([0-9]+).([0-9]+).([0-9]+) ]]; then @@ -623,13 +605,11 @@ jobs: else prior_version="$major.$minor.$((patch - 1))" fi - echo "::set-output name=release-version::$version" - echo "::set-output name=prior-release-version::$prior_version" + echo "VERSION=$version" >> $GITHUB_ENV + echo "PRIOR_VERSION=$prior_version" >> $GITHUB_ENV - name: Generate release notes env: - VERSION: ${{ steps.set-versions.outputs.release-version }} - PRIOR_VERSION: ${{ steps.set-versions.outputs.prior-release-version }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | if [[ $version != *.0 ]]; then @@ -640,12 +620,12 @@ jobs: fi # TODO this is dependent on the conventions you follow in your CHANGELOG.md - sed -n '/^## Version $VERSION/,/^## Version /p' CHANGELOG.md \ + sed -n "/^## Version $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/$GITHUB_REPOSITORY/(pull|issues)/[0-9]+\),#\1,' \ + | sed -r "s,\[#([0-9]+)]\(https://github.com/$GITHUB_REPOSITORY/(pull|issues)/[0-9]+\),#\1," \ | perl -0pe 's/\n +/ /g' \ >> release-notes.txt ``` @@ -662,7 +642,6 @@ hitting the "Publish release" button). ```yaml - name: Create GitHub release env: - VERSION: ${{ steps.set-versions.outputs.release-version }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh release create --target $GITHUB_REF_NAME \ @@ -672,6 +651,52 @@ hitting the "Publish release" button). v$VERSION ``` +#### Sending a pull request to another repository + +For example to send a PR to notify/update another repository that a new release is available. + +```yaml + - uses: actions/checkout@v3 + with: + repository: opentelemetry-java-bot/opentelemetry-operator + # this is the PAT used for "git push" below + token: ${{ secrets.OPENTELEMETRY_JAVA_BOT_TOKEN }} + + - name: Initialize pull request branch + run: | + git remote add upstream https://github.com/open-telemetry/opentelemetry-operator.git + git fetch upstream + git checkout -b update-opentelemetry-javaagent-to-$VERSION upstream/main + + - name: Bump version + run: | + echo $VERSION > autoinstrumentation/java/version.txt + + - name: Set git user + run: | + git config user.name opentelemetry-java-bot + git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com + + - name: Create pull request against opentelemetry-operator + env: + # this is the PAT used for "gh pr create" below + GITHUB_TOKEN: ${{ secrets.OPENTELEMETRY_JAVA_BOT_TOKEN }} + run: | + msg="Update opentelemetry-javaagent version to $VERSION" + git commit -a -m "$msg" + + # gh pr create doesn't have a way to explicitly specify different head and base + # repositories currently, but it will implicitly pick up the head from a different + # repository if you set up a tracking branch + + git push --set-upstream origin update-opentelemetry-javaagent-to-$VERSION + + gh pr create --title "$msg" \ + --body "$msg" \ + --repo open-telemetry/opentelemetry-operator + --base main +``` + #### Merge back any change log updates to the `main` branch After the release completes, generate a pull request against the `main` branch to merge back any change log diff --git a/settings.gradle.kts b/settings.gradle.kts index adfbdb5a3d..ddf41fe1ad 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -4,7 +4,6 @@ pluginManagement { id("com.github.johnrengelman.shadow") version "7.1.2" id("com.gradle.enterprise") version "3.8.1" id("io.github.gradle-nexus.publish-plugin") version "1.1.0" - id("nebula.release") version "16.0.0" id("org.jetbrains.kotlin.jvm") version "1.6.10" } } diff --git a/version.gradle.kts b/version.gradle.kts new file mode 100644 index 0000000000..f84489f410 --- /dev/null +++ b/version.gradle.kts @@ -0,0 +1,8 @@ +allprojects { + val release = findProperty("otel.release") + if (release != null) { + version = "1.13.0-" + release + "-SNAPSHOT" + } else { + version = "1.13.0-SNAPSHOT" + } +}