From 5f371b8bcedf6a6b8152b3fc1a6692ba3b09507f Mon Sep 17 00:00:00 2001 From: Tobias Pitters Date: Thu, 17 Jul 2025 01:51:31 +0200 Subject: [PATCH 1/2] add workflows --- .github/workflows/ci.yml | 40 ++++++++++++++++++ .github/workflows/publish-prod.yml | 68 ++++++++++++++++++++++++++++++ .github/workflows/publish-test.yml | 52 +++++++++++++++++++++++ 3 files changed, 160 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/publish-prod.yml create mode 100644 .github/workflows/publish-test.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e7594de --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,40 @@ +name: CI + +on: + push: + branches: [ main, develop ] + pull_request: + branches: [ main, develop ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e ".[dev]" + + - name: Run tests + run: | + pytest tests/ -v + + - name: Test package installation + run: | + pip install -e . + python -c "from xflow import CEMLflowPlugin, ReportGenerator; print('Import successful')" + + - name: Test basic functionality + run: | + python test_plugin_auto_mpg.py \ No newline at end of file diff --git a/.github/workflows/publish-prod.yml b/.github/workflows/publish-prod.yml new file mode 100644 index 0000000..fa2b62f --- /dev/null +++ b/.github/workflows/publish-prod.yml @@ -0,0 +1,68 @@ +name: Publish to PyPI + +on: + push: + tags: + - 'v*' # Trigger on version tags like v1.0.0, v1.2.3, etc. + +jobs: + publish-prod: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - name: Install build dependencies + run: | + python -m pip install --upgrade pip + pip install build twine + + - name: Extract version from tag + id: extract_version + run: | + VERSION=${GITHUB_REF#refs/tags/v} + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Extracted version: $VERSION" + + - name: Update version in pyproject.toml + run: | + sed -i 's/version = "[^"]*"/version = "${{ steps.extract_version.outputs.version }}"/' pyproject.toml + echo "Updated pyproject.toml version to ${{ steps.extract_version.outputs.version }}" + + - name: Build package + run: python -m build + + - name: Check package + run: python -m twine check dist/* + + - name: Publish to PyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: | + python -m twine upload dist/* + + - name: Create GitHub Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ steps.extract_version.outputs.version }} + body: | + ## Changes in this Release + + Please see the [CHANGELOG.md](CHANGELOG.md) for detailed changes. + + ## Installation + + ```bash + pip install xflow==${{ steps.extract_version.outputs.version }} + ``` + draft: false + prerelease: false \ No newline at end of file diff --git a/.github/workflows/publish-test.yml b/.github/workflows/publish-test.yml new file mode 100644 index 0000000..ac3694d --- /dev/null +++ b/.github/workflows/publish-test.yml @@ -0,0 +1,52 @@ +name: Publish to Test PyPI + +on: + workflow_dispatch: + inputs: + version: + description: 'Version to publish (optional, will use pyproject.toml version if not specified)' + required: false + type: string + +jobs: + publish-test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - name: Install build dependencies + run: | + python -m pip install --upgrade pip + pip install build twine + + - name: Update version if specified + if: ${{ github.event.inputs.version != '' }} + run: | + sed -i 's/version = "[^"]*"/version = "${{ github.event.inputs.version }}"/' pyproject.toml + echo "Updated version to ${{ github.event.inputs.version }}" + + - name: Build package + run: python -m build + + - name: Check package + run: python -m twine check dist/* + + - name: Publish to Test PyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} + run: | + python -m twine upload --repository testpypi dist/* + + - name: Test installation from Test PyPI + run: | + # Wait a bit for the package to be available + sleep 30 + pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ xflow + python -c "from xflow import CEMLflowPlugin; print('Package installed successfully')" \ No newline at end of file From b4f34ef88e4348b432ab944b887b714176d5c15d Mon Sep 17 00:00:00 2001 From: Tobias Pitters Date: Thu, 17 Jul 2025 08:06:15 +0200 Subject: [PATCH 2/2] update publish-test.yml --- .github/workflows/publish-test.yml | 46 ++++++++++-------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/.github/workflows/publish-test.yml b/.github/workflows/publish-test.yml index ac3694d..22c873c 100644 --- a/.github/workflows/publish-test.yml +++ b/.github/workflows/publish-test.yml @@ -9,44 +9,28 @@ on: type: string jobs: - publish-test: + build: runs-on: ubuntu-latest - + steps: - - uses: actions/checkout@v4 - + - name: Checkout code + uses: actions/checkout@v2 + - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v2 with: - python-version: '3.9' - - - name: Install build dependencies + python-version: '3.x' + + - name: Install dependencies run: | python -m pip install --upgrade pip - pip install build twine - - - name: Update version if specified - if: ${{ github.event.inputs.version != '' }} - run: | - sed -i 's/version = "[^"]*"/version = "${{ github.event.inputs.version }}"/' pyproject.toml - echo "Updated version to ${{ github.event.inputs.version }}" - + pip install setuptools wheel twine build + - name: Build package run: python -m build - - - name: Check package - run: python -m twine check dist/* - - - name: Publish to Test PyPI + + - name: Publish package to Test PyPI env: TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} - run: | - python -m twine upload --repository testpypi dist/* - - - name: Test installation from Test PyPI - run: | - # Wait a bit for the package to be available - sleep 30 - pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ xflow - python -c "from xflow import CEMLflowPlugin; print('Package installed successfully')" \ No newline at end of file + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }} + run: twine upload --repository-url https://test.pypi.org/legacy/ dist/* \ No newline at end of file