11name : Releases
22
33on :
4- push :
5- branches :
6- - main
7- - automate-release
8- tags :
9- - ' *.*.*'
4+ workflow_call :
5+ outputs :
6+ release_id :
7+ description : " Tag name to use of release, empty if not needed"
8+ value : ${{ jobs.prepare-release.outputs.release_id }}
109
1110permissions :
1211 contents : read
@@ -18,23 +17,36 @@ jobs:
1817 contents : write
1918 security-events : write
2019
20+ outputs :
21+ release_id : ${{ steps.release_info.outputs.tag }}
22+
2123 steps :
24+ - uses : step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
25+ with :
26+ egress-policy : audit
2227 - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v5.0.0
23-
24- - name : Setup Python
25- uses : actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
28+ - uses : actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
2629 with :
2730 python-version : ' 3.13'
2831
2932 - name : Determine release info
3033 id : release_info
3134 run : |
32- if [[ "${GITHUB_REF}" == "refs/heads/automate-release" ]]; then
33- TAG="latest"
34- else
35- TAG="${GITHUB_REF#refs/tags/}"
36- fi
37- echo "tag=$TAG" >> $GITHUB_OUTPUT
35+ if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
36+ BRANCH="${GITHUB_HEAD_REF}"
37+ else
38+ BRANCH="${GITHUB_REF#refs/heads/}"
39+ fi
40+
41+ if [[ "$BRANCH" == "main" || "$BRANCH" == "automate-release" ]]; then
42+ TAG="latest"
43+ elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then
44+ TAG="${GITHUB_REF#refs/tags/}"
45+ else
46+ TAG=""
47+ fi
48+ echo "tag=$TAG"
49+ echo "tag=$TAG" >> $GITHUB_OUTPUT
3850
3951 - name : Update latest tag
4052 if : github.ref == 'refs/heads/automate-release'
@@ -45,11 +57,13 @@ jobs:
4557 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4658
4759 - name : Generate release notes
60+ if : ${{ steps.release_info.outputs.tag != '' }}
4861 id : notes
4962 run : |
5063 python script/create_release_notes.py
5164
5265 - name : Create release
66+ if : ${{ steps.release_info.outputs.tag != '' }}
5367 uses : softprops/action-gh-release@5122b4edc95f85501a71628a57dc180a03ec7588 # v2.5.0
5468 with :
5569 tag_name : ${{ steps.release_info.outputs.tag }}
0 commit comments