5
5
inputs :
6
6
version :
7
7
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)"
9
9
required : true
10
10
11
11
permissions : write-all
@@ -41,10 +41,16 @@ jobs:
41
41
env :
42
42
VERSION : ${{ github.event.inputs.version }}
43
43
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
44
50
echo "version=$VERSION" >> $GITHUB_OUTPUT
45
51
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^)
46
52
echo "previous_tag=${PREVIOUS_TAG}" >> $GITHUB_OUTPUT
47
- if [[ $VERSION =~ -rc ]]; then
53
+ if [[ $VERSION =~ rc[0-9]+$ ]]; then
48
54
MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
49
55
echo "branch_name=v${MAJOR_MINOR_VERSION}.x" >> $GITHUB_OUTPUT
50
56
echo "is_rc=true" >> $GITHUB_OUTPUT
@@ -106,7 +112,7 @@ jobs:
106
112
docs_release :
107
113
runs-on : ubuntu-latest
108
114
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 ')) }}
110
116
environment : release
111
117
steps :
112
118
- name : " Sync Versions on Read the Docs"
@@ -119,7 +125,7 @@ jobs:
119
125
run : |
120
126
VERSION=${{ needs.pre_config.outputs.version }}
121
127
MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
122
- if [[ $VERSION == *- rc* ]]; then
128
+ if [[ $VERSION == *rc* ]]; then
123
129
DOCS_VERSION="v${MAJOR_MINOR_VERSION}.x"
124
130
else
125
131
DOCS_VERSION="v$VERSION"
@@ -144,15 +150,15 @@ jobs:
144
150
run : |
145
151
VERSION=${{ needs.pre_config.outputs.version }}
146
152
MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
147
- if [[ $VERSION == *- rc* ]]; then
153
+ if [[ $VERSION == *rc* ]]; then
148
154
DOCS_URL="<https://docs.pycord.dev/en/v${MAJOR_MINOR_VERSION}.x/changelog.html>"
149
155
else
150
156
DOCS_URL="<https://docs.pycord.dev/en/v$VERSION/changelog.html>"
151
157
fi
152
158
GITHUB_COMPARE_URL="<https://github.com/Pycord-Development/pycord/compare/${{ needs.pre_config.outputs.previous_tag }}...v$VERSION>"
153
159
GITHUB_RELEASE_URL="<https://github.com/Pycord-Development/pycord/releases/tag/v$VERSION>"
154
160
PYPI_RELEASE_URL="<https://pypi.org/project/py-cord/$VERSION/>"
155
- if [[ $VERSION == *- rc* ]]; then
161
+ if [[ $VERSION == *rc* ]]; then
156
162
ANNOUNCEMENT="## <:pycord:1063211537008955495> Pycord v${MAJOR_MINOR_VERSION} Release Candidate ($VERSION) is available!\n\n"
157
163
ANNOUNCEMENT="${ANNOUNCEMENT}This is a pre-release (release candidate) for testing and feedback.\n\n"
158
164
ANNOUNCEMENT="${ANNOUNCEMENT}You can view the changelog here: <$DOCS_URL>\n\n"
@@ -196,7 +202,7 @@ jobs:
196
202
close_milestone :
197
203
runs-on : ubuntu-latest
198
204
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') }}
200
206
environment : release
201
207
env :
202
208
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments