Skip to content

Commit

Permalink
Use reusable workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
carlthome authored Oct 17, 2023
1 parent 84f199f commit ac675c5
Showing 1 changed file with 15 additions and 89 deletions.
104 changes: 15 additions & 89 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ac675c5

Please sign in to comment.