diff --git a/.github/workflows/releasepr.yml b/.github/workflows/releasepr.yml index f062e0fa..6a86679b 100644 --- a/.github/workflows/releasepr.yml +++ b/.github/workflows/releasepr.yml @@ -12,7 +12,12 @@ jobs: steps: - name: Checkout uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 - + with: + # Read-only checkout: the default token is never persisted into the git + # config. The write-capable app token is only introduced at the push + # step below. + persist-credentials: false + - name: Get package info shell: bash id: package-info @@ -34,18 +39,31 @@ jobs: return releaseWithTag ? 'true' : 'false' result-encoding: string - - name: Make changes to pull request + - name: Create release pull request if: steps.pre-release-exists.outputs.result == 'true' - run: date +%s > auto-release.log + env: + APP_VERSION: ${{ steps.package-info.outputs.version }} + GH_TOKEN: ${{ secrets.JLAB_APP_TOKEN }} + run: | + set -eux + # git checkout -b fails if the branch already exists, which keeps a + # re-run from opening a duplicate release PR. + BRANCH_NAME="release-v${APP_VERSION}" + git checkout -b "${BRANCH_NAME}" + git config user.name "JupyterLab Desktop Bot" + git config user.email 'jupyterlab-bot@users.noreply.github.com' - - name: Create Release pull request - if: steps.pre-release-exists.outputs.result == 'true' - uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6 - with: - token: ${{ secrets.JLAB_APP_TOKEN }} - commit-message: Update auto-release logs - branch: release-v${{ steps.package-info.outputs.version}} - title: 'Release v${{ steps.package-info.outputs.version}}' - body: | - Release v${{ steps.package-info.outputs.version}} - draft: false + date +%s > auto-release.log + git add auto-release.log + git commit -m "Update auto-release logs" + # Checkout ran with persist-credentials: false. Wire the app token in + # through gh's credential helper just for this push, so it never lands + # in the git config or the command log; git push then uses GH_TOKEN. + gh auth setup-git + git push origin "HEAD:refs/heads/${BRANCH_NAME}" + + gh pr create \ + --head "${BRANCH_NAME}" \ + --base "${GITHUB_REF_NAME}" \ + --title "Release v${APP_VERSION}" \ + --body "Release v${APP_VERSION}"