Skip to content

Commit

Permalink
chore: automate testpypi releases (#118)
Browse files Browse the repository at this point in the history
## Changes

- remove root repo from release please. There is no need to track change
to the top level of the repo
- add step to release.yml to publish to testpypi
- add make recipes to build and release to testpypi
- sync the current version of python api with release please manifest
- add comment on how python api tags are created

## Testing steps

- tested using this branch at the target. Verified the release is
created.

## Notes for Reviewer
  • Loading branch information
Bento007 authored Mar 15, 2024
1 parent 841fddf commit b5a1a66
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 8 deletions.
32 changes: 27 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ jobs:
with:
manifest-file: ".release-please-manifest.json"
config-file: "release-please-config.json"
target-branch: main
target-branch: "main"
outputs:
release_created: ${{ steps.release.outputs.ontology-assets--release_created }}
upload_url: ${{ steps.release.outputs.ontology-assets--upload_url }}
ontology_assets_upload_url: ${{ steps.release.outputs.ontology-assets--upload_url }}
paths_released: ${{ steps.release.outputs.paths_released }}

add-release-artifacts:
runs-on: [ubuntu-latest]
needs: release-please
if: ${{ needs.release-please.outputs.release_created == 'true' }}
if: contains(needs.release-please.outputs.paths_released, 'ontology-assets')
strategy:
matrix:
include:
Expand All @@ -53,9 +53,31 @@ jobs:
- name: Upload release asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ needs.release-please.outputs.upload_url }}
upload_url: ${{ needs.release-please.outputs.ontology_assets_upload_url }}
asset_path: "ontology-assets/${{ matrix.file_name }}"
asset_name: ${{ matrix.file_name }}
asset_content_type: ${{ matrix.content_type }}
env:
GITHUB_TOKEN: ${{ github.token }}

publish-pypi-package:
runs-on: [ubuntu-latest]
needs: release-please
if: contains(needs.release-please.outputs.paths_released, 'api/python')
steps:
- name: Checkout main branch
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 1
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: build and publish
# TODO change to make publish
run: |
make test/publish -C api/python
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TESTPYPI_TOKEN_BENTO007 }}
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"api/python":"0.0.1","ontology-assets":"0.0.1",".":"0.0.1"}
{"api/python":"0.0.2","ontology-assets":"0.0.1",".":"0.0.1"}
12 changes: 12 additions & 0 deletions api/python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,17 @@ package-data:
cp -r ../../ontology-assets/ ./src/cellxgene_ontology_guide/data
touch ./src/cellxgene_ontology_guide/data/__init__.py

build: package-data
python -m pip install --upgrade pip
pip install build twine
python -m build

test/publish: build
python -m twine upload --repository testpypi dist/*

publish: build
python -m twine upload dist/*

unit-tests:
python -m pytest tests

1 change: 1 addition & 0 deletions api/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ where = ["src"]
version_file = "src/cellxgene_ontology_guide/_version.py"
version_scheme = "python-simplified-semver"
root = "../.." # relative to the location of the pyproject.toml file
# tags are generated by release-please
tag_regex = "^python-api-(?P<version>[vV]?\\d+(?:\\.\\d+){0,2}[^\\+]*)(?:\\+.*)?$"

[tool.pytest.ini_options]
Expand Down
3 changes: 1 addition & 2 deletions release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
},
"ontology-assets": {
"package-name": "ontology-assets"
},
".": {}
}
}
}

0 comments on commit b5a1a66

Please sign in to comment.