diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 00000000..5ace4600 --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a46a9a42..4a581157 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,7 +6,8 @@ on: types: [opened, edited, synchronize] jobs: - lib: + build: + name: Build wheels runs-on: ubuntu-latest strategy: fail-fast: false @@ -15,34 +16,51 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install CPython - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: - python-version: ${{matrix.python-version}} + python-version: ${{ matrix.python-version }} - - name: Install Deps + - name: Install deps run: | - python -m ensurepip - pip install wheel setuptools - pip install -r requirements.txt + pip install -U wheel setuptools pip Cython + pip install '.[speed,sound]' - - name: Build - run: python setup.py sdist bdist_wheel + - name: Build wheels + run: pip wheel -w ./wheelhouse/ '.[speed,sound]' + + - uses: actions/upload-artifact@v4 + with: + name: artifact-wheels-${{ matrix.python-version }} + path: ./wheelhouse/twitchio*.whl + + sdist: + name: Make source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - run: pipx run build --sdist + + - uses: actions/upload-artifact@v4 + with: + name: artifact-source-dist + path: "./**/dist/*.tar.gz" docs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install CPython - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: 3.7 @@ -62,19 +80,41 @@ jobs: lint: runs-on: ubuntu-latest steps: - - name: checkout - uses: actions/checkout@v2 - - - name: Setup Python - uses: actions/setup-python@v2 - with: - python-version: 3.7 - - - name: install black - run: | - python -m ensurepip - pip install black - - - name: run linter - run: | - black twitchio --line-length 120 --verbose --check \ No newline at end of file + - name: checkout + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: 3.7 + + - name: install black + run: | + python -m ensurepip + pip install black + + - name: run linter + run: | + black twitchio --line-length 120 --verbose --check + + upload_pypi: + if: github.event_name == 'push' && github.ref_type == 'tag' + name: Publish built wheels to Pypi + runs-on: ubuntu-latest + environment: release + needs: [build, sdist] + permissions: + id-token: write + + steps: + - uses: actions/download-artifact@v4 + + - name: Copy artifacts to dist/ folder + run: | + find . -name 'artifact-*' -exec unzip '{}' \; + mkdir -p dist/ + find . -name '*.tar.gz' -exec mv '{}' dist/ \; + find . -name '*.whl' -exec mv '{}' dist/ \; + + - uses: pypa/gh-action-pypi-publish@release/v1 + name: Publish to PyPI diff --git a/.github/workflows/edit_version.py b/.github/workflows/edit_version.py deleted file mode 100644 index 47baf3d8..00000000 --- a/.github/workflows/edit_version.py +++ /dev/null @@ -1,16 +0,0 @@ -import argparse -import re - - -parser = argparse.ArgumentParser() -parser.add_argument("--latest") -args = parser.parse_args() - - -with open("../../twitchio/__init__.py", "r+") as fp: - data = fp.read() - - data = re.sub(r"__version__ = \"\d+.\d+.\d+\"", f'__version__ = "{args.latest.removeprefix("v")}"', data) - - fp.seek(0) - fp.write(data) diff --git a/.github/workflows/get_revision.py b/.github/workflows/get_revision.py deleted file mode 100644 index 60e3021f..00000000 --- a/.github/workflows/get_revision.py +++ /dev/null @@ -1,14 +0,0 @@ -import requests - - -def getrev(): - resp = requests.get("https://pypi.org/pypi/TwitchIO/json") - data = resp.json()["releases"] - - pre = max(data).split("b") - final = f"{pre[0]}b{int(pre[1]) + 1}" - - return final - - -print(getrev()) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 1fd3ee59..00000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Publish to PyPI - -on: - release: - types: [published] - -jobs: - deploy: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - - name: Get Latest Release - id: latest_version - uses: abatilo/release-info-action@v1.3.0 - with: - owner: PythonistaGuild - repo: TwitchIO - - - name: Set up Python - uses: actions/setup-python@v1 - with: - python-version: '3.11' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - - - name: Edit init version - working-directory: .github/workflows/ - run: | - python edit_version.py --latest ${{ steps.latest_version.outputs.latest_tag }} - - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python setup.py sdist bdist_wheel - twine upload dist/*