Skip to content

Commit b32481c

Browse files
committed
Fix checkout step in GH release action
1 parent 2d111ba commit b32481c

1 file changed

Lines changed: 25 additions & 25 deletions

File tree

.github/workflows/release-and-deploy.yml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
# releases the project with specified version
44
# deploys it to the sonatype staging repo
55
name: Release and deploy to Sonatype staging repo
6+
67
env:
78
GITHUB_PAT: ${{ secrets.QUDTLIB_BOT_GITHUB_TOKEN }}
89
MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
910
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
1011
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
12+
1113
on:
1214
workflow_dispatch:
1315
inputs:
@@ -19,15 +21,6 @@ on:
1921
description: 'Next SNAPSHOT version (such as 2.4-SNAPSHOT)'
2022
required: true
2123
type: string
22-
secrets:
23-
QUDTLIB_BOT_GITHUB_TOKEN:
24-
required: true
25-
MAVEN_USERNAME:
26-
required: true
27-
MAVEN_CENTRAL_TOKEN:
28-
required: true
29-
MAVEN_GPG_PASSPHRASE:
30-
required: true
3124

3225
jobs:
3326
build:
@@ -37,6 +30,25 @@ jobs:
3730
pull-requests: write
3831

3932
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v6
35+
with:
36+
token: ${{ secrets.QUDTLIB_BOT_GITHUB_TOKEN }}
37+
fetch-depth: 0
38+
persist-credentials: true
39+
40+
# Critical fix for "could not read Username" and duplicate header issues
41+
- name: Configure Git credentials (insteadOf)
42+
run: |
43+
git config --global url."https://${{ secrets.QUDTLIB_BOT_GITHUB_TOKEN }}@github.com/".insteadOf "https://github.com/"
44+
45+
# Extra safety - remove any conflicting extraheader
46+
- name: Fix git authentication headers
47+
run: |
48+
git config --global --unset http.https://github.com/.extraheader || true
49+
git config --local --unset http.https://github.com/.extraheader || true
50+
51+
# Check write access to repo
4052
- name: Check write access to repo
4153
run: |
4254
token_login=$(curl -H "Authorization: Bearer ${token}" https://api.github.com/user | jq -r '.login')
@@ -57,26 +69,14 @@ jobs:
5769
tag: v${{ inputs.release_version }}
5870
env:
5971
GITHUB_TOKEN: ${{ secrets.QUDTLIB_BOT_GITHUB_TOKEN }}
72+
6073
- name: Fail if tag v${{ inputs.release_version }} exists
6174
if: steps.checkTag.outputs.exists == 'true'
6275
run: |
6376
echo Tag v${{ inputs.release_version }} already exists, release aborted >> $GITHUB_STEP_SUMMARY
6477
exit 1
6578
66-
67-
68-
# Set up java with maven cache
69-
- name: Checkout
70-
uses: actions/checkout@v6
71-
with:
72-
token: ${{ secrets.QUDTLIB_BOT_GITHUB_TOKEN }}
73-
fetch-depth: 0
74-
75-
- name: Fix git authentication headers
76-
run: |
77-
git config --global --unset http.https://github.com/.extraheader || true
78-
git config --local --unset http.https://github.com/.extraheader || true
79-
79+
# Set up Java + Maven
8080
- name: Set up JDK 21
8181
uses: actions/setup-java@v5
8282
with:
@@ -182,8 +182,8 @@ jobs:
182182
# Next Steps
183183
184184
Please rebase this PR on top of `main` after publishing the release via the
185-
[Sonatype Repository Manager](https://central.sonatype.com/publishing/deployments).
185+
[Sonatype Repository Manager](https://central.sonatype.com/publishing/deployments).
186186
187187
# print the summary
188188
- name: Print summary
189-
run: echo "Release ${{ inputs.release_version }} deployed to sonatype staging repo. Please go there, close the repo and publish it." >> $GITHUB_STEP_SUMMARY
189+
run: echo "Release ${{ inputs.release_version }} deployed to sonatype staging repo. Please go there, close the repo and publish it." >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)