Skip to content

Commit

Permalink
chore(release): update pypi packaging (#604)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
thomasrockhu-codecov and webknjaz authored Feb 6, 2025
1 parent 781d11f commit 1bd492c
Show file tree
Hide file tree
Showing 15 changed files with 214 additions and 159 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/build_assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
name: Build Compiled Assets

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

jobs:
build_assets:
Expand Down Expand Up @@ -68,12 +69,12 @@ jobs:
run: ${{matrix.CMD_BUILD}}
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
if: inputs.release == false
if: github.ref_type == 'tag'
with:
name: ${{ matrix.OUT_FILE_NAME }}
path: ./dist/${{ matrix.OUT_FILE_NAME }}
- name: Upload Release Asset
if: inputs.release == true
if: github.ref_type == 'tag'
id: upload-release-asset
uses: svenstaro/upload-release-action@v2
with:
Expand Down Expand Up @@ -118,12 +119,12 @@ jobs:
./scripts/build_${{ matrix.distro_name }}_arm.sh ${{ matrix.distro_name }}_${{ matrix.arch }}
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
if: inputs.release == false
if: github.ref_type == 'tag'
with:
name: codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }}
path: ./dist/codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }}
- name: Upload Release Asset
if: inputs.release == true
if: github.ref_type == 'tag'
id: upload-release-asset
uses: svenstaro/upload-release-action@v2
with:
Expand Down
98 changes: 69 additions & 29 deletions .github/workflows/build_for_pypi.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,87 @@
---
name: Build and Optionally Publish to PyPi

on:
workflow_call:
inputs:
publish:
type: boolean
default: false
description: "Publish to PyPi"
pull_request:
branches:
- main
push:
# Pattern matched against refs/tags
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
build_for_pypi:
build_src_for_pypi:
runs-on: ubuntu-latest
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
submodules: true
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
pip install -r requirements.txt
python setup.py build
python setup.py develop
- name: Build distributions for different platforms
pip install build
- name: Build src dist
run: |
pip install wheel
python setup.py sdist bdist_wheel --plat-name=manylinux2014_x86_64
python setup.py bdist_wheel --plat-name=macosx-12.6-universal2
python setup.py bdist_wheel --plat-name=win_amd64
- name: Move src file to match PEP625
python -m build --sdist
env:
PIP_CONSTRAINT: requirements.txt
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: ./**/*.tar.gz

build_dist_for_pypi:
needs:
- build_src_for_pypi
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-13
- macos-latest
- ubuntu-24.04-arm
- ubuntu-latest
- windows-latest
steps:
- name: Download the sdist
uses: actions/download-artifact@v4
with:
name: cibw-sdist
- name: Get sdist filename
id: get-sdist
run: |
cd dist
ls | grep *.tar.gz | xargs -I x mv -- x "$(ls | grep *.tar.gz | sed 's/codecov-cli/codecov_cli/')"
ls -al
cd ..
echo "sdist_filename=$(ls dist/)" >> "${GITHUB_OUTPUT}"
shell: bash
- name: Build wheels
uses: pypa/[email protected]
with:
package-dir: dist/${{ steps.get-sdist.outputs.sdist_filename }}
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl


publish_to_pypi:
if: github.ref_type == 'tag'
needs:
- build_dist_for_pypi
- build_src_for_pypi
permissions:
id-token: write # This is required for OIDC
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/codecov-cli
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: cibw-*
- name: Publish package to PyPi
if: inputs.publish == true
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: false
verbose: true
17 changes: 0 additions & 17 deletions .github/workflows/build_main.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .github/workflows/ci-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
- name: Test with pytest
run: |
pytest --cov --junitxml=3.12junit.xml
env:
CODECOV_ENV: test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ jobs:
- name: Test with pytest
run: |
pytest --cov --junitxml=${{matrix.python-version}}junit.xml
env:
CODECOV_ENV: test
- name: Dogfooding codecov-cli
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- id: get-release-vars
name: Configure Release Vars
run: |
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"
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"
echo previous_version=$(git tag --sort=-creatordate | head -n 2 | tail -n 1) >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/create_release_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
- name: Update version and push
id: make-commit
run: |
sed -i 's/version="[0-9]\+\.[0-9]\+\.[0-9]\+"/version="${{ github.event.inputs.versionName }}"/g' setup.py
git add setup.py
sed -i 's/version="[0-9]\+\.[0-9]\+\.[0-9]\+"/version="${{ github.event.inputs.versionName }}"/g' pyproject.toml
git add pyproject.toml
git commit -S --message "Prepare release ${{ github.event.inputs.versionName }}"
echo "commit=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
git push origin release/${{ github.event.inputs.versionName }}
Expand Down
3 changes: 3 additions & 0 deletions .pip-tools.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[tool.pip-tools]
all-build-deps = true
all-extras = true
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include languages/treesitterjavascript/src/tree_sitter/parser.h
include languages/treesitterpython/src/tree_sitter/parser.h
include requirements.txt
Loading

0 comments on commit 1bd492c

Please sign in to comment.