Merge pull request #14 from ParclLabs/feature/search #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Package | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Install Pip and Tools | |
run: | | |
python -m pip install --upgrade pip | |
pip install pipenv twine build | |
- name: Install dependencies | |
run: | | |
PIPENV_PYTHON=$(which python) | |
pipenv install --dev --python "$PIPENV_PYTHON" | |
- name: Run tests | |
run: | | |
pipenv run make test # Use makefile to run tests (assumes 'make test' is setup to run pytest) | |
- name: Run Lint | |
run: | | |
pipenv run make lint # Use makefile to run lint (assumes 'make lint' is setup) | |
- name: Extract version | |
id: get_version | |
run: | | |
VERSION_LINE=$(grep 'VERSION' parcllabs/__version__.py) | |
VERSION=$(echo $VERSION_LINE | cut -d '"' -f 2) | |
echo "Extracted version: $VERSION" | |
echo "::set-output name=VERSION::$VERSION" | |
- name: Tag Repository | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
uses: actions/github-script@v5 | |
with: | |
script: | | |
const tagName = '${{ steps.get_version.outputs.VERSION }}'; | |
const ref = 'refs/tags/' + tagName; | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: ref, | |
sha: context.sha | |
}); | |
- name: Build Package | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
run: | | |
python -m build --sdist --wheel --outdir dist/ | |
- name: Check package | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
run: | | |
python -m twine check dist/* | |
- name: Upload to TestPyPI | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_KEY }} | |
run: | | |
twine upload dist/* |