diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 469d05e..bb83add 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,10 +1,18 @@ -name: Build & Upload Python Package to PyPI +name: Build & Deploy to PyPI on: + workflow_dispatch: + inputs: + environment: + description: Deployment environment + required: true + type: choice + options: + - test + - production + release: - types: [ published ] - branches: - - main + types: [published] jobs: deploy: @@ -43,9 +51,31 @@ jobs: echo "Tag version: $TAG_VERSION" uv version $TAG_VERSION - - name: Build and publish 🚀 - env: - UV_PUBLISH_TOKEN: ${{ secrets.UV_PUBLISH_TOKEN }} + - name: Generate HTML documentation 📚 + if: github.event_name == 'release' || inputs.environment == 'production' + run: | + uv sync --all-groups --frozen + uv pip install -e . + uv run pdoc --html -f -o ./docs keboola.component + mv ./docs/keboola/component/* docs + rm -r ./docs/keboola + + - name: Build package 📦 run: | uv build - uv publish + + - name: Publish to PyPI 🚀 + env: + UV_PUBLISH_TOKEN: ${{ inputs.environment == 'test' && secrets.UV_PUBLISH_TOKEN_TEST_PYPI || secrets.UV_PUBLISH_TOKEN }} + run: | + uv publish ${{ inputs.environment == 'test' && '--index testpypi' || '' }} + + - name: Commit documentation 📝 + if: github.event_name == 'release' || inputs.environment == 'production' + run: | + TAG_VERSION=${GITHUB_REF#refs/tags/} + git config --global user.name 'KCF' + git config --global user.email 'kcf@users.noreply.github.com' + git add docs + git commit -m "docs: update for release $TAG_VERSION 📚" || echo "No changes to commit" + git push diff --git a/.github/workflows/deploy_to_test.yml b/.github/workflows/deploy_to_test.yml deleted file mode 100644 index 40989f6..0000000 --- a/.github/workflows/deploy_to_test.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Build & Upload Python Package To Test PyPI - -on: workflow_dispatch - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout 🛒 - uses: actions/checkout@v4 - - - name: Install uv 💜 - uses: astral-sh/setup-uv@v6 - - - name: Install and run ruff 🐶 - uses: astral-sh/ruff-action@v3 - - - name: Set up Python 🐍 - uses: actions/setup-python@v4 - with: - python-version: "3.13" - - - name: Install dependencies 📦 - run: | - uv sync --all-groups --frozen - - - name: Lint with flake8 ❄️ - run: | - uv run flake8 - - - name: Test with pytest ✅ - run: | - uv run pytest tests - - - name: Version replacement based on tag ↔️ - if: github.ref_type == 'tag' - run: | - TAG_VERSION=${GITHUB_REF#refs/tags/} - echo "Tag version: $TAG_VERSION" - uv version $TAG_VERSION - - - name: Build and publish 🚀 - env: - UV_PUBLISH_TOKEN: ${{ secrets.UV_PUBLISH_TOKEN_TEST_PYPI }} - run: | - uv build - uv publish --index testpypi diff --git a/.github/workflows/push_dev.yml b/.github/workflows/push.yml similarity index 70% rename from .github/workflows/push_dev.yml rename to .github/workflows/push.yml index 223344a..15462a4 100644 --- a/.github/workflows/push_dev.yml +++ b/.github/workflows/push.yml @@ -1,13 +1,12 @@ -name: Build & Test (side branches) +name: Build & Test on: push: - branches: - - "**" - - "!main" + branches-ignore: + - main jobs: - build: + test: runs-on: ubuntu-latest strategy: matrix: @@ -39,10 +38,3 @@ jobs: - name: Test with pytest ✅ run: | uv run pytest tests - - - name: Version replacement based on tag ↔️ - if: github.ref_type == 'tag' - run: | - TAG_VERSION=${GITHUB_REF#refs/tags/} - echo "Tag version: $TAG_VERSION" - uv version $TAG_VERSION diff --git a/.github/workflows/push_main.yml b/.github/workflows/push_main.yml deleted file mode 100644 index 452ac9b..0000000 --- a/.github/workflows/push_main.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Build, Test & Generate Docs (main branch) - -on: - push: - branches: - - "main" - -jobs: - docs: - runs-on: ubuntu-latest - steps: - - name: Checkout 🛒 - uses: actions/checkout@v4 - - - name: Install uv 💜 - uses: astral-sh/setup-uv@v6 - - - name: Set up Python 🐍 - uses: actions/setup-python@v4 - with: - python-version: "3.13" - - - name: Create html documentation 📚 - run: | - uv sync --all-groups --frozen - uv run pdoc --html -f -o ./docs keboola.component - mv ./docs/keboola/component/* docs - rm -r ./docs/keboola - - - name: Commit docs 📝 - run: | - git config --global user.name 'KCF' - git config --global user.email 'kcf@users.noreply.github.com' - git commit --allow-empty -am "Automated html docs build" - git push