Skip to content

Commit 1bd492c

Browse files
chore(release): update pypi packaging (#604)
* feat: first pass at new packaging * fix: skip pypy3.9 * fix: add wildcard on pp39 * fix: no pypy * fix: add in separate publish step * fix: update requirements.txt * fix: pipe * fix: ls first * fix: wheelhouse * fix: change the name * fix: download all artifacts * fix: update tool.setuptools * fix: split the pypi and asset building * fix: use CODECOV_ENV * fix: do some more jiggling * fix: remove log * fix: make it a file * fix: maybe like this * fix: remove setup.py cases * fix: show all files * fix: add push tags * Update pyproject.toml Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]> * fix: address some comments * fix: more comments * fix: versioning * fix: versioning * fix: remove dynamic * fix: change pattern * fix: update the patterns * fix: dist/ * fix: just dist * fix: ls * fix: oops * fix: whats in the dist * fix: how about wildcard now * fix: now with codecov * fix: hack it * fix: use steps * fix: address comments * fix: add env to cibuildwheel * fix: formatting * fix: nope * fix: try with manifest * fix: address comments * Update .github/workflows/create_release.yml Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]> * Update pyproject.toml Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]> * Update .github/workflows/build_for_pypi.yml Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]> * Update .github/workflows/build_for_pypi.yml Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]> --------- Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
1 parent 781d11f commit 1bd492c

15 files changed

+214
-159
lines changed

.github/workflows/build_assets.yml

+11-10
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
name: Build Compiled Assets
33

44
on:
5-
workflow_call:
6-
inputs:
7-
release:
8-
type: boolean
9-
default: false
10-
description: "Attach artifacts to a release"
5+
pull_request:
6+
branches:
7+
- main
8+
push:
9+
# Pattern matched against refs/tags
10+
tags:
11+
- 'v[0-9]+.[0-9]+.[0-9]+'
1112

1213
jobs:
1314
build_assets:
@@ -68,12 +69,12 @@ jobs:
6869
run: ${{matrix.CMD_BUILD}}
6970
- name: Upload a Build Artifact
7071
uses: actions/upload-artifact@v4
71-
if: inputs.release == false
72+
if: github.ref_type == 'tag'
7273
with:
7374
name: ${{ matrix.OUT_FILE_NAME }}
7475
path: ./dist/${{ matrix.OUT_FILE_NAME }}
7576
- name: Upload Release Asset
76-
if: inputs.release == true
77+
if: github.ref_type == 'tag'
7778
id: upload-release-asset
7879
uses: svenstaro/upload-release-action@v2
7980
with:
@@ -118,12 +119,12 @@ jobs:
118119
./scripts/build_${{ matrix.distro_name }}_arm.sh ${{ matrix.distro_name }}_${{ matrix.arch }}
119120
- name: Upload a Build Artifact
120121
uses: actions/upload-artifact@v4
121-
if: inputs.release == false
122+
if: github.ref_type == 'tag'
122123
with:
123124
name: codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }}
124125
path: ./dist/codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }}
125126
- name: Upload Release Asset
126-
if: inputs.release == true
127+
if: github.ref_type == 'tag'
127128
id: upload-release-asset
128129
uses: svenstaro/upload-release-action@v2
129130
with:

.github/workflows/build_for_pypi.yml

+69-29
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,87 @@
1+
---
12
name: Build and Optionally Publish to PyPi
23

34
on:
4-
workflow_call:
5-
inputs:
6-
publish:
7-
type: boolean
8-
default: false
9-
description: "Publish to PyPi"
5+
pull_request:
6+
branches:
7+
- main
8+
push:
9+
# Pattern matched against refs/tags
10+
tags:
11+
- 'v[0-9]+.[0-9]+.[0-9]+'
1012

