Skip to content

Commit 0038b5e

Browse files
committed
chore(release): use GitHub App token for releases
1 parent f2376f2 commit 0038b5e

6 files changed

Lines changed: 40 additions & 5 deletions

File tree

.github/scripts/create-release-branch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ fi
2727
require_missing_remote_branch "${maintenance_branch}"
2828
require_remote_branch "${source_branch}"
2929

30-
configure_git_credentials
3130
git fetch origin "+refs/heads/${source_branch}:refs/remotes/origin/${source_branch}" --tags
3231
git rev-parse --verify --end-of-options "${source_ref}^{commit}" >/dev/null
3332
if ! git merge-base --is-ancestor -- "${source_ref}^{commit}" "origin/${source_branch}"; then
3433
echo "Source ref ${source_ref} is not reachable from origin/${source_branch}."
3534
exit 1
3635
fi
36+
configure_git_credentials
3737
git push origin "${source_ref}^{commit}:refs/heads/${maintenance_branch}"
3838
gh issue comment "${ISSUE_NUMBER}" --body "Created ${maintenance_branch} from ${source_ref}."

.github/scripts/prepare-release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ require_remote_branch "${target_branch}"
2424
require_missing_remote_branch "${work_branch}"
2525

2626
configure_git_author
27-
configure_git_credentials
2827
git fetch origin "+refs/heads/${target_branch}:refs/remotes/origin/${target_branch}" --tags
2928
git checkout -B "${work_branch}" "origin/${target_branch}"
3029

@@ -34,6 +33,7 @@ git checkout -B "${work_branch}" "origin/${target_branch}"
3433
-Prelease.releaseVersion="${release_version}" \
3534
-Prelease.newVersion="${next_version}"
3635

36+
configure_git_credentials
3737
git push origin "HEAD:refs/heads/${work_branch}"
3838

3939
{

.github/scripts/publish-release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ fi
6262
gh pr checks "${pr_number}" --required --fail-fast
6363

6464
configure_git_author
65-
configure_git_credentials
6665
git fetch origin \
6766
"+refs/heads/${target_branch}:refs/remotes/origin/${target_branch}" \
6867
"+refs/heads/${work_branch}:refs/remotes/origin/${work_branch}" \
@@ -106,5 +105,6 @@ if [[ "$(git cat-file -t "${tag_name}")" != "tag" ]]; then
106105
exit 1
107106
fi
108107

108+
configure_git_credentials
109109
git push --atomic --follow-tags origin "refs/remotes/origin/${work_branch}:refs/heads/${target_branch}"
110110
gh issue comment "${ISSUE_NUMBER}" --body "Published ${tag_name} to ${target_branch}."

.github/workflows/release-branch.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ jobs:
1818
GH_TOKEN: ${{ github.token }}
1919
ISSUE_BODY: ${{ github.event.issue.body }}
2020
ISSUE_NUMBER: ${{ github.event.issue.number }}
21-
PUSH_TOKEN: ${{ github.token }}
2221
RELEASE_ACTOR: ${{ github.event.sender.login }}
2322
steps:
2423
- name: Checkout
@@ -28,11 +27,27 @@ jobs:
2827
fetch-tags: true
2928
persist-credentials: false
3029

30+
- name: Authorize release actor
31+
run: bash -c 'source .github/scripts/release-common.sh; require_maintainer'
32+
33+
- name: Create release app token
34+
id: release-app-token
35+
uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4
36+
with:
37+
app-id: ${{ secrets.RELEASE_APP_ID }}
38+
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
39+
owner: ${{ github.repository_owner }}
40+
repositories: ${{ github.event.repository.name }}
41+
3142
- name: Create branch
43+
env:
44+
PUSH_TOKEN: ${{ steps.release-app-token.outputs.token }}
3245
run: |
3346
set -o pipefail
3447
bash .github/scripts/create-release-branch.sh 2>&1 | tee "${RUNNER_TEMP}/release-branch.log"
3548
3649
- name: Comment on failure
3750
if: failure()
51+
env:
52+
PUSH_TOKEN: ${{ steps.release-app-token.outputs.token }}
3853
run: bash .github/scripts/comment-issue-failure.sh "${RUNNER_TEMP}/release-branch.log" "Create release branch"

.github/workflows/release-prepare.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ jobs:
1919
GH_TOKEN: ${{ github.token }}
2020
ISSUE_BODY: ${{ github.event.issue.body }}
2121
ISSUE_NUMBER: ${{ github.event.issue.number }}
22-
PUSH_TOKEN: ${{ github.token }}
2322
RELEASE_ACTOR: ${{ github.event.sender.login }}
2423
steps:
2524
- name: Checkout
@@ -29,6 +28,9 @@ jobs:
2928
fetch-tags: true
3029
persist-credentials: false
3130

31+
- name: Authorize release actor
32+
run: bash -c 'source .github/scripts/release-common.sh; require_maintainer'
33+
3234
- name: Set up JDK
3335
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
3436
with:
@@ -40,13 +42,26 @@ jobs:
4042
with:
4143
validate-wrappers: true
4244

45+
- name: Create release app token
46+
id: release-app-token
47+
uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4
48+
with:
49+
app-id: ${{ secrets.RELEASE_APP_ID }}
50+
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
51+
owner: ${{ github.repository_owner }}
52+
repositories: ${{ github.event.repository.name }}
53+
4354
- name: Prepare release branch
4455
id: release
56+
env:
57+
PUSH_TOKEN: ${{ steps.release-app-token.outputs.token }}
4558
run: |
4659
set -o pipefail
4760
bash .github/scripts/prepare-release.sh 2>&1 | tee "${RUNNER_TEMP}/release-prepare.log"
4861
4962
- name: Open or update release pull request
63+
env:
64+
GH_TOKEN: ${{ steps.release-app-token.outputs.token }}
5065
run: |
5166
set -o pipefail
5267
bash .github/scripts/upsert-release-pr.sh \
@@ -59,4 +74,6 @@ jobs:
5974
6075
- name: Comment on failure
6176
if: failure()
77+
env:
78+
PUSH_TOKEN: ${{ steps.release-app-token.outputs.token }}
6279
run: bash .github/scripts/comment-issue-failure.sh "${RUNNER_TEMP}/release-prepare.log" "Prepare release"

.github/workflows/release-publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ jobs:
3030
fetch-tags: true
3131
persist-credentials: false
3232

33+
- name: Authorize release actor
34+
run: bash -c 'source .github/scripts/release-common.sh; require_maintainer'
35+
3336
- name: Create release app token
3437
id: release-app-token
3538
uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4

0 commit comments

Comments
 (0)