Skip to content

Commit 66deb4f

Browse files
committed
Simplify draft release version retrieval logic.
Replaced `actions/github-script` with a direct `gh api` call to fetch the latest draft release title.
1 parent f2e817c commit 66deb4f

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

.github/workflows/release.yml

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,18 @@ jobs:
2222
if: github.event.inputs.version != null
2323
run: echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
2424

25-
- uses: actions/github-script@v7
25+
- name: Get latest draft release title
2626
if: github.event.inputs.version == null
27-
id: candidate-version
28-
with:
29-
github-token: ${{secrets.GITHUB_TOKEN}}
30-
result-encoding: string
31-
script: |
32-
const list = await github.rest.repos.listReleases({
33-
owner: "domaframework",
34-
repo: "doma",
35-
});
36-
console.log(list)
37-
return list.data[0].name
38-
39-
- name: Assign candidate version
40-
if: github.event.inputs.version == null
41-
run: echo "RELEASE_VERSION=${{ steps.candidate-version.outputs.result }}" >> $GITHUB_ENV
27+
run: |
28+
TITLE=$(gh api repos/${{ github.repository }}/releases \
29+
--jq '.[] | select(.draft==true) | .name' | head -n 1)
30+
if [[ -z "$TITLE" ]]; then
31+
echo "No draft release found."
32+
exit 1
33+
fi
34+
echo "RELEASE_VERSION=$TITLE" >> $GITHUB_ENV
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4237

4338
- name: Set up the latest LTS JDK
4439
uses: actions/setup-java@v4

0 commit comments

Comments
 (0)