Skip to content

Commit f1c88cc

Browse files
authored
Merge branch 'master' into feat/mssage-update-parse-message
Signed-off-by: Paillat <[email protected]>
2 parents 7ea1aa6 + 0038661 commit f1c88cc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2691
-235
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
* @Pycord-Development/maintainers
1+
* @Pycord-Development/library-maintainers @Pycord-Development/library-contributors
22

33
/discord/ @Pycord-Development/maintain-discord-api
44

.github/SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
| Version | Supported |
66
| ------- | ------------------ |
77
| 2.x | :white_check_mark: |
8-
| <2.0.0 | :x: |
8+
| <2.6.1 | :x: |
99

1010
## Reporting a Vulnerability
1111

.github/dependabot.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Docs JSON Export
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
jobs:
10+
export-docs-json:
11+
name: Export docs.json
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repository
15+
id: checkout
16+
uses: actions/checkout@v5
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
id: setup-python
20+
with:
21+
python-version: "3.13"
22+
cache: "pip"
23+
cache-dependency-path: "requirements/docs.txt"
24+
check-latest: true
25+
- name: Install dependencies
26+
id: install-deps
27+
run: |
28+
python -m pip install -U pip
29+
pip install ".[docs]"
30+
pip install beautifulsoup4
31+
- name: Build Sphinx HTML docs
32+
id: build-sphinx
33+
run: sphinx-build -b html docs docs/_build/html
34+
- name: Export docs.json
35+
id: generate-json
36+
run: python scripts/docs_json_exporter.py
37+
- name: Upload docs.json as artifact
38+
uses: actions/[email protected]
39+
id: artifact-upload
40+
with:
41+
name: Pycord Docs JSON
42+
path: docs.json
43+
retention-days: 1
44+
- name: Show docs.json summary
45+
run: |
46+
head -n 40 docs.json || tail -n 40 docs.json
47+
- name: Output artifact ID
48+
run: |
49+
echo "artifact-id=${{ steps.artifact-upload.outputs.artifact-id }}" >> $GITHUB_OUTPUT
50+
echo "artifact-url=${{ steps.artifact-upload.outputs.artifact-url }}" >> $GITHUB_OUTPUT
51+
echo "::notice::Artifact uploaded: ${{ steps.artifact-upload.outputs.artifact-url }}"

.github/workflows/release.yml

Lines changed: 154 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
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

