diff --git a/.github/workflows/create-or-update-release-pr.yml b/.github/workflows/create-or-update-release-pr.yml index a028963c3a5..9e74f8e47a5 100644 --- a/.github/workflows/create-or-update-release-pr.yml +++ b/.github/workflows/create-or-update-release-pr.yml @@ -19,30 +19,21 @@ on: - semconv # only semantic convention package permissions: - contents: read + contents: write jobs: create-or-update-release-pr: runs-on: ubuntu-latest steps: - - name: Fork - run: gh repo fork open-telemetry/opentelemetry-js - env: - GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} + - uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 + id: otelbot-token + with: + app-id: ${{ vars.OTELBOT_APP_ID }} + private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }} - name: Checkout uses: actions/checkout@v4 with: - repository: opentelemetrybot/opentelemetry-js - ref: main - token: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} - - name: Sync with upstream - run: | - git remote show origin - git remote add upstream https://github.com/open-telemetry/opentelemetry-js.git - git fetch upstream - git reset --hard upstream/main - git push origin main --force - + token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/setup-node@v4 with: cache: 'npm' @@ -52,14 +43,52 @@ jobs: - run: npm ci - - name: Create/Update Release PR + - name: Update Release Branch run: | - git config user.name opentelemetrybot - git config user.email 107717825+opentelemetrybot@users.noreply.github.com - npm run github:create_or_update_release_pr + git config user.name otelbot + git config user.email 197425009+otelbot@users.noreply.github.com + # Set up remotes for the script + git remote add upstream https://github.com/open-telemetry/opentelemetry-js.git + # Manual implementation of _github:update_release_branch with otelbot branch prefix + npm run _verify_release_kind + npm run _verify_release_remote + git checkout main + git pull upstream main + git branch -D otelbot/release/next-version || true + git checkout -b otelbot/release/next-version + npm run prepare_release:$RELEASE_KIND + git commit -am "chore: prepare release" + git push --set-upstream $RELEASE_PR_REMOTE --force otelbot/release/next-version env: - GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} RELEASE_SCOPE: ${{ github.event.inputs.release_scope }} RELEASE_KIND: ${{ github.event.inputs.release_scope }}:${{ github.event.inputs.release_type }} RELEASE_PR_REMOTE: origin - RELEASE_PR_OWNER: opentelemetrybot + RELEASE_PR_OWNER: otelbot + + - name: Create/Update Release PR + run: | + # Create PR using otelbot token to trigger workflows + gh pr create --repo open-telemetry/opentelemetry-js --head otelbot/release/next-version --base main --title 'chore: prepare next release' --body '' || true + # Extract release notes based on scope + case "$RELEASE_SCOPE" in + "all") + node scripts/extract-latest-release-notes.js api/CHANGELOG.md ./CHANGELOG.md experimental/CHANGELOG.md + ;; + "sdk") + node scripts/extract-latest-release-notes.js ./CHANGELOG.md experimental/CHANGELOG.md + ;; + "experimental") + node scripts/extract-latest-release-notes.js experimental/CHANGELOG.md + ;; + "semconv") + node scripts/extract-latest-release-notes.js semantic-conventions/CHANGELOG.md + ;; + esac + # Update PR body with release notes + gh pr edit --repo open-telemetry/opentelemetry-js otelbot/release/next-version --body-file ./.tmp/release-notes.md || echo "Could not update PR body, continuing..." + env: + GITHUB_TOKEN: ${{ steps.otelbot-token.outputs.token }} + GH_TOKEN: ${{ steps.otelbot-token.outputs.token }} + RELEASE_SCOPE: ${{ github.event.inputs.release_scope }} + RELEASE_PR_OWNER: otelbot diff --git a/.github/workflows/survey-on-merged-pr.yml b/.github/workflows/survey-on-merged-pr.yml index eb54bdac9a0..020ebe1b07a 100644 --- a/.github/workflows/survey-on-merged-pr.yml +++ b/.github/workflows/survey-on-merged-pr.yml @@ -21,6 +21,11 @@ jobs: if: github.event.pull_request.merged == true steps: - uses: actions/checkout@v4 + - uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 + id: otelbot-token + with: + app-id: ${{ vars.OTELBOT_APP_ID }} + private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }} - name: Check if user is a member of the org id: check-membership run: | @@ -33,7 +38,7 @@ jobs: echo "MEMBER_FOUND=false" >> $GITHUB_ENV fi env: - GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} + GH_TOKEN: ${{ steps.otelbot-token.outputs.token }} - name: Add comment to PR if author is not a member if: env.MEMBER_FOUND == 'false' @@ -41,4 +46,4 @@ jobs: USERNAME=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH") gh pr comment ${PR_NUM} --repo open-telemetry/opentelemetry-js --body "Thank you for your contribution @${USERNAME}! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this [survey](${SURVEY_URL})." env: - GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} \ No newline at end of file + GH_TOKEN: ${{ steps.otelbot-token.outputs.token }} \ No newline at end of file diff --git a/doc/contributing/releasing.md b/doc/contributing/releasing.md index 18246c3cf88..749bcae3dac 100644 --- a/doc/contributing/releasing.md +++ b/doc/contributing/releasing.md @@ -20,7 +20,7 @@ We aim to eventually automate this process as much as possible. ## 2. Review and merge the release PR -1. Review the PR generated via the workflow (it will be titled `chore: prepare next release` and opened by the @opentelemetrybot user) +1. Review the PR generated via the workflow (it will be titled `chore: prepare next release` and opened by the @otelbot[bot] user) 2. Once approved, merge the PR ## 3. Publish to NPM