55 inputs :
66 version :
77 type : string
8- description : " Version number to release (e.g., 1.2.3, 1.2.3-rc1 , 1.2.0)"
8+ description : " Version number to release (e.g., 1.2.3, 1.2.3rc1 , 1.2.0)"
99 required : true
1010
1111permissions : write-all
@@ -41,10 +41,16 @@ jobs:
4141 env :
4242 VERSION : ${{ github.event.inputs.version }}
4343 run : |
44+ # PEP 440 version regex
45+ VALID_VERSION_REGEX='^([0-9]+\.[0-9]+\.[0-9]+((a|b|rc|\.dev|\.post)[0-9]+)?)$'
46+ if ! [[ $VERSION =~ $VALID_VERSION_REGEX ]]; then
47+ echo "::error::Invalid version string '$VERSION'. Must match PEP 440 (e.g. 1.2.0, 1.2.0rc1, 1.2.0.dev1, 1.2.0a1, 1.2.0b1, 1.2.0.post1)"
48+ exit 1
49+ fi
4450 echo "version=$VERSION" >> $GITHUB_OUTPUT
4551 PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^)
4652 echo "previous_tag=${PREVIOUS_TAG}" >> $GITHUB_OUTPUT
47- if [[ $VERSION =~ -rc ]]; then
53+ if [[ $VERSION =~ rc[0-9]+$ ]]; then
4854 MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
4955 echo "branch_name=v${MAJOR_MINOR_VERSION}.x" >> $GITHUB_OUTPUT
5056 echo "is_rc=true" >> $GITHUB_OUTPUT
@@ -106,7 +112,7 @@ jobs:
106112 docs_release :
107113 runs-on : ubuntu-latest
108114 needs : [lib_release,pre_config]
109- if : ${{ needs.pre_config.outputs.is_rc == 'false' || (needs.pre_config.outputs.is_rc == 'true' && endsWith(needs.pre_config.outputs.version, '.0-rc.1 ')) }}
115+ if : ${{ needs.pre_config.outputs.is_rc == 'false' || (needs.pre_config.outputs.is_rc == 'true' && endsWith(needs.pre_config.outputs.version, '0rc1 ')) }}
110116 environment : release
111117 steps :
112118 - name : " Sync Versions on Read the Docs"
@@ -119,7 +125,7 @@ jobs:
119125 run : |
120126 VERSION=${{ needs.pre_config.outputs.version }}
121127 MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
122- if [[ $VERSION == *- rc* ]]; then
128+ if [[ $VERSION == *rc* ]]; then
123129 DOCS_VERSION="v${MAJOR_MINOR_VERSION}.x"
124130 else
125131 DOCS_VERSION="v$VERSION"
@@ -144,15 +150,15 @@ jobs:
144150 run : |
145151 VERSION=${{ needs.pre_config.outputs.version }}
146152 MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
147- if [[ $VERSION == *- rc* ]]; then
153+ if [[ $VERSION == *rc* ]]; then
148154 DOCS_URL="<https://docs.pycord.dev/en/v${MAJOR_MINOR_VERSION}.x/changelog.html>"
149155 else
150156 DOCS_URL="<https://docs.pycord.dev/en/v$VERSION/changelog.html>"
151157 fi
152158 GITHUB_COMPARE_URL="<https://github.com/Pycord-Development/pycord/compare/${{ needs.pre_config.outputs.previous_tag }}...v$VERSION>"
153159 GITHUB_RELEASE_URL="<https://github.com/Pycord-Development/pycord/releases/tag/v$VERSION>"
154160 PYPI_RELEASE_URL="<https://pypi.org/project/py-cord/$VERSION/>"
155- if [[ $VERSION == *- rc* ]]; then
161+ if [[ $VERSION == *rc* ]]; then
156162 ANNOUNCEMENT="## <:pycord:1063211537008955495> Pycord v${MAJOR_MINOR_VERSION} Release Candidate ($VERSION) is available!\n\n"
157163 ANNOUNCEMENT="${ANNOUNCEMENT}This is a pre-release (release candidate) for testing and feedback.\n\n"
158164 ANNOUNCEMENT="${ANNOUNCEMENT}You can view the changelog here: <$DOCS_URL>\n\n"
@@ -196,7 +202,7 @@ jobs:
196202 close_milestone :
197203 runs-on : ubuntu-latest
198204 needs : [determine_milestone_id,pre_config]
199- if : ${{ !contains(needs.pre_config.outputs.version, '- ') && endsWith(needs.pre_config.outputs.version, '.0') }}
205+ if : ${{ !contains(needs.pre_config.outputs.version, 'rc ') && endsWith(needs.pre_config.outputs.version, '.0') }}
200206 environment : release
201207 env :
202208 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments