2023-02-15 02:47:42 +01:00
|
|
|
name: pypi
|
2022-08-03 20:57:27 +02:00
|
|
|
|
|
|
|
on:
|
2022-08-15 05:47:36 +02:00
|
|
|
push:
|
|
|
|
tags:
|
2023-01-05 00:46:48 +01:00
|
|
|
- "*"
|
2022-08-03 20:57:27 +02:00
|
|
|
branches:
|
|
|
|
- 'master'
|
|
|
|
paths:
|
2023-02-14 21:50:51 +01:00
|
|
|
- src/khoj/**
|
2024-06-22 16:42:41 +02:00
|
|
|
- src/interface/web/**
|
2023-02-16 10:12:04 +01:00
|
|
|
- pyproject.toml
|
2023-02-15 02:47:42 +01:00
|
|
|
- .github/workflows/pypi.yml
|
2023-02-14 20:47:25 +01:00
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- 'master'
|
|
|
|
paths:
|
2023-02-14 21:50:51 +01:00
|
|
|
- src/khoj/**
|
2024-06-22 16:42:41 +02:00
|
|
|
- src/interface/web/**
|
2023-02-16 10:12:04 +01:00
|
|
|
- pyproject.toml
|
2023-02-15 02:47:42 +01:00
|
|
|
- .github/workflows/pypi.yml
|
2022-08-03 20:57:27 +02:00
|
|
|
|
|
|
|
jobs:
|
2022-08-04 02:49:32 +02:00
|
|
|
publish:
|
2023-02-15 02:47:42 +01:00
|
|
|
name: Publish Python Package to PyPI
|
2024-03-28 19:28:15 +01:00
|
|
|
runs-on: ubuntu-latest
|
2024-03-28 18:28:36 +01:00
|
|
|
permissions:
|
|
|
|
id-token: write
|
2022-08-03 20:57:27 +02:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
2023-02-15 02:47:42 +01:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2022-08-03 20:57:27 +02:00
|
|
|
|
2024-03-28 07:49:07 +01:00
|
|
|
- name: Set up Python 3.11
|
2022-08-03 20:57:27 +02:00
|
|
|
uses: actions/setup-python@v4
|
|
|
|
with:
|
2024-03-28 07:49:07 +01:00
|
|
|
python-version: '3.11'
|
2022-08-03 20:57:27 +02:00
|
|
|
|
2023-03-01 17:56:39 +01:00
|
|
|
- name: ⬇️ Install Application
|
2023-02-15 04:44:00 +01:00
|
|
|
run: python -m pip install --upgrade pip && pip install --upgrade .
|
2022-08-03 20:57:27 +02:00
|
|
|
|
2024-06-22 16:42:41 +02:00
|
|
|
- name: Install the Next.js application
|
|
|
|
run: |
|
|
|
|
yarn install
|
|
|
|
working-directory: src/interface/web
|
|
|
|
|
|
|
|
- name: Build & export static Next.js app to Django static assets
|
|
|
|
run: |
|
|
|
|
yarn ciexport
|
|
|
|
working-directory: src/interface/web
|
|
|
|
|
2023-02-15 02:47:42 +01:00
|
|
|
- name: ⚙️ Build Python Package
|
|
|
|
run: |
|
2022-08-19 20:00:12 +02:00
|
|
|
# Setup Environment for Reproducible Builds
|
|
|
|
export PYTHONHASHSEED=42
|
|
|
|
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
|
2023-02-15 04:44:00 +01:00
|
|
|
rm -rf dist
|
2022-08-19 20:00:12 +02:00
|
|
|
|
2023-02-14 20:41:33 +01:00
|
|
|
# Build PyPi Package
|
2023-02-15 04:44:00 +01:00
|
|
|
pipx run build
|
2023-02-14 20:41:33 +01:00
|
|
|
|
2023-03-01 17:56:39 +01:00
|
|
|
- name: 🌡️ Validate Python Package
|
2023-02-15 02:47:42 +01:00
|
|
|
run: |
|
2023-02-14 20:41:33 +01:00
|
|
|
# Validate PyPi Package
|
2023-11-21 20:33:43 +01:00
|
|
|
pipx run check-wheel-contents dist/*.whl --ignore W004
|
2023-02-15 04:44:00 +01:00
|
|
|
pipx run twine check dist/*
|
2023-02-14 20:41:33 +01:00
|
|
|
|
2023-02-15 02:47:42 +01:00
|
|
|
- name: ⏫ Upload Python Package Artifacts
|
2023-02-15 04:44:00 +01:00
|
|
|
uses: actions/upload-artifact@v3
|
2023-02-15 02:47:42 +01:00
|
|
|
with:
|
2023-02-15 04:44:00 +01:00
|
|
|
name: khoj-assistant
|
|
|
|
path: dist/*.whl
|
2023-02-15 02:47:42 +01:00
|
|
|
|
2023-02-15 04:44:00 +01:00
|
|
|
- name: 📦 Publish Python Package to PyPI
|
2023-02-15 02:47:42 +01:00
|
|
|
if: startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/master'
|
2024-03-28 08:17:31 +01:00
|
|
|
uses: pypa/gh-action-pypi-publish@v1.8.14
|