Skip to content

Commit 4272e87

Browse files
security: harden release workflow and declare workflow_call secrets
- Replace actions/checkout v4.3.1 with v6.0.3 and switch from PERSONAL_ACCESS_TOKEN to GITHUB_TOKEN - Fix script injection in Download CLI, Tag, Update POM, Build artifactId, and Publish steps by moving inputs to env vars - Replace deprecated ::set-output with $GITHUB_OUTPUT in Tag step - Update actions/setup-java v4.3.0 to v5.2.0 - Add explicit secrets declaration for workflow_call (MAVEN_GPG_PASSPHRASE, MAVEN_GPG_PRIVATE_KEY, OSSRH_TOKEN, OSSRH_USERNAME) - Fix broken shell conditional in Build artifactId property step
1 parent 6661e60 commit 4272e87

1 file changed

Lines changed: 28 additions & 14 deletions

File tree

.github/workflows/release.yml

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ on:
4141
required: false
4242
default: false
4343
type: boolean
44+
secrets:
45+
MAVEN_GPG_PASSPHRASE:
46+
required: true
47+
MAVEN_GPG_PRIVATE_KEY:
48+
required: true
49+
OSSRH_TOKEN:
50+
required: true
51+
OSSRH_USERNAME:
52+
required: true
4453

4554
permissions:
4655
contents: read
@@ -56,16 +65,18 @@ jobs:
5665
TAG_NAME: ${{ steps.set_tag_name.outputs.TAG_NAME }}
5766
steps:
5867
- name: Checkout
59-
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
68+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
6069
with:
61-
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
70+
token: ${{ secrets.GITHUB_TOKEN }}
6271
lfs: true
6372

6473
- name: Download CLI
6574
if: inputs.cliTag
75+
env:
76+
INPUT_CLI_TAG: ${{ inputs.cliTag }}
6677
run: |
6778
chmod +x ./.github/scripts/update_cli.sh
68-
./.github/scripts/update_cli.sh ${{ inputs.cliTag }}
79+
./.github/scripts/update_cli.sh "$INPUT_CLI_TAG"
6980
7081
- name: Extract CLI version
7182
id: extract_cli_version
@@ -92,19 +103,19 @@ jobs:
92103
93104
- name: Tag
94105
id: set_tag_name
106+
env:
107+
INPUT_TAG: ${{ inputs.tag }}
95108
run: |
96-
echo ${{ inputs.tag }}
97-
tag=${{ inputs.tag }}
98-
echo "RELEASE_VERSION=${{ inputs.tag }}" >> $GITHUB_ENV
99-
message='${{ inputs.tag }}'
109+
echo "$INPUT_TAG"
110+
echo "RELEASE_VERSION=$INPUT_TAG" >> $GITHUB_ENV
100111
git config user.name "${GITHUB_ACTOR}"
101112
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
102-
git tag -a "${tag}" -m "${message}"
103-
git push origin "${tag}"
104-
echo "TAG_NAME=${{ inputs.tag }}" >> $GITHUB_OUTPUT
113+
git tag -a "$INPUT_TAG" -m "$INPUT_TAG"
114+
git push origin "$INPUT_TAG"
115+
echo "TAG_NAME=$INPUT_TAG" >> $GITHUB_OUTPUT
105116
106117
- name: Set up Maven Central Repository
107-
uses: actions/setup-java@2dfa2011c5b2a0f1489bf9e433881c92c1631f88 # v4.3.0
118+
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
108119
with:
109120
java-version: '11'
110121
distribution: 'temurin'
@@ -115,19 +126,22 @@ jobs:
115126
gpg-passphrase: MAVEN_GPG_PASSPHRASE
116127

117128
- name: Update the POM version.
118-
run: mvn -B versions:set -DnewVersion='${{ env.RELEASE_VERSION }}' --file pom.xml -DskipTests
129+
run: mvn -B versions:set -DnewVersion="$RELEASE_VERSION" --file pom.xml -DskipTests
119130

120131
- name: Build artifactId property
132+
env:
133+
INPUT_DEV: ${{ inputs.dev }}
134+
INPUT_TAG: ${{ inputs.tag }}
121135
run: |
122136
prop=''
123-
if [ ${{ inputs.dev }} = true ] && ![ "${{ inputs.tag }}" = "1.0.0-SNAPSHOT" ]; then
137+
if [ "$INPUT_DEV" = "true" ] && [ "$INPUT_TAG" != "1.0.0-SNAPSHOT" ]; then
124138
prop='-Dast.wrapper.id=ast-cli-java-wrapper-dev'
125139
fi
126140
echo "AID_PROP=${prop}" >> $GITHUB_ENV
127141
128142
- name: Publish package
129143
if: inputs.publish == true
130-
run: mvn --batch-mode deploy -DskipTests ${{ env.AID_PROP }}
144+
run: mvn --batch-mode deploy -DskipTests $AID_PROP
131145
env:
132146
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
133147
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}

0 commit comments

Comments
 (0)