]> git.madduck.net Git - etc/vim.git/blob - .github/workflows/pypi_upload.yml

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

41ab6460793e47c8a80b0317a537e4aaf1ccdcfe
[etc/vim.git] / .github / workflows / pypi_upload.yml
1 name: Build and publish
2
3 on:
4   release:
5     types: [published]
6   pull_request:
7   push:
8     branches:
9       - main
10
11 permissions:
12   contents: read
13
14 jobs:
15   main:
16     name: sdist + pure wheel
17     runs-on: ubuntu-latest
18     if: github.event_name == 'release'
19
20     steps:
21       - uses: actions/checkout@v4
22
23       - name: Set up latest Python
24         uses: actions/setup-python@v4
25         with:
26           python-version: "*"
27
28       - name: Install latest pip, build, twine
29         run: |
30           python -m pip install --upgrade --disable-pip-version-check pip
31           python -m pip install --upgrade build twine
32
33       - name: Build wheel and source distributions
34         run: python -m build
35
36       - if: github.event_name == 'release'
37         name: Upload to PyPI via Twine
38         env:
39           TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
40         run: twine upload --verbose -u '__token__' dist/*
41
42   generate_wheels_matrix:
43     name: generate wheels matrix
44     runs-on: ubuntu-latest
45     outputs:
46       include: ${{ steps.set-matrix.outputs.include }}
47     steps:
48       - uses: actions/checkout@v4
49       - name: Install cibuildwheel and pypyp
50         run: |
51           pipx install cibuildwheel==2.15.0
52           pipx install pypyp==1
53       - name: generate matrix
54         if: github.event_name != 'pull_request'
55         run: |
56           {
57             cibuildwheel --print-build-identifiers --platform linux \
58             | pyp 'json.dumps({"only": x, "os": "ubuntu-latest"})' \
59             && cibuildwheel --print-build-identifiers --platform macos \
60             | pyp 'json.dumps({"only": x, "os": "macos-latest"})' \
61             && cibuildwheel --print-build-identifiers --platform windows \
62             | pyp 'json.dumps({"only": x, "os": "windows-latest"})'
63           } | pyp 'json.dumps(list(map(json.loads, lines)))' > /tmp/matrix
64         env:
65           CIBW_ARCHS_LINUX: x86_64
66           CIBW_ARCHS_MACOS: x86_64 arm64
67           CIBW_ARCHS_WINDOWS: AMD64
68       - name: generate matrix (PR)
69         if: github.event_name == 'pull_request'
70         run: |
71           cibuildwheel --print-build-identifiers --platform linux \
72           | pyp 'json.dumps({"only": x, "os": "ubuntu-latest"})' \
73           | pyp 'json.dumps(list(map(json.loads, lines)))' > /tmp/matrix
74         env:
75           CIBW_BUILD: "cp38-* cp311-*"
76           CIBW_ARCHS_LINUX: x86_64
77       - id: set-matrix
78         run: echo "include=$(cat /tmp/matrix)" | tee -a $GITHUB_OUTPUT
79
80   mypyc:
81     name: mypyc wheels ${{ matrix.only }}
82     needs: generate_wheels_matrix
83     runs-on: ${{ matrix.os }}
84     strategy:
85       fail-fast: false
86       matrix:
87         include: ${{ fromJson(needs.generate_wheels_matrix.outputs.include) }}
88
89     steps:
90       - uses: actions/checkout@v4
91       - uses: pypa/cibuildwheel@v2.16.1
92         with:
93           only: ${{ matrix.only }}
94
95       - name: Upload wheels as workflow artifacts
96         uses: actions/upload-artifact@v3
97         with:
98           name: ${{ matrix.name }}-mypyc-wheels
99           path: ./wheelhouse/*.whl
100
101       - if: github.event_name == 'release'
102         name: Upload wheels to PyPI via Twine
103         env:
104           TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
105         run: pipx run twine upload --verbose -u '__token__' wheelhouse/*.whl
106
107   update-stable-branch:
108     name: Update stable branch
109     needs: [main, mypyc]
110     runs-on: ubuntu-latest
111     if: github.event_name == 'release'
112     permissions:
113       contents: write
114
115     steps:
116       - name: Checkout stable branch
117         uses: actions/checkout@v4
118         with:
119           ref: stable
120           fetch-depth: 0
121
122       - if: github.event_name == 'release'
123         name: Update stable branch to release tag & push
124         run: |
125           git reset --hard ${{ github.event.release.tag_name }}
126           git push