From 2b731a9fadeeec1707a36dec9b2aac094a17fa49 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Sun, 18 Aug 2024 22:31:30 +0200 Subject: [PATCH] fix(releases): fix release builds & add new release system --- .github/workflows/release.yml | 191 +++++++++------------------------- README.rst | 1 + pyproject.toml | 6 +- requirements/_locale.txt | 4 +- requirements/_release.txt | 5 + requirements/dev.txt | 2 +- 6 files changed, 63 insertions(+), 146 deletions(-) create mode 100644 requirements/_release.txt diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 34eefe5212..6b3922b2f6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,19 +25,23 @@ jobs: needs: [safety_check] outputs: branch_name: ${{ steps.determine_vars.outputs.branch_name }} - is_rc: ${{ steps.determine_vars.outputs.version }} - version: ${{ steps.determine_vars.outputs.is_rc }} + is_rc: ${{ steps.determine_vars.outputs.is_rc }} + version: ${{ steps.determine_vars.outputs.version }} previous_tag: ${{ steps.determine_vars.outputs.previous_tag }} - runs-on: ububtu-latest + runs-on: ubuntu-latest steps: - name: "Checkout Repository" uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true - name: "Determine Push Branch" id: determine_vars + env: + VERSION: ${{ github.event.inputs.version }} run: | - VERSION=${{ github.event.inputs.version }} - echo "version=${VERSION}" >> $GITHUB_OUTPUT + echo "version=$VERSION" >> $GITHUB_OUTPUT PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^) echo "previous_tag=${PREVIOUS_TAG}" >> $GITHUB_OUTPUT if [[ $VERSION =~ -rc ]]; then @@ -63,124 +67,48 @@ jobs: steps: - name: "Checkout Repository" uses: actions/checkout@v4 - - - name: "Setup Python" - uses: actions/setup-python@v5 - with: - python-version: "3.12" - cache: "pip" - cache-dependency-path: "requirements/_release.txt" - - - name: "Install Release Dependencies" - run: | - python -m pip install --upgrade pip - pip install -r requirements/_release.txt - - - name: "Prepare and Update CHANGELOG.md" - run: | - VERSION=${{ needs.pre_config.outputs.version }} - DATE=$(date +'%Y-%m-%d') - sed -i "s/## \[Unreleased\]/## [$VERSION] - $DATE/" CHANGELOG.md - sed -i "0,/## \[$VERSION\]/ s|## \[$VERSION\]|## [Unreleased]\n\n### Added\n\n### Changed\n\n### Fixed\n\n### Removed\n\n$&|" CHANGELOG.md - 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 - echo "[Unreleased]: https://github.com/Pycord-Development/pycord/compare/v$VERSION...HEAD" >> CHANGELOG.md - git add CHANGELOG.md - git commit -m "chore(release): update CHANGELOG for version $VERSION" - - - name: "Commit and Push Changelog to Master" - run: | - git config user.name "GitHub Actions" - git config user.email "actions@github.com" - git add CHANGELOG.md - git commit -m "chore(release): update CHANGELOG for version ${{ needs.pre_config.outputs.version }}" - git push origin HEAD:master - - - name: "Push Changelog to Version Branch" - run: | - git push origin HEAD:${{ needs.pre_config.outputs.branch_name }} - - - name: "Create Git Tag" - run: | - git config user.name "GitHub Actions" - git config user.email "actions@github.com" - VERSION=${{ needs.pre_config.outputs.version }} - git tag -s v$VERSION -m "Release version $VERSION" - git push origin v$VERSION - - - name: "Verify Version" - run: python -m setuptools_scm - - - name: "Build Package" - run: | - python3 -m build --sdist - python3 -m build --wheel - - - name: "Create GitHub Release" - uses: softprops/action-gh-release@v2.0.8 with: - tag_name: "v${{ needs.pre_config.outputs.version }}" - name: "v${{ needs.pre_config.outputs.version }}" - generate_release_notes: true - draft: false - prerelease: ${{ needs.pre_config.outputs.is_rc == 'true' }} - files: | - dist/*.whl - dist/*.tar.gz - token: ${{ secrets.GITHUB_TOKEN }} - make_latest: true + fetch-depth: 0 + fetch-tags: true - - name: "Publish package distributions to PyPI" - uses: pypa/gh-action-pypi-publish@v1.9.0 - env: - name: pypi - url: https://pypi.org/p/pycord + - name: "Release Pycord" + id: pycord-release + uses: Aiko-IT-Systems/pycord-lib-release-action@v1.0.0 with: - password: ${{ secrets.PYPI_TOKEN }} - - docs_release: - runs-on: ubuntu-latest - needs: [lib_release,pre_config] - if: needs.pre_config.outputs.is_rc == 'false' || (needs.pre_config.outputs.is_rc == 'true' && endsWith(needs.pre_config.outputs.version, '.0-rc1')) - environment: release - steps: - - name: "Sync Versions on Read the Docs" - run: | - curl --location --request POST 'https://readthedocs.org/api/v3/projects/pycord/sync-versions/' \ - --header 'Content-Type: application/json' \ - --header "Authorization: Token ${{ secrets.READTHEDOCS_TOKEN }}" + github-token: ${{ secrets.GITHUB_TOKEN }} + pypi-token: ${{ secrets.PYPI_TOKEN }} + version-branch-name: ${{ needs.pre_config.outputs.branch_name }} + ref: ${{ github.ref_name }} + repository: ${{ github.repository }} + python-version: "3.12" + release-requirements: "requirements/_release.txt" + version: ${{ needs.pre_config.outputs.version }} + is-rc: ${{ needs.pre_config.outputs.is_rc }} + pypi-package: "py-cord" - - name: "Activate and Show Version on Read the Docs" - run: | - VERSION=${{ needs.pre_config.outputs.version }} - MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+') - PATCH_VERSION=${VERSION##*.} - if [[ $PATCH_VERSION =~ ^[0-9]+$ ]]; then - DOCS_VERSION="v$VERSION" - else - DOCS_VERSION="v$MAJOR_MINOR_VERSION.x" - fi - curl --location --request PATCH "https://readthedocs.org/api/v3/projects/pycord/versions/$DOCS_VERSION/" \ - --header 'Content-Type: application/json' \ - --header "Authorization: Token ${{ secrets.READTHEDOCS_TOKEN }}" \ - --data '{ - "active": true, - "hidden": false - }' + - name: "Echo release url" + run: echo "${{ steps.pycord-release.outputs.gh-release }}" determine_milestone_id: runs-on: ubuntu-latest - needs: [lib_release,docs_release,pre_config] + needs: [lib_release,pre_config] if: ${{ !contains(needs.pre_config.outputs.version, '-') && endsWith(needs.pre_config.outputs.version, '.0') }} outputs: - milestone_version: ${{ steps.extract_version.outputs.milestone_version }} + old_milestone_version: ${{ steps.extract_version.outputs.old_milestone_version }} + new_milestone_version: ${{ steps.extract_version.outputs.new_milestone_version }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} environment: release steps: - name: "Extract Milestone Version" id: extract_version run: | + gh extension install valeriobelli/gh-milestone VERSION=${{ needs.pre_config.outputs.version }} - MILESTONE_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+') - echo "milestone_version=$MILESTONE_VERSION" >> $GITHUB_OUTPUT + OLD_MILESTONE_VERSION=$(gh milestone list --query "v2.7" | grep "#" | awk '{print $2}') + NEW_MILESTONE_VERSION="v$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+')" + echo "old_milestone_version=$OLD_MILESTONE_VERSION" >> $GITHUB_OUTPUT + echo "new_milestone_version=$NEW_MILESTONE_VERSION" >> $GITHUB_OUTPUT close_milestone: runs-on: ubuntu-latest @@ -188,42 +116,21 @@ jobs: if: ${{ !contains(needs.pre_config.outputs.version, '-') && endsWith(needs.pre_config.outputs.version, '.0') }} environment: release env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - name: "Close Milestone" - run: gh milestone edit "v${{ needs.determine_milestone_id.outputs.milestone_version }}" --state closed - - - name: "Create New Milestone" - run: | - NEW_MILESTONE_VERSION=$(echo ${{ needs.determine_milestone_id.outputs.milestone_version }} | awk -F. '{print $1"."$2+1}') - gh milestone create "v${NEW_MILESTONE_VERSION}" + - name: "Checkout Repository" + uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true - - name: "Move Open Issues and PRs" + - name: "Close Milestone" run: | - gh issue list --milestone "v${{ needs.determine_milestone_id.outputs.milestone_version }}" --state open | while read issue - do - gh issue edit $issue --milestone "v${NEW_MILESTONE_VERSION}" - done + gh extension install valeriobelli/gh-milestone + OLD_MILESTONE_ID=$(gh milestone list --query "${{ needs.determine_milestone_id.outputs.old_milestone_version }}" | grep "#" | cut -d' ' -f2 | cut -d '#' -f2) + gh milestone edit $OLD_MILESTONE_ID --state closed - inform_discord: - runs-on: ubuntu-latest - needs: [lib_release,docs_release,close_milestone,pre_config] - environment: release - steps: - - name: "Notify Discord" + - name: "Create New Milestone" run: | - VERSION=${{ needs.pre_config.outputs.version }} - MAJOR_MINOR_VERSION=$(echo $VERSION | grep -oE '^[0-9]+\.[0-9]+') - DOCS_URL="" - GITHUB_COMPARE_URL="" - GITHUB_RELEASE_URL="" - PYPI_RELEASE_URL="" - ANNOUNCEMENT="## <:pycord:1063211537008955495> Pycord v${MAJOR_MINOR_VERSION} is out!\n\n" - ANNOUNCEMENT="${ANNOUNCEMENT}[@everyone]\n\n" - ANNOUNCEMENT="${ANNOUNCEMENT}You can view the changelog here: <$DOCS_URL>\n\n" - 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" - ANNOUNCEMENT="${ANNOUNCEMENT}You can install this version by running the following command:\n\`\`\`sh\npip install -U py-cord==$VERSION\n\`\`\`\n\n" - curl -H "Content-Type: application/json" \ - -X POST \ - -d "{\"content\":\"$ANNOUNCEMENT\"}" \ - ${{ secrets.DISCORD_WEBHOOK_URL }} + gh extension install valeriobelli/gh-milestone + gh milestone create "${{ needs.determine_milestone_id.outputs.new_milestone_version }}" \ No newline at end of file diff --git a/README.rst b/README.rst index 19503bd234..cb387419ae 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,6 @@ .. image:: https://raw.githubusercontent.com/Pycord-Development/pycord-next/main/docs/assets/pycord-v3.png :alt: Pycord v3 + Pycord is a modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python. ====== diff --git a/pyproject.toml b/pyproject.toml index b4662813e2..abbc5290bb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] requires = [ - "setuptools>=62.6,<=72.1.0", + "setuptools>=62.6,<=72.2.0", "setuptools-scm>=6.2,<=8.1.0", ] build-backend = "setuptools.build_meta" @@ -11,7 +11,7 @@ authors = [ {name = "Pycord Development"} ] description = "A Python wrapper for the Discord API" -readme = "README.rst" +readme = {content-type = "text/x-rst", file = "README.rst"} requires-python = ">=3.9" license = {text = "MIT"} classifiers = [ @@ -52,10 +52,12 @@ packages = [ "discord.ext.tasks", "discord.ext.pages", "discord.ext.bridge", + "discord.bin", ] [tool.setuptools.dynamic] dependencies = {file = "requirements/_.txt"} +readme = {content-type = "text/x-rst", file = "README.rst"} [tool.setuptools.dynamic.optional-dependencies] docs = {file = "requirements/docs.txt"} diff --git a/requirements/_locale.txt b/requirements/_locale.txt index 3f7eae7305..e6e31a4fe9 100644 --- a/requirements/_locale.txt +++ b/requirements/_locale.txt @@ -1,2 +1,4 @@ -r all.txt -build==1.2.1 +build>=1.2.1 +setuptools>=72.2.0 +setuptools_scm>=8.1.0 \ No newline at end of file diff --git a/requirements/_release.txt b/requirements/_release.txt new file mode 100644 index 0000000000..e09b3bb2ea --- /dev/null +++ b/requirements/_release.txt @@ -0,0 +1,5 @@ +-r all.txt +setuptools>=72.2.0 +setuptools_scm>=8.1.0 +twine>=5.1.1 +build>=1.2.1 \ No newline at end of file diff --git a/requirements/dev.txt b/requirements/dev.txt index aa7fb8afc1..db298590ba 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,7 +1,7 @@ -r _.txt pylint~=3.2.6 pytest~=8.3.2 -pytest-asyncio~=0.23.3 +pytest-asyncio~=0.23.8 # pytest-order~=1.0.1 mypy~=1.11.1 coverage~=7.6