Skip to content

Commit 231e160

Browse files
committed
Refactor release workflow for manual Python packaging
Replaces the pycord-lib-release-action with explicit steps for setting up Python, installing dependencies, updating the changelog, building distributions, tagging releases, and publishing to PyPI. This change provides more control and transparency over the release process.
1 parent 82659b2 commit 231e160

File tree

1 file changed

+103
-15
lines changed

1 file changed

+103
-15
lines changed

.github/workflows/release.yml

Lines changed: 103 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -89,25 +89,113 @@ jobs:
8989
git push origin $VERSION_BRANCH
9090
fi
9191
git checkout $VERSION_BRANCH
92-
- name: "Release Pycord"
93-
id: pycord-release
94-
uses: Aiko-IT-Systems/[email protected]
92+
- name: "Setup Python"
93+
id: python-setup
94+
uses: actions/setup-python@v5
9595
with:
96-
github-token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
97-
pypi-token: ${{ secrets.PYPI_TOKEN }}
98-
git-username: "NyuwBot"
99-
git-email: "[email protected]"
100-
version-branch-name: ${{ needs.pre_config.outputs.branch_name }}
101-
ref: ${{ github.ref_name }}
102-
repository: ${{ github.repository }}
10396
python-version: "3.13"
104-
release-requirements: "requirements/_release.txt"
105-
version: ${{ needs.pre_config.outputs.version }}
106-
is-rc: ${{ needs.pre_config.outputs.is_rc }}
107-
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+
108196

109197
- name: "Echo release url"
110-
run: echo "${{ steps.pycord-release.outputs.gh-release }}"
198+
run: echo "${{ steps.gh-release.outputs.url }}"
111199

112200
docs_release:
113201
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)