Skip to content

Commit 2b731a9

Browse files
committed
fix(releases): fix release builds & add new release system
1 parent 3a1c827 commit 2b731a9

File tree

6 files changed

+63
-146
lines changed

6 files changed

+63
-146
lines changed

.github/workflows/release.yml

Lines changed: 49 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,23 @@ jobs:
2525
needs: [safety_check]
2626
outputs:
2727
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 }}
3030
previous_tag: ${{ steps.determine_vars.outputs.previous_tag }}
31-
runs-on: ububtu-latest
31+
runs-on: ubuntu-latest
3232
steps:
3333
- name: "Checkout Repository"
3434
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
fetch-tags: true
3538

3639
- name: "Determine Push Branch"
3740
id: determine_vars
41+
env:
42+
VERSION: ${{ github.event.inputs.version }}
3843
run: |
39-
VERSION=${{ github.event.inputs.version }}
40-
echo "version=${VERSION}" >> $GITHUB_OUTPUT
44+
echo "version=$VERSION" >> $GITHUB_OUTPUT
4145
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^)
4246
echo "previous_tag=${PREVIOUS_TAG}" >> $GITHUB_OUTPUT
4347
if [[ $VERSION =~ -rc ]]; then
@@ -63,167 +67,70 @@ jobs:
6367
steps:
6468
- name: "Checkout Repository"
6569
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-
uses: softprops/[email protected]
12070
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
13173

132-
- name: "Publish package distributions to PyPI"
133-
uses: pypa/[email protected]
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]
13777
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"
15188

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 }}"
16991

17092
determine_milestone_id:
17193
runs-on: ubuntu-latest
172-
needs: [lib_release,docs_release,pre_config]
94+
needs: [lib_release,pre_config]
17395
if: ${{ !contains(needs.pre_config.outputs.version, '-') && endsWith(needs.pre_config.outputs.version, '.0') }}
17496
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 }}
176101
environment: release
177102
steps:
178103
- name: "Extract Milestone Version"
179104
id: extract_version
180105
run: |
106+
gh extension install valeriobelli/gh-milestone
181107
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
184112
185113
close_milestone:
186114
runs-on: ubuntu-latest
187115
needs: [determine_milestone_id,pre_config]
188116
if: ${{ !contains(needs.pre_config.outputs.version, '-') && endsWith(needs.pre_config.outputs.version, '.0') }}
189117
environment: release
190118
env:
191-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
192120
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
200126

201-
- name: "Move Open Issues and PRs"
127+
- name: "Close Milestone"
202128
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
207132
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"
214134
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 }}"

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.. image:: https://raw.githubusercontent.com/Pycord-Development/pycord-next/main/docs/assets/pycord-v3.png
22
:alt: Pycord v3
3+
34
Pycord is a modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python.
45

56
======

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
22
requires = [
3-
"setuptools>=62.6,<=72.1.0",
3+
"setuptools>=62.6,<=72.2.0",
44
"setuptools-scm>=6.2,<=8.1.0",
55
]
66
build-backend = "setuptools.build_meta"
@@ -11,7 +11,7 @@ authors = [
1111
{name = "Pycord Development"}
1212
]
1313
description = "A Python wrapper for the Discord API"
14-
readme = "README.rst"
14+
readme = {content-type = "text/x-rst", file = "README.rst"}
1515
requires-python = ">=3.9"
1616
license = {text = "MIT"}
1717
classifiers = [
@@ -52,10 +52,12 @@ packages = [
5252
"discord.ext.tasks",
5353
"discord.ext.pages",
5454
"discord.ext.bridge",
55+
"discord.bin",
5556
]
5657

5758
[tool.setuptools.dynamic]
5859
dependencies = {file = "requirements/_.txt"}
60+
readme = {content-type = "text/x-rst", file = "README.rst"}
5961

6062
[tool.setuptools.dynamic.optional-dependencies]
6163
docs = {file = "requirements/docs.txt"}

requirements/_locale.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
-r all.txt
2-
build==1.2.1
2+
build>=1.2.1
3+
setuptools>=72.2.0
4+
setuptools_scm>=8.1.0

requirements/_release.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-r all.txt
2+
setuptools>=72.2.0
3+
setuptools_scm>=8.1.0
4+
twine>=5.1.1
5+
build>=1.2.1

requirements/dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-r _.txt
22
pylint~=3.2.6
33
pytest~=8.3.2
4-
pytest-asyncio~=0.23.3
4+
pytest-asyncio~=0.23.8
55
# pytest-order~=1.0.1
66
mypy~=1.11.1
77
coverage~=7.6

0 commit comments

Comments
 (0)