From e1ab8d00b0c29e9964f3179136f59392bbcc39ca Mon Sep 17 00:00:00 2001 From: Leif Gehrmann Date: Tue, 25 Jun 2024 22:33:32 +0100 Subject: [PATCH] Fix and update GitHub Actions + Add publish action (#33) * Update GitHub Actions and add publish action * Added setuptools * Fix publish action --- .github/workflows/build.yml | 36 ++++++--------------------- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/publish.yml | 26 ++++++++++++++++++++ .github/workflows/test.yml | 45 ++++++++++++++++++++++++++++++++++ requirements.txt | 1 + 6 files changed, 81 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a947e87..6800bca 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,41 +5,19 @@ on: pull_request: jobs: - build: - runs-on: ${{matrix.os}} - strategy: - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + sdist: + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python uses: actions/setup-python@v4 with: - python-version: ${{ matrix.python-version }} + python-version: "3.12" - name: Install dependencies run: | python -m pip install --upgrade pip - pip install tox tox-gh-actions - - name: Install System Dependencies (macOS) - if: runner.os == 'macOS' + pip install -r requirements.txt + - name: Create sdist run: | - brew install pkg-config - brew install libffi - brew install pango - brew install glib - # https://github.com/Kozea/CairoSVG/issues/354#issuecomment-1160552256 - sudo ln -s /opt/homebrew/lib/libcairo* . - sudo ln -s /opt/homebrew/lib/libpango* . - sudo ln -s /opt/homebrew/lib/libgobject* . - sudo ln -s /opt/homebrew/lib/libglib* . - - name: Install System Dependencies (Windows) - if: runner.os == 'windows' - run: | - C:\msys64\usr\bin\bash -lc 'pacman -S mingw-w64-x86_64-ttf-dejavu mingw-w64-x86_64-gtk3 --noconfirm' - xcopy "C:\msys64\mingw64\share\fonts\TTF" "C:\Users\runneradmin\.fonts" /e /i - echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH - rm C:\msys64\mingw64\bin\python.exe - - name: Test with tox - run: tox + python setup.py sdist diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 5371c3e..e6a3300 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -5,7 +5,7 @@ on: pull_request: jobs: - build: + coverage: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a5e9853..81ae901 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,7 +5,7 @@ on: pull_request: jobs: - build: + lint: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..230b435 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,26 @@ +name: Publish + +on: + workflow_dispatch: + +jobs: + pypi-publish: + runs-on: ubuntu-latest + environment: release + permissions: + id-token: write + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.12" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: Create dist + run: | + python setup.py sdist + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..8e22d07 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,45 @@ +name: Test + +on: + push: + pull_request: + +jobs: + tox: + runs-on: ${{matrix.os}} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox tox-gh-actions + - name: Install System Dependencies (macOS) + if: runner.os == 'macOS' + run: | + brew install pkg-config + brew install libffi + brew install pango + brew install glib + # https://github.com/Kozea/CairoSVG/issues/354#issuecomment-1160552256 + sudo ln -s /opt/homebrew/lib/libcairo* . + sudo ln -s /opt/homebrew/lib/libpango* . + sudo ln -s /opt/homebrew/lib/libgobject* . + sudo ln -s /opt/homebrew/lib/libglib* . + - name: Install System Dependencies (Windows) + if: runner.os == 'windows' + run: | + C:\msys64\usr\bin\bash -lc 'pacman -S mingw-w64-x86_64-ttf-dejavu mingw-w64-x86_64-gtk3 --noconfirm' + xcopy "C:\msys64\mingw64\share\fonts\TTF" "C:\Users\runneradmin\.fonts" /e /i + echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH + rm C:\msys64\mingw64\bin\python.exe + - name: Test with tox + run: tox diff --git a/requirements.txt b/requirements.txt index 5850a99..f00410b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ pangocffi >= 0.11.0 flake8 coverage pytest +setuptools