Skip to content

Commit d6df0dc

Browse files
authored
chore: refine apecloud create release (#744)
1 parent 2bba7c3 commit d6df0dc

1 file changed

Lines changed: 29 additions & 5 deletions

File tree

.github/workflows/release-create.yml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ on:
1515
default: 'release'
1616

1717
env:
18-
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
18+
GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
1919
RELEASE_VERSION: ${{ github.ref_name }}
20+
RELEASE_NOTES_KEY: "release-notes-${{ github.ref_name }}"
21+
RELEASE_NOTES_FILE: "release-notes-${{ github.ref_name }}.md"
2022

2123
jobs:
2224
create-release:
@@ -33,18 +35,40 @@ jobs:
3335
path: apecloud-cd
3436
ref: ${{ inputs.APECD_REF }}
3537

38+
- name: Restore apecloud Artifact
39+
if: ${{ github.repository == 'apecloud/apecloud' }}
40+
id: cache-artifact-restore
41+
uses: actions/cache/restore@v4
42+
with:
43+
path: |
44+
${{ env.RELEASE_NOTES_FILE }}
45+
key: ${{ env.RELEASE_NOTES_KEY }}
46+
3647
- name: Parse release version and set REL_VERSION
3748
id: get_rel_version
3849
run: |
39-
python ./apecloud-cd/.github/utils/is_rc_or_stable_release_version.py
50+
RELEASE_NOTES_FILE="${{ env.RELEASE_NOTES_FILE }}"
51+
if [[ "${GITHUB_REPOSITORY}" == "apecloud/apecloud" && -f "${RELEASE_NOTES_FILE}" ]]; then
52+
echo WITH_RELEASE_NOTES=true >> $GITHUB_ENV
53+
REL_VERSION="${{ env.RELEASE_VERSION }}"
54+
if [[ "${REL_VERSION}" == "v"* ]]; then
55+
REL_VERSION="${REL_VERSION/v/}"
56+
fi
57+
echo REL_VERSION="${REL_VERSION}" >> $GITHUB_ENV
58+
mkdir -p ./docs/release_notes/v${REL_VERSION}
59+
cp ${RELEASE_NOTES_FILE} ./docs/release_notes/v${REL_VERSION}/v${REL_VERSION}.md
60+
else
61+
python ./apecloud-cd/.github/utils/is_rc_or_stable_release_version.py
62+
fi
63+
4064
echo rel_version=v${{ env.REL_VERSION }} >> $GITHUB_OUTPUT
4165
4266
repo_name=${GITHUB_REPOSITORY#*/}
4367
echo 'REPO_NAME='${repo_name} >> $GITHUB_ENV
4468
4569
- name: release pre-release without release notes
4670
uses: softprops/action-gh-release@v2
47-
if: not ${{ env.WITH_RELEASE_NOTES }}
71+
if: ${{ env.WITH_RELEASE_NOTES != 'true' }}
4872
with:
4973
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
5074
name: ${{ env.REPO_NAME }} v${{ env.REL_VERSION }}
@@ -54,10 +78,10 @@ jobs:
5478

5579
- name: release RC with release notes
5680
uses: softprops/action-gh-release@v2
57-
if: ${{ env.WITH_RELEASE_NOTES }}
81+
if: ${{ env.WITH_RELEASE_NOTES == 'true' }}
5882
with:
5983
body_path: ./docs/release_notes/v${{ env.REL_VERSION }}/v${{ env.REL_VERSION }}.md
60-
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
84+
token: ${{ env.GH_TOKEN }}
6185
name: ${{ env.REPO_NAME }} v${{ env.REL_VERSION }}
6286
tag_name: v${{ env.REL_VERSION }}
6387
prerelease: true

0 commit comments

Comments
 (0)