1111
permissions: 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
@@ -63,36 +69,138 @@ jobs:
6369
runs-on: ubuntu-latest
6470
environment: release
6571
env:
66-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
GITHUB_TOKEN: ${{ secrets.ADMIN_GITHUB_TOKEN }}
6773
steps:
6874
- name: "Checkout Repository"
6975
uses: actions/checkout@v5
7076
with:
7177
fetch-depth: 0
7278
fetch-tags: true
73-
74-
- name: "Release Pycord"
75-
id: pycord-release
76-
uses: Aiko-IT-Systems/[email protected]
79+
- name: "Create version branch if missing"
80+
id: conditional-create-version-branch
81+
shell: bash
82+
env:
83+
VERSION_BRANCH: ${{ needs.pre_config.outputs.branch_name }}
84+
GITHUB_TOKEN: ${{ secrets.ADMIN_GITHUB_TOKEN }}
85+
run: |
86+
git fetch origin
87+
if ! git show-ref --verify --quiet refs/heads/$VERSION_BRANCH; then
88+
git checkout -b $VERSION_BRANCH
89+
git push origin $VERSION_BRANCH
90+
fi
91+
git checkout $VERSION_BRANCH
92+
- name: "Setup Python"
93+
id: python-setup
94+
uses: actions/setup-python@v5
7795
with:
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 }}
8396
python-version: "3.13"
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"
97+
cache: "pip"
98+
cache-dependency-path: "requirements/_release.txt"
99+
- name: "Install Release Dependencies"
100+
id: python-install
101+
env:
102+
REQ_FILE: "requirements/_release.txt"
103+
shell: bash
104+
run: |
105+
python -m pip install --upgrade pip
106+
pip install setuptools setuptools_scm twine build
107+
pip install -r $REQ_FILE
108+
- name: "Prepare and Update CHANGELOG.md"
109+
id: changelog-update
110+
shell: bash
111+
env:
112+
VERSION: ${{ inputs.version }}
113+
REPOSITORY: ${{ github.repository }}
114+
GITHUB_TOKEN: ${{ secrets.ADMIN_GITHUB_TOKEN }}
115+
BRANCH: ${{ github.ref_name }}
116+
run: |
117+
git config user.name "NyuwBot"
118+
git config user.email "[email protected]"
119+
DATE=$(date +'%Y-%m-%d')
120+
sed -i "/These changes are available on the \`.*\` branch, but have not yet been released\./{N;d;}" CHANGELOG.md
121+
sed -i "s/## \[Unreleased\]/## [$VERSION] - $DATE/" CHANGELOG.md
122+
sed -i "0,/## \[$VERSION\]/ s|## \[$VERSION\]|## [Unreleased]\n\nThese changes are available on the \`$BRANCH\` branch, but have not yet been released.\n\n### Added\n\n### Changed\n\n### Fixed\n\n### Removed\n\n&|" CHANGELOG.md
123+
sed -i "s|\[unreleased\]:.*|[unreleased]: https://github.com/$REPOSITORY/compare/v$VERSION...HEAD\n[$VERSION]: https://github.com/$REPOSITORY/compare/$(git describe --tags --abbrev=0 @^)...v$VERSION|" CHANGELOG.md
124+
git add CHANGELOG.md
125+
git commit -m "chore(release): update CHANGELOG.md for version $VERSION"
126+
- name: "Commit and Push Changelog to ${{ github.ref_name }}"
127+
id: commit-main-branch
128+
shell: bash
129+
env:
130+
VERSION: ${{ inputs.version }}
131+
GITHUB_TOKEN: ${{ secrets.ADMIN_GITHUB_TOKEN }}
132+
BRANCH: ${{ github.ref_name }}
133+
run: |
134+
git config user.name "NyuwBot"
135+
git config user.email "[email protected]"
136+
git push origin HEAD:$BRANCH -f
137+
- name: "Push Changelog to Version Branch"
138+
id: commit-version-branch
139+
shell: bash
140+
env:
141+
GITHUB_TOKEN: ${{ secrets.ADMIN_GITHUB_TOKEN }}
142+
VERSION_BRANCH: ${{ needs.pre_config.outputs.branch_name }}
143+
run: |
144+
git config user.name "NyuwBot"
145+
git config user.email "[email protected]"
146+
git push origin HEAD:$VERSION_BRANCH -f
147+
- name: "Create Git Tag"
148+
id: create-git-tag
149+
shell: bash
150+
env:
151+
VERSION: ${{ inputs.version }}
152+
GITHUB_TOKEN: ${{ secrets.ADMIN_GITHUB_TOKEN }}
153+
run: |
154+
git config user.name "NyuwBot"
155+
git config user.email "[email protected]"
156+
git tag v$VERSION -m "Release version $VERSION"
157+
git push origin v$VERSION -f
158+
- name: "Verify Version"
159+
id: python-version-verify
160+
shell: bash
161+
run: python -m setuptools_scm
162+
- name: "Build Package"
163+
id: python-version-build
164+
shell: bash
165+
run: |
166+
python3 -m build --sdist
167+
python3 -m build --wheel
168+
- name: "Create GitHub Release"
169+
uses: softprops/[email protected]
170+
id: gh-release
171+
with:
172+
tag_name: "v${{ inputs.version }}"
173+
name: "v${{ inputs.version }}"
174+
generate_release_notes: true
175+
draft: false
176+
prerelease: ${{ needs.pre_config.outputs.is_rc }}
177+
files: |
178+
dist/*.whl
179+
dist/*.tar.gz
180+
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
181+
make_latest: true
182+
repository: ${{ github.repository }}
183+
target_commitish: ${{ github.ref_name }}
184+
185+
- name: "Publish package distributions to PyPI"
186+
uses: pypa/[email protected]
187+
env:
188+
name: "pypi"
189+
url: "https://pypi.org/p/py-cord"
190+
with:
191+
password: ${{ secrets.PYPI_TOKEN }}
192+
user: __token__
193+
attestations: false
194+
verify-metadata: false
195+
88196

89197
- name: "Echo release url"
90-
run: echo "${{ steps.pycord-release.outputs.gh-release }}"
198+
run: echo "${{ steps.gh-release.outputs.url }}"
91199

92200
docs_release:
93201
runs-on: ubuntu-latest
94202
needs: [lib_release,pre_config]
95-
if: needs.pre_config.outputs.is_rc == 'false' || (needs.pre_config.outputs.is_rc == 'true' && endsWith(needs.pre_config.outputs.version, '.0-rc1'))
203+
if: ${{ needs.pre_config.outputs.is_rc == 'false' || (needs.pre_config.outputs.is_rc == 'true' && endsWith(needs.pre_config.outputs.version, '0rc1')) }}
96204
environment: release
97205
steps:
98206
- name: "Sync Versions on Read the Docs"
@@ -105,11 +213,10 @@ jobs:
105213
run: |
106214
VERSION=${{ needs.pre_config.outputs.version }}
107215
MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
108-
PATCH_VERSION=${VERSION##*.}
109-
if [[ $PATCH_VERSION =~ ^[0-9]+$ ]]; then
110-
DOCS_VERSION="v$VERSION"
216+
if [[ $VERSION == *rc* ]]; then
217+
DOCS_VERSION="v${MAJOR_MINOR_VERSION}.x"
111218
else
112-
DOCS_VERSION="v$MAJOR_MINOR_VERSION.x"
219+
DOCS_VERSION="v$VERSION"
113220
fi
114221
curl --location --request PATCH "https://readthedocs.org/api/v3/projects/pycord/versions/$DOCS_VERSION/" \
115222
--header 'Content-Type: application/json' \
@@ -121,31 +228,44 @@ jobs:
121228
122229
inform_discord:
123230
runs-on: ubuntu-latest
124-
needs: [lib_release,docs_release,close_milestone,pre_config]
231+
needs: [lib_release,docs_release,pre_config]
125232
environment: release
126233
steps:
127234
- name: "Notify Discord"
128235
run: |
129236
VERSION=${{ needs.pre_config.outputs.version }}
130237
MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')
131-
DOCS_URL="<https://docs.pycord.dev/en/v$VERSION/changelog.html>"
238+
if [[ $VERSION == *rc* ]]; then
239+
DOCS_URL="<https://docs.pycord.dev/en/v${MAJOR_MINOR_VERSION}.x/changelog.html>"
240+
else
241+
DOCS_URL="<https://docs.pycord.dev/en/v$VERSION/changelog.html>"
242+
fi
132243
GITHUB_COMPARE_URL="<https://github.com/Pycord-Development/pycord/compare/${{ needs.pre_config.outputs.previous_tag }}...v$VERSION>"
133244
GITHUB_RELEASE_URL="<https://github.com/Pycord-Development/pycord/releases/tag/v$VERSION>"
134245
PYPI_RELEASE_URL="<https://pypi.org/project/py-cord/$VERSION/>"
135-
ANNOUNCEMENT="## <:pycord:1063211537008955495> Pycord v${MAJOR_MINOR_VERSION} is out!\n\n"
136-
ANNOUNCEMENT="${ANNOUNCEMENT}[@everyone]\n\n"
137-
ANNOUNCEMENT="${ANNOUNCEMENT}You can view the changelog here: <$DOCS_URL>\n\n"
138-
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"
139-
ANNOUNCEMENT="${ANNOUNCEMENT}You can install this version by running the following command:\n\`\`\`sh\npip install -U py-cord==$VERSION\n\`\`\`\n\n"
246+
if [[ $VERSION == *rc* ]]; then
247+
ANNOUNCEMENT="## <:pycord:1063211537008955495> Pycord v${MAJOR_MINOR_VERSION} Release Candidate ($VERSION) is available!\n\n"
248+
ANNOUNCEMENT="${ANNOUNCEMENT}This is a pre-release (release candidate) for testing and feedback.\n\n"
249+
ANNOUNCEMENT="${ANNOUNCEMENT}You can view the changelog here: <$DOCS_URL>\n\n"
250+
ANNOUNCEMENT="${ANNOUNCEMENT}Check out the [GitHub changelog]($GITHUB_COMPARE_URL), [GitHub release page]($GITHUB_RELEASE_URL), and [PyPI release page]($PYPI_RELEASE_URL).\n\n"
251+
ANNOUNCEMENT="${ANNOUNCEMENT}You can install this version by running the following command:\n\`\`\`sh\npip install -U py-cord==$VERSION\n\`\`\`\n\n"
252+
ANNOUNCEMENT="${ANNOUNCEMENT}Please try it out and let us know your feedback or any issues!\n@here"
253+
else
254+
ANNOUNCEMENT="## <:pycord:1063211537008955495> Pycord v${MAJOR_MINOR_VERSION} is out!\n\n"
255+
ANNOUNCEMENT="${ANNOUNCEMENT}[@everyone]\n\n"
256+
ANNOUNCEMENT="${ANNOUNCEMENT}You can view the changelog here: <$DOCS_URL>\n\n"
257+
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"
258+
ANNOUNCEMENT="${ANNOUNCEMENT}You can install this version by running the following command:\n\`\`\`sh\npip install -U py-cord==$VERSION\n\`\`\`\n\n"
259+
fi
140260
curl -H "Content-Type: application/json" \
141261
-X POST \
142-
-d "{\"content\":\"$ANNOUNCEMENT\"}" \
262+
-d "{\"content\":\"$ANNOUNCEMENT\",\"allowed_mentions\":{\"parse\": [\"everyone\"]}}" \
143263
${{ secrets.DISCORD_WEBHOOK_URL }}
144264
145265
determine_milestone_id:
146266
runs-on: ubuntu-latest
147267
needs: [lib_release,pre_config]
148-
if: ${{ !contains(needs.pre_config.outputs.version, '-') && endsWith(needs.pre_config.outputs.version, '.0') }}
268+
if: ${{ !contains(needs.pre_config.outputs.version, '-') }}
149269
outputs:
150270
old_milestone_version: ${{ steps.extract_version.outputs.old_milestone_version }}
151271
new_milestone_version: ${{ steps.extract_version.outputs.new_milestone_version }}
@@ -158,15 +278,16 @@ jobs:
158278
run: |
159279
gh extension install valeriobelli/gh-milestone
160280
VERSION=${{ needs.pre_config.outputs.version }}
161-
OLD_MILESTONE_VERSION=$(gh milestone list --query "v2.7" | grep "#" | awk '{print $2}')
281+
PREV_MAJOR_MINOR=$(echo $VERSION | awk -F. '{printf "v%d.%d", $1, $2-1}')
282+
OLD_MILESTONE_VERSION=$(gh milestone list --query "$PREV_MAJOR_MINOR" | grep "#" | awk '{print $2}')
162283
NEW_MILESTONE_VERSION="v$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')"
163284
echo "old_milestone_version=$OLD_MILESTONE_VERSION" >> $GITHUB_OUTPUT
164285
echo "new_milestone_version=$NEW_MILESTONE_VERSION" >> $GITHUB_OUTPUT
165286
166287
close_milestone:
167288
runs-on: ubuntu-latest
168289
needs: [determine_milestone_id,pre_config]
169-
if: ${{ !contains(needs.pre_config.outputs.version, '-') && endsWith(needs.pre_config.outputs.version, '.0') }}
290+
if: ${{ !contains(needs.pre_config.outputs.version, 'rc') && endsWith(needs.pre_config.outputs.version, '.0') }}
170291
environment: release
171292
env:
172293
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ cython_debug/
159159

160160
# Custom
161161
*.json
162+
!renovate.json
162163
*.egg-info
163164
.venv/
164165
docs/_build
@@ -192,3 +193,4 @@ docs/build/linkcheck
192193
!docs/locales/*
193194
/build/
194195
/vscode/
196+
remote-release.yml

0 commit comments

Comments
 (0)