mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-08 05:39:13 +00:00
Fix workflow to publish Khoj python package to PyPi
This commit is contained in:
37
.github/workflows/pypi.yml
vendored
37
.github/workflows/pypi.yml
vendored
@@ -32,59 +32,50 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-version: '3.10'
|
python-version: '3.10'
|
||||||
|
|
||||||
- name: Install Dependencies
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install build twine check-wheel-contents
|
|
||||||
|
|
||||||
- name: Install Application
|
- name: Install Application
|
||||||
run: |
|
run: python -m pip install --upgrade pip && pip install --upgrade .
|
||||||
pip install --upgrade .
|
|
||||||
|
|
||||||
- name: 📝 Set Pre-Release Version for Master
|
- name: 📝 Set Pre-Release Version for Master
|
||||||
if: github.ref == 'refs/heads/master'
|
if: github.ref == 'refs/heads/master'
|
||||||
run: |
|
run: sed -E -i "s/version=(.*)',/version=\1a$(date +%s)',/g" setup.py
|
||||||
# Set Pre-Release Version
|
|
||||||
sed -E -i "s/version=(.*)',/version=\1a$(date +%s)',/g" setup.py
|
|
||||||
|
|
||||||
- name: 📝 Set Development Version for PR
|
- name: 📝 Set Development Version for PR
|
||||||
if: github.event_name == 'pull_request'
|
if: github.event_name == 'pull_request'
|
||||||
env:
|
env:
|
||||||
PULL_REQUEST_NUMBER: ${{ github.event.number }}
|
PULL_REQUEST_NUMBER: ${{ github.event.number }}
|
||||||
run: |
|
run: sed -E -i "s/version=(.*)',/version=\1.dev$PULL_REQUEST_NUMBER$(date +%s)',/g" setup.py
|
||||||
# Set Development Release Version
|
|
||||||
sed -E -i "s/version=(.*)',/version=\1.dev$PULL_REQUEST_NUMBER$(date +%s)',/g" setup.py
|
|
||||||
|
|
||||||
- name: ⚙️ Build Python Package
|
- name: ⚙️ Build Python Package
|
||||||
run: |
|
run: |
|
||||||
# Setup Environment for Reproducible Builds
|
# Setup Environment for Reproducible Builds
|
||||||
export PYTHONHASHSEED=42
|
export PYTHONHASHSEED=42
|
||||||
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
|
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
|
||||||
|
rm -rf dist
|
||||||
|
|
||||||
# Build PyPi Package
|
# Build PyPi Package
|
||||||
rm -rf dist
|
pipx run build
|
||||||
python -m build
|
|
||||||
|
|
||||||
- name: 👀 Validate Python Package
|
- name: 👀 Validate Python Package
|
||||||
run: |
|
run: |
|
||||||
# Validate PyPi Package
|
# Validate PyPi Package
|
||||||
check-wheel-contents dist/*.whl
|
pipx run check-wheel-contents dist/*.whl
|
||||||
twine check dist/*
|
pipx run twine check dist/*
|
||||||
|
|
||||||
- name: ⏫ Upload Python Package Artifacts
|
- name: ⏫ Upload Python Package Artifacts
|
||||||
- uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
path: dist/*
|
name: khoj-assistant
|
||||||
|
path: dist/*.whl
|
||||||
|
|
||||||
- name: 📦 Publish Python Package from Master or Release to PyPI
|
- name: 📦 Publish Python Package to PyPI
|
||||||
if: startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/master'
|
if: startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/master'
|
||||||
uses: pypa/gh-action-pypi-publish@release/v1.6.4
|
uses: pypa/gh-action-pypi-publish@v1.6.4
|
||||||
with:
|
with:
|
||||||
password: ${{ secrets.PYPI_API_KEY }}
|
password: ${{ secrets.PYPI_API_KEY }}
|
||||||
|
|
||||||
- name: 📦 Publish Python Package from Repo PR to Test PyPI
|
- name: 📦 Publish Python Package to Test PyPI
|
||||||
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
|
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
|
||||||
uses: pypa/gh-action-pypi-publish@release/v1.6.4
|
uses: pypa/gh-action-pypi-publish@v1.6.4
|
||||||
with:
|
with:
|
||||||
password: ${{ secrets.PYPI_API_KEY }}
|
password: ${{ secrets.PYPI_API_KEY }}
|
||||||
repository_url: https://test.pypi.org/legacy/
|
repository_url: https://test.pypi.org/legacy/
|
||||||
Reference in New Issue
Block a user