1010 branches : [ "main" ]
1111
1212permissions :
13- actions : write
14- id-token : write # for OIDC
13+ id-token : write
1514 contents : read
1615
1716jobs :
1817 prepare :
1918 runs-on : ubuntu-latest
2019 outputs :
2120 package : ${{ steps.pkg.outputs.package }}
21+ pypi_url : ${{ steps.pkg.outputs.pypi_url }}
2222 steps :
2323 - name : Compute package name from the repository's
2424 id : pkg
2525 run : |
2626 name="${GITHUB_REPOSITORY##*/}"
2727 echo "package=${name#python-}" >> $GITHUB_OUTPUT
28+ echo "pypi_url=https://pypi.org/p/${name#python-}" >> $GITHUB_OUTPUT
2829 build :
2930 needs : prepare
3031 runs-on : ${{ matrix.os }}
3132 strategy :
3233 fail-fast : false
3334 matrix :
3435 os : [ubuntu-latest]
35- python-version : ["3.10", "3.11", "3.12", "3.13"]
36+ python-version : ["3.9", "3. 10", "3.11", "3.12", "3.13"]
3637 env :
3738 package : ${{ needs.prepare.outputs.package }}
3839 steps :
4344 python-version : ${{ matrix.python-version }}
4445 - name : Install ${{ env.package }}
4546 run : |
47+ sudo apt install graphviz libgraphviz-dev
4648 python -m pip install --upgrade pip
4749 python -m pip install pytest pytest-cov coverage
4850 pip install -r requirements.txt
@@ -52,19 +54,25 @@ jobs:
5254 pytest --cov=$package
5355 coverage :
5456 needs : [prepare, build]
57+ permissions :
58+ contents : write
5559 runs-on : ubuntu-latest
5660 env :
5761 cov_badge_path : docs/coverage.svg
5862 package : ${{ needs.prepare.outputs.package }}
5963 python_version : " 3.13"
6064 steps :
6165 - uses : actions/checkout@v5
66+ with :
67+ fetch-depth : 0
68+ ref : ${{ github.head_ref || github.ref_name }}
6269 - name : Set up Python ${{ env.python_version }}
6370 uses : actions/setup-python@v6
6471 with :
6572 python-version : ${{ env.python_version }}
6673 - name : Install ${{ env.package }}
6774 run : |
75+ sudo apt install graphviz libgraphviz-dev
6876 python -m pip install --upgrade pip
6977 python -m pip install pytest pytest-cov
7078 pip install -r requirements.txt
@@ -79,20 +87,21 @@ jobs:
7987 id : changed_files
8088 with :
8189 files : ${{ env.cov_badge_path }}
82- - name : Commit files
90+ - name : Push coverage badge
8391 if : steps.changed_files.outputs.files_changed == 'true'
8492 run : |
8593 git config --local user.email "github-actions[bot]@users.noreply.github.com"
8694 git config --local user.name "github-actions[bot]"
95+ git fetch origin
96+ git checkout coverage-badge || git checkout -b coverage-badge
8797 git add $cov_badge_path
88- git commit -m "Updated coverage.svg"
89- - name : Push changes
90- if : steps.changed_files.outputs.files_changed == 'true'
91- uses : ad-m/github-push-action@master
92- with :
93- github_token : ${{ secrets.github_token }}
94- branch : ${{ github.ref }}
98+ git diff --cached --quiet && exit 0
99+ git commit -m "Update coverage badge"
100+ git push origin coverage-badge --force
95101 deploy :
102+ environment :
103+ name : pypi
104+ url : ${{ needs.prepare.outputs.pypi_url }}
96105 runs-on : ubuntu-latest
97106 needs : [prepare, coverage]
98107 steps :
0 commit comments