mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-27 17:35:07 +01:00
88 lines
No EOL
2.4 KiB
YAML
88 lines
No EOL
2.4 KiB
YAML
name: publish
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "*"
|
|
branches:
|
|
- 'master'
|
|
paths:
|
|
- src/**
|
|
- setup.py
|
|
- .github/workflows/publish.yml
|
|
|
|
jobs:
|
|
publish:
|
|
name: Publish App to PyPI
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Set up Python 3.10
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.10'
|
|
|
|
- name: Install Dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install build twine
|
|
|
|
- name: Install Application
|
|
run: |
|
|
pip install --upgrade .
|
|
|
|
- name: Publish Release to PyPI
|
|
if: startsWith(github.ref, 'refs/tags')
|
|
env:
|
|
TWINE_USERNAME: __token__
|
|
TWINE_PASSWORD: ${{ secrets.PYPI_API_KEY }}
|
|
run: |
|
|
# Setup Environment for Reproducible Builds
|
|
export PYTHONHASHSEED=42
|
|
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
|
|
|
|
# Build and Upload PyPi Package
|
|
rm -rf dist
|
|
python -m build
|
|
twine check dist/*
|
|
twine upload --verbose dist/*
|
|
|
|
- name: Publish Master to PyPI
|
|
if: github.ref == 'refs/heads/master'
|
|
env:
|
|
TWINE_USERNAME: __token__
|
|
TWINE_PASSWORD: ${{ secrets.PYPI_API_KEY }}
|
|
run: |
|
|
# Set Pre-Release Version
|
|
sed -E -i "s/version=(.*)',/version=\1a$(date +%s)',/g" setup.py
|
|
|
|
# Setup Environment for Reproducible Builds
|
|
export PYTHONHASHSEED=42
|
|
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
|
|
|
|
# Build and Upload PyPi Package
|
|
rm -rf dist
|
|
python -m build
|
|
twine check dist/*
|
|
twine upload --verbose dist/*
|
|
|
|
- name: Publish PR to Test PyPI
|
|
if: github.event_name == 'pull_request'
|
|
env:
|
|
TWINE_USERNAME: __token__
|
|
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_KEY }}
|
|
PULL_REQUEST_NUMBER: ${{ github.event.number }}
|
|
run: |
|
|
# Set Development Release Version
|
|
sed -E -i "s/version=(.*)',/version=\1.dev$PULL_REQUEST_NUMBER$(date +%s)',/g" setup.py
|
|
|
|
# Setup Environment for Reproducible Builds
|
|
export PYTHONHASHSEED=42
|
|
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
|
|
|
|
# Build and Upload PyPi Package
|
|
rm -rf dist
|
|
python -m build
|
|
twine check dist/*
|
|
twine upload -r testpypi --verbose dist/* |