1113
jobs:
12-
build_for_pypi:
14+
build_src_for_pypi:
1315
runs-on: ubuntu-latest
14-
permissions:
15-
id-token: write # This is required for requesting the JWT
16-
contents: read # This is required for actions/checkout
1716
steps:
1817
- uses: actions/checkout@v4
1918
with:
19+
persist-credentials: false
2020
submodules: true
21-
- name: Set up Python 3.11
22-
uses: actions/setup-python@v4
23-
with:
24-
python-version: "3.11"
2521
- name: Install dependencies
2622
run: |
27-
pip install -r requirements.txt
28-
python setup.py build
29-
python setup.py develop
30-
- name: Build distributions for different platforms
23+
pip install build
24+
- name: Build src dist
3125
run: |
32-
pip install wheel
33-
python setup.py sdist bdist_wheel --plat-name=manylinux2014_x86_64
34-
python setup.py bdist_wheel --plat-name=macosx-12.6-universal2
35-
python setup.py bdist_wheel --plat-name=win_amd64
36-
- name: Move src file to match PEP625
26+
python -m build --sdist
27+
env:
28+
PIP_CONSTRAINT: requirements.txt
29+
- name: Store the distribution packages
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: cibw-sdist
33+
path: ./**/*.tar.gz
34+
35+
build_dist_for_pypi:
36+
needs:
37+
- build_src_for_pypi
38+
runs-on: ${{ matrix.os }}
39+
strategy:
40+
matrix:
41+
os:
42+
- macos-13
43+
- macos-latest
44+
- ubuntu-24.04-arm
45+
- ubuntu-latest
46+
- windows-latest
47+
steps:
48+
- name: Download the sdist
49+
uses: actions/download-artifact@v4
50+
with:
51+
name: cibw-sdist
52+
- name: Get sdist filename
53+
id: get-sdist
3754
run: |
38-
cd dist
39-
ls | grep *.tar.gz | xargs -I x mv -- x "$(ls | grep *.tar.gz | sed 's/codecov-cli/codecov_cli/')"
40-
ls -al
41-
cd ..
55+
echo "sdist_filename=$(ls dist/)" >> "${GITHUB_OUTPUT}"
56+
shell: bash
57+
- name: Build wheels
58+
uses: pypa/[email protected]
59+
with:
60+
package-dir: dist/${{ steps.get-sdist.outputs.sdist_filename }}
61+
- name: Store the distribution packages
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: cibw-wheels-${{ matrix.os }}
65+
path: ./wheelhouse/*.whl
66+
67+
68+
publish_to_pypi:
69+
if: github.ref_type == 'tag'
70+
needs:
71+
- build_dist_for_pypi
72+
- build_src_for_pypi
73+
permissions:
74+
id-token: write # This is required for OIDC
75+
runs-on: ubuntu-latest
76+
environment:
77+
name: pypi
78+
url: https://pypi.org/p/codecov-cli
79+
steps:
80+
- name: Download artifacts
81+
uses: actions/download-artifact@v4
82+
with:
83+
pattern: cibw-*
4284
- name: Publish package to PyPi
43-
if: inputs.publish == true
4485
uses: pypa/gh-action-pypi-publish@release/v1
4586
with:
46-
attestations: false
4787
verbose: true

.github/workflows/build_main.yml

-17
This file was deleted.

.github/workflows/ci-job.yml

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
- name: Test with pytest
3131
run: |
3232
pytest --cov --junitxml=3.12junit.xml
33+
env:
34+
CODECOV_ENV: test
3335

3436
- name: Upload coverage to Codecov
3537
uses: codecov/codecov-action@v5

.github/workflows/ci.yml

+2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ jobs:
9898
- name: Test with pytest
9999
run: |
100100
pytest --cov --junitxml=${{matrix.python-version}}junit.xml
101+
env:
102+
CODECOV_ENV: test
101103
- name: Dogfooding codecov-cli
102104
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
103105
run: |

.github/workflows/create_release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- id: get-release-vars
1919
name: Configure Release Vars
2020
run: |
21-
echo release_version=v$(grep -E "version=\"[0-9]+\.[0-9]+\.[0-9]+\"" setup.py | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+") >> "$GITHUB_OUTPUT"
21+
echo release_version=v$(grep -E "version = \"[0-9]+\.[0-9]+\.[0-9]+\"" pyproject.toml | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+") >> "$GITHUB_OUTPUT"
2222
echo previous_version=$(git tag --sort=-creatordate | head -n 2 | tail -n 1) >> "$GITHUB_OUTPUT"
2323
2424
- name: Create GitHub Release

.github/workflows/create_release_pr.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ jobs:
3030
- name: Update version and push
3131
id: make-commit
3232
run: |
33-
sed -i 's/version="[0-9]\+\.[0-9]\+\.[0-9]\+"/version="${{ github.event.inputs.versionName }}"/g' setup.py
34-
git add setup.py
33+
sed -i 's/version="[0-9]\+\.[0-9]\+\.[0-9]\+"/version="${{ github.event.inputs.versionName }}"/g' pyproject.toml
34+
git add pyproject.toml
3535
git commit -S --message "Prepare release ${{ github.event.inputs.versionName }}"
3636
echo "commit=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
3737
git push origin release/${{ github.event.inputs.versionName }}

.pip-tools.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[tool.pip-tools]
2+
all-build-deps = true
3+
all-extras = true

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
include languages/treesitterjavascript/src/tree_sitter/parser.h
22
include languages/treesitterpython/src/tree_sitter/parser.h
3+
include requirements.txt

0 commit comments

Comments
 (0)