@@ -25,19 +25,23 @@ jobs:
25
25
needs : [safety_check]
26
26
outputs :
27
27
branch_name : ${{ steps.determine_vars.outputs.branch_name }}
28
- is_rc : ${{ steps.determine_vars.outputs.version }}
29
- version : ${{ steps.determine_vars.outputs.is_rc }}
28
+ is_rc : ${{ steps.determine_vars.outputs.is_rc }}
29
+ version : ${{ steps.determine_vars.outputs.version }}
30
30
previous_tag : ${{ steps.determine_vars.outputs.previous_tag }}
31
- runs-on : ububtu -latest
31
+ runs-on : ubuntu -latest
32
32
steps :
33
33
- name : " Checkout Repository"
34
34
uses : actions/checkout@v4
35
+ with :
36
+ fetch-depth : 0
37
+ fetch-tags : true
35
38
36
39
- name : " Determine Push Branch"
37
40
id : determine_vars
41
+ env :
42
+ VERSION : ${{ github.event.inputs.version }}
38
43
run : |
39
- VERSION=${{ github.event.inputs.version }}
40
- echo "version=${VERSION}" >> $GITHUB_OUTPUT
44
+ echo "version=$VERSION" >> $GITHUB_OUTPUT
41
45
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^)
42
46
echo "previous_tag=${PREVIOUS_TAG}" >> $GITHUB_OUTPUT
43
47
if [[ $VERSION =~ -rc ]]; then
@@ -63,167 +67,70 @@ jobs:
63
67
steps :
64
68
- name : " Checkout Repository"
65
69
uses : actions/checkout@v4
66
-
67
- - name : " Setup Python"
68
- uses : actions/setup-python@v5
69
- with :
70
- python-version : " 3.12"
71
- cache : " pip"
72
- cache-dependency-path : " requirements/_release.txt"
73
-
74
- - name : " Install Release Dependencies"
75
- run : |
76
- python -m pip install --upgrade pip
77
- pip install -r requirements/_release.txt
78
-
79
- - name : " Prepare and Update CHANGELOG.md"
80
- run : |
81
- VERSION=${{ needs.pre_config.outputs.version }}
82
- DATE=$(date +'%Y-%m-%d')
83
- sed -i "s/## \[Unreleased\]/## [$VERSION] - $DATE/" CHANGELOG.md
84
- sed -i "0,/## \[$VERSION\]/ s|## \[$VERSION\]|## [Unreleased]\n\n### Added\n\n### Changed\n\n### Fixed\n\n### Removed\n\n$&|" CHANGELOG.md
85
- sed -i "s|\[Unreleased\]:.*|[Unreleased]: https://github.com/Pycord-Development/pycord/compare/v$VERSION...HEAD\n[$VERSION]: https://github.com/Pycord-Development/pycord/compare/v$(git describe --tags --abbrev=0 @^)...v$VERSION|" CHANGELOG.md
86
- echo "[Unreleased]: https://github.com/Pycord-Development/pycord/compare/v$VERSION...HEAD" >> CHANGELOG.md
87
- git add CHANGELOG.md
88
- git commit -m "chore(release): update CHANGELOG for version $VERSION"
89
-
90
- - name : " Commit and Push Changelog to Master"
91
- run : |
92
- git config user.name "GitHub Actions"
93
- git config user.email "[email protected] "
94
- git add CHANGELOG.md
95
- git commit -m "chore(release): update CHANGELOG for version ${{ needs.pre_config.outputs.version }}"
96
- git push origin HEAD:master
97
-
98
- - name : " Push Changelog to Version Branch"
99
- run : |
100
- git push origin HEAD:${{ needs.pre_config.outputs.branch_name }}
101
-
102
- - name : " Create Git Tag"
103
- run : |
104
- git config user.name "GitHub Actions"
105
- git config user.email "[email protected] "
106
- VERSION=${{ needs.pre_config.outputs.version }}
107
- git tag -s v$VERSION -m "Release version $VERSION"
108
- git push origin v$VERSION
109
-
110
- - name : " Verify Version"
111
- run : python -m setuptools_scm
112
-
113
- - name : " Build Package"
114
- run : |
115
- python3 -m build --sdist
116
- python3 -m build --wheel
117
-
118
- - name : " Create GitHub Release"
119
-
120
70
with :
121
- tag_name : " v${{ needs.pre_config.outputs.version }}"
122
- name : " v${{ needs.pre_config.outputs.version }}"
123
- generate_release_notes : true
124
- draft : false
125
- prerelease : ${{ needs.pre_config.outputs.is_rc == 'true' }}
126
- files : |
127
- dist/*.whl
128
- dist/*.tar.gz
129
- token : ${{ secrets.GITHUB_TOKEN }}
130
- make_latest : true
71
+ fetch-depth : 0
72
+ fetch-tags : true
131
73
132
- - name : " Publish package distributions to PyPI"
133
-
134
- env :
135
- name : pypi
136
- url : https://pypi.org/p/pycord
74
+ - name : " Release Pycord"
75
+ id : pycord-release
76
+ uses :
Aiko-IT-Systems/[email protected]
137
77
with :
138
- password : ${{ secrets.PYPI_TOKEN }}
139
-
140
- docs_release :
141
- runs-on : ubuntu-latest
142
- needs : [lib_release,pre_config]
143
- if : needs.pre_config.outputs.is_rc == 'false' || (needs.pre_config.outputs.is_rc == 'true' && endsWith(needs.pre_config.outputs.version, '.0-rc1'))
144
- environment : release
145
- steps :
146
- - name : " Sync Versions on Read the Docs"
147
- run : |
148
- curl --location --request POST 'https://readthedocs.org/api/v3/projects/pycord/sync-versions/' \
149
- --header 'Content-Type: application/json' \
150
- --header "Authorization: Token ${{ secrets.READTHEDOCS_TOKEN }}"
78
+ github-token : ${{ secrets.GITHUB_TOKEN }}
79
+ pypi-token : ${{ secrets.PYPI_TOKEN }}
80
+ version-branch-name : ${{ needs.pre_config.outputs.branch_name }}
81
+ ref : ${{ github.ref_name }}
82
+ repository : ${{ github.repository }}
83
+ python-version : " 3.12"
84
+ release-requirements : " requirements/_release.txt"
85
+ version : ${{ needs.pre_config.outputs.version }}
86
+ is-rc : ${{ needs.pre_config.outputs.is_rc }}
87
+ pypi-package : " py-cord"
151
88
152
- - name : " Activate and Show Version on Read the Docs"
153
- run : |
154
- VERSION=${{ needs.pre_config.outputs.version }}
155
- MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
156
- PATCH_VERSION=${VERSION##*.}
157
- if [[ $PATCH_VERSION =~ ^[0-9]+$ ]]; then
158
- DOCS_VERSION="v$VERSION"
159
- else
160
- DOCS_VERSION="v$MAJOR_MINOR_VERSION.x"
161
- fi
162
- curl --location --request PATCH "https://readthedocs.org/api/v3/projects/pycord/versions/$DOCS_VERSION/" \
163
- --header 'Content-Type: application/json' \
164
- --header "Authorization: Token ${{ secrets.READTHEDOCS_TOKEN }}" \
165
- --data '{
166
- "active": true,
167
- "hidden": false
168
- }'
89
+ - name : " Echo release url"
90
+ run : echo "${{ steps.pycord-release.outputs.gh-release }}"
169
91
170
92
determine_milestone_id :
171
93
runs-on : ubuntu-latest
172
- needs : [lib_release,docs_release, pre_config]
94
+ needs : [lib_release,pre_config]
173
95
if : ${{ !contains(needs.pre_config.outputs.version, '-') && endsWith(needs.pre_config.outputs.version, '.0') }}
174
96
outputs :
175
- milestone_version : ${{ steps.extract_version.outputs.milestone_version }}
97
+ old_milestone_version : ${{ steps.extract_version.outputs.old_milestone_version }}
98
+ new_milestone_version : ${{ steps.extract_version.outputs.new_milestone_version }}
99
+ env :
100
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
176
101
environment : release
177
102
steps :
178
103
- name : " Extract Milestone Version"
179
104
id : extract_version
180
105
run : |
106
+ gh extension install valeriobelli/gh-milestone
181
107
VERSION=${{ needs.pre_config.outputs.version }}
182
- MILESTONE_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
183
- echo "milestone_version=$MILESTONE_VERSION" >> $GITHUB_OUTPUT
108
+ OLD_MILESTONE_VERSION=$(gh milestone list --query "v2.7" | grep "#" | awk '{print $2}')
109
+ NEW_MILESTONE_VERSION="v$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')"
110
+ echo "old_milestone_version=$OLD_MILESTONE_VERSION" >> $GITHUB_OUTPUT
111
+ echo "new_milestone_version=$NEW_MILESTONE_VERSION" >> $GITHUB_OUTPUT
184
112
185
113
close_milestone :
186
114
runs-on : ubuntu-latest
187
115
needs : [determine_milestone_id,pre_config]
188
116
if : ${{ !contains(needs.pre_config.outputs.version, '-') && endsWith(needs.pre_config.outputs.version, '.0') }}
189
117
environment : release
190
118
env :
191
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
119
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
192
120
steps :
193
- - name : " Close Milestone"
194
- run : gh milestone edit "v${{ needs.determine_milestone_id.outputs.milestone_version }}" --state closed
195
-
196
- - name : " Create New Milestone"
197
- run : |
198
- NEW_MILESTONE_VERSION=$(echo ${{ needs.determine_milestone_id.outputs.milestone_version }} | awk -F. '{print $1"."$2+1}')
199
- gh milestone create "v${NEW_MILESTONE_VERSION}"
121
+ - name : " Checkout Repository"
122
+ uses : actions/checkout@v4
123
+ with :
124
+ fetch-depth : 0
125
+ fetch-tags : true
200
126
201
- - name : " Move Open Issues and PRs "
127
+ - name : " Close Milestone "
202
128
run : |
203
- gh issue list --milestone "v${{ needs.determine_milestone_id.outputs.milestone_version }}" --state open | while read issue
204
- do
205
- gh issue edit $issue --milestone "v${NEW_MILESTONE_VERSION}"
206
- done
129
+ gh extension install valeriobelli/gh-milestone
130
+ OLD_MILESTONE_ID=$(gh milestone list --query "${{ needs.determine_milestone_id.outputs.old_milestone_version }}" | grep "#" | cut -d' ' -f2 | cut -d '#' -f2)
131
+ gh milestone edit $OLD_MILESTONE_ID --state closed
207
132
208
- inform_discord :
209
- runs-on : ubuntu-latest
210
- needs : [lib_release,docs_release,close_milestone,pre_config]
211
- environment : release
212
- steps :
213
- - name : " Notify Discord"
133
+ - name : " Create New Milestone"
214
134
run : |
215
- VERSION=${{ needs.pre_config.outputs.version }}
216
- MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
217
- DOCS_URL="<https://docs.pycord.dev/en/v$VERSION/changelog.html>"
218
- GITHUB_COMPARE_URL="<https://github.com/Pycord-Development/pycord/compare/${{ needs.pre_config.outputs.previous_tag }}...v$VERSION>"
219
- GITHUB_RELEASE_URL="<https://github.com/Pycord-Development/pycord/releases/tag/v$VERSION>"
220
- PYPI_RELEASE_URL="<https://pypi.org/project/py-cord/$VERSION/>"
221
- ANNOUNCEMENT="## <:pycord:1063211537008955495> Pycord v${MAJOR_MINOR_VERSION} is out!\n\n"
222
- ANNOUNCEMENT="${ANNOUNCEMENT}[@everyone]\n\n"
223
- ANNOUNCEMENT="${ANNOUNCEMENT}You can view the changelog here: <$DOCS_URL>\n\n"
224
- ANNOUNCEMENT="${ANNOUNCEMENT}Feel free to take a look at the [GitHub changelog]($GITHUB_COMPARE_URL), [GitHub release page]($GITHUB_RELEASE_URL) and the [PyPI release page]($PYPI_RELEASE_URL).\n\n"
225
- ANNOUNCEMENT="${ANNOUNCEMENT}You can install this version by running the following command:\n\`\`\`sh\npip install -U py-cord==$VERSION\n\`\`\`\n\n"
226
- curl -H "Content-Type: application/json" \
227
- -X POST \
228
- -d "{\"content\":\"$ANNOUNCEMENT\"}" \
229
- ${{ secrets.DISCORD_WEBHOOK_URL }}
135
+ gh extension install valeriobelli/gh-milestone
136
+ gh milestone create "${{ needs.determine_milestone_id.outputs.new_milestone_version }}"
0 commit comments