From ac675c59099b3370aade43eeede93b99b4780bfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20Thom=C3=A9?= Date: Wed, 18 Oct 2023 01:28:51 +0200 Subject: [PATCH] Use reusable workflow --- .github/workflows/ci.yaml | 104 ++++++-------------------------------- 1 file changed, 15 insertions(+), 89 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0e2462a..18ba5b9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,96 +16,22 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -env: - package-name: "audioscrape" +permissions: + id-token: write jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.x" - cache: pip - - - name: Install build tool - run: pip install build - - - name: Build ${{ env.package-name }} - run: python -m build - - - name: Upload ${{ env.package-name }} package - uses: actions/upload-artifact@v3 - with: - name: ${{ env.package-name }} - path: ./dist/ - test: - runs-on: ubuntu-latest - needs: build - steps: - - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.x" - cache: pip - - - name: Download ${{ env.package-name }} package - uses: actions/download-artifact@v3 - with: - name: ${{ env.package-name }} - path: ./dist/ + if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/main') }} + uses: carlthome/workflows/.github/workflows/python.yaml@main + with: + package-name: "audioscrape" + package-index-name: TestPyPI + package-index-url: https://test.pypi.org/legacy - - name: Install ${{ env.package-name }} - run: pip install ./dist/*.whl - - - name: Install test runner - run: pip install pytest pytest-cov - - - name: Run unit tests - run: pytest --cov=${{ env.package-name }} - - test-publish: - if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/main') - runs-on: ubuntu-latest - needs: test - environment: - name: testpypi - url: https://test.pypi.org/p/${{ env.package-name }} - permissions: - id-token: write - steps: - - name: Download ${{ env.package-name }} package - uses: actions/download-artifact@v3 - with: - name: ${{ env.package-name }} - path: ./dist/ - - - name: Publish ${{ env.package-name }} to TestPyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - repository-url: https://test.pypi.org/legacy/ - - publish: - if: github.event_name == 'release' && github.event.action == 'published' - runs-on: ubuntu-latest - needs: test - environment: - name: pypi - url: https://pypi.org/p/${{ env.package-name }} - permissions: - id-token: write - steps: - - name: Download ${{ env.package-name }} package - uses: actions/download-artifact@v3 - with: - name: ${{ env.package-name }} - path: ./dist/ - - - name: Publish ${{ env.package-name }} to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 + release: + if: ${{ github.event_name == 'release' && github.event.action == 'published' }} + uses: carlthome/workflows/.github/workflows/python.yaml@main + with: + package-name: "audioscrape" + package-index-name: PyPI + package-index-url: https://pypi.org