Merge branch 'feat/v2.0.0' into feat/rename-argilla-2-argilla-v1 #93
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | |
name: Build and publish the `argilla-sdk` python package | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
workflow_dispatch: | |
inputs: | |
release: | |
description: "If true, the workflow will publish the package to PyPI. Default is false." | |
default: false | |
push: | |
paths: | |
- "argilla-sdk/**" | |
- "!argilla-sdk/docs/**" | |
branches: | |
- "develop" | |
- "main" | |
- "feat/**" | |
pull_request: | |
paths: | |
- "argilla-sdk/**" | |
- "!argilla-sdk/docs/**" | |
branches: | |
- "develop" | |
- "main" | |
- "feat/**" | |
release: | |
types: | |
- "published" | |
defaults: | |
run: | |
working-directory: argilla-sdk | |
jobs: | |
build: | |
services: | |
argilla-quickstart: | |
image: argilla/argilla-quickstart:main | |
ports: | |
- 6900:6900 | |
env: | |
ANNOTATOR_USERNAME: annotator | |
OWNER_USERNAME: argilla | |
OWNER_API_KEY: argilla.apikey | |
ADMIN_USERNAME: admin | |
ADMIN_API_KEY: admin.apikey | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup PDM | |
uses: pdm-project/setup-pdm@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: true | |
cache-dependency-path: | | |
argilla-sdk/pyproject.toml | |
- name: Install dependencies | |
run: | | |
pdm install | |
- name: Wait for argilla-quickstart to start | |
run: | | |
while ! curl -XGET http://localhost:6900/api/_status; do sleep 5; done | |
- name: Run unit tests | |
run: | | |
pdm run test tests/unit | |
- name: Run integration tests | |
run: | | |
pdm run test tests/integration | |
- name: Build package | |
run: | | |
pdm build | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
# Upload the package to be used in the next jobs only once | |
if: ${{ matrix.python-version == '3.8' }} | |
with: | |
name: argilla-sdk | |
path: argilla-sdk/dist | |
# This job will publish argilla-sdk package into PyPI repository | |
publish_release: | |
name: Publish Release | |
runs-on: ubuntu-latest | |
if: github.event_name == 'workflow_dispatch' | |
needs: | |
- build | |
permissions: | |
# This permission is needed for private repositories. | |
# contents: read | |
# IMPORTANT: this permission is mandatory for trusted publishing on PyPI | |
id-token: write | |
# This permission is needed for creating tags | |
contents: write | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- name: Checkout Code 🛎 | |
uses: actions/checkout@v4 | |
- name: Download python package | |
uses: actions/download-artifact@v4 | |
with: | |
name: argilla-sdk | |
path: argilla-sdk/dist | |
- name: Setup PDM | |
uses: pdm-project/setup-pdm@v4 | |
with: | |
cache: true | |
- name: Read package info | |
run: | | |
PACKAGE_VERSION=$(pdm show --version) | |
PACKAGE_NAME=$(pdm show --name) | |
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV | |
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV | |
echo "$PACKAGE_NAME==$PACKAGE_VERSION" | |
- name: Create tag | |
run: | | |
git config user.name "${{ github.actor }}" | |
git config user.email "${{ github.actor }}@users.noreply.github.com" | |
git tag -f -a v${{ env.PACKAGE_VERSION }} -m "Release v${{ env.PACKAGE_VERSION }}" | |
git push -f origin v${{ env.PACKAGE_VERSION }} | |
- name: Publish Package to PyPI test environment 🥪 | |
run: pdm publish --no-build --repository testpypi | |
continue-on-error: true | |
- name: Test Installing 🍿 | |
run: | | |
pip install --index-url https://test.pypi.org/simple --no-deps $PACKAGE_NAME==$PACKAGE_VERSION | |
- name: Publish Package to PyPI 🥩 | |
if: ${{ inputs.release == 'true' }} | |
run: pdm publish --no-build |