Debian Codegraph @

.github/workflows/publish-release.yml

raw
1 on:
2 push:
3 tags:
4 - "v*" # Push events to matching `v*` version srings. e.g. v1.0, v20.15.10
5
6 name: Create and Publish Release
7
8 jobs:
9 build:
10 name: Build distribution
11 runs-on: ubuntu-latest
12 permissions:
13 contents: write
14 steps:
15 - uses: actions/checkout@v2
16 with:
17 submodules: recursive
18 fetch-depth: 0
19 - name: Set up Python
20 uses: actions/setup-python@v2
21 with:
22 python-version: '3.x'
23
24 - name: Install release dependencies
25 run: |
26 python -m pip install --upgrade pip
27 pip install --upgrade setuptools wheel build
28
29 - name: Get release notes
30 id: release_notes
31 run: |
32 # By default, GH Actions checkout will only fetch a single commit.
33 # For us to extract the release notes, we need to fetch the tags
34 # and tag annotations as well.
35 # https://github.com/actions/checkout/issues/290
36 git fetch --tags --force
37 TAG_NAME=${GITHUB_REF/refs\/tags\//}
38 echo "$(git tag -l --format='%(contents)' $TAG_NAME)" > "${{ runner.temp }}/CHANGELOG.md"
39
40 - name: Create GitHub release
41 id: create_release
42 uses: actions/create-release@v1
43 env:
44 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45 with:
46 tag_name: ${{ github.ref }}
47 release_name: ${{ github.ref }}
48 body_path: "${{ runner.temp }}/CHANGELOG.md"
49 draft: false
50 prerelease: false
51
52 - name: Build a binary wheel and a source tarball
53 run: python3 -m build
54 - name: Store the distribution packages
55 uses: actions/upload-artifact@v4
56 with:
57 name: python-package-distributions
58 path: dist/
59
60 publish-to-pypi:
61 name: >-
62 Publish Python 🐍 distribution 📦 to PyPI
63 if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
64 needs:
65 - build
66 runs-on: ubuntu-latest
67 environment:
68 name: pypi
69 url: https://pypi.org/p/axisregistry
70 permissions:
71 id-token: write # IMPORTANT: mandatory for trusted publishing
72 steps:
73 - name: Download all the dists
74 uses: actions/download-artifact@v4
75 with:
76 name: python-package-distributions
77 path: dist/
78 - name: Publish distribution 📦 to PyPI
79 uses: pypa/gh-action-pypi-publish@release/v1
80 with:
81 # repository-url: https://test.pypi.org/legacy/ # for testing purposes
82 verify-metadata: false # twine previously didn't verify metadata when uploading