Skip to content

[PLT-2228] Move to task queue task id to be optional with default as … #1943

[PLT-2228] Move to task queue task id to be optional with default as …

[PLT-2228] Move to task queue task id to be optional with default as … #1943

name: Labelbox Python SDK Staging (Develop)
on:
push:
branches: [develop]
pull_request:
branches: [develop]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
id-token: write
jobs:
path-filter:
runs-on: ubuntu-latest
outputs:
labelbox: ${{ steps.filter.outputs.labelbox }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
labelbox:
- 'libs/labelbox/**'
get_sdk_versions:
runs-on: ubuntu-latest
outputs:
sdk_versions: ${{ steps.get_sdk_versions.outputs.sdk_versions }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: ${{ github.event.repository.default_branch }}
- name: Fetch tags
run: git fetch --tags
- name: Get Latest SDK versions
id: get_sdk_versions
run: |
sdk_versions=$(git tag --list --sort=-version:refname "v.*" | head -n 3 | jq -R -s -c 'split("\n")[:-1]')
if [ -z "$sdk_versions" ]; then
echo "No tags found"
exit 1
fi
echo "sdk_versions=$sdk_versions"
echo "sdk_versions=$sdk_versions" >> $GITHUB_OUTPUT
build:
needs: ['path-filter', 'get_sdk_versions']
if: ${{ needs.path-filter.outputs.labelbox == 'true' }}
strategy:
fail-fast: false
matrix:
include:
- python-version: 3.9
api-key: STAGING_LABELBOX_API_KEY_3
da-test-key: DA_GCP_LABELBOX_API_KEY
sdk-version: ${{ fromJson(needs.get_sdk_versions.outputs.sdk_versions)[2] }}
- python-version: "3.10"
api-key: STAGING_LABELBOX_API_KEY_4
da-test-key: DA_GCP_LABELBOX_API_KEY
sdk-version: ${{ fromJson(needs.get_sdk_versions.outputs.sdk_versions)[1] }}
- python-version: 3.11
api-key: STAGING_LABELBOX_API_KEY
da-test-key: DA_GCP_LABELBOX_API_KEY
sdk-version: ${{ fromJson(needs.get_sdk_versions.outputs.sdk_versions)[0] }}
- python-version: 3.12
api-key: STAGING_LABELBOX_API_KEY_5
da-test-key: DA_GCP_LABELBOX_API_KEY
uses: ./.github/workflows/python-package-shared.yml
with:
python-version: ${{ matrix.python-version }}
api-key: ${{ matrix.api-key }}
da-test-key: ${{ matrix.da-test-key }}
sdk-version: ${{ matrix.sdk-version }}
fixture-profile: true
test-env: 'staging'
secrets: inherit
test-pypi:
runs-on: ubuntu-latest
needs: ['path-filter']
continue-on-error: true
environment:
name: Test-PyPI
url: 'https://test.pypi.org/p/labelbox-test'
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- uses: ./.github/actions/python-package-shared-setup
with:
rye-version: ${{ vars.RYE_VERSION }}
python-version: '3.9'
- name: Create build
id: create-build
working-directory: libs/labelbox
run: |
VERSION=$(date +"%Y.%m.%d.%H.%M")
echo "pip install --index-url https://test.pypi.org/simple/ --extra-index-url=https://pypi.org/simple/ labelbox-test@$VERSION" >> "$GITHUB_STEP_SUMMARY"
rye version "$VERSION"
rye run toml set --toml-path pyproject.toml project.name labelbox-test
rye build
- name: Publish package distributions to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
repository-url: https://test.pypi.org/legacy/
test-container:
runs-on: ubuntu-latest
needs: ['path-filter']
continue-on-error: true
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
packages: write
env:
CONTAINER_IMAGE: "ghcr.io/${{ github.repository }}"
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: downcase CONTAINER_IMAGE
run: |
echo "CONTAINER_IMAGE=${CONTAINER_IMAGE,,}" >> ${GITHUB_ENV}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push (Develop)
if: github.event_name == 'push'
uses: docker/build-push-action@v5
with:
context: .
file: ./libs/labelbox/Dockerfile
github-token: ${{ secrets.GITHUB_TOKEN }}
push: true
platforms: |
linux/amd64
linux/arm64
tags: |
${{ env.CONTAINER_IMAGE }}:develop
${{ env.CONTAINER_IMAGE }}:${{ github.sha }}
- name: Build and push (Pull Request)
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v5
with:
context: .
file: ./libs/labelbox/Dockerfile
github-token: ${{ secrets.GITHUB_TOKEN }}
push: true
platforms: |
linux/amd64
linux/arm64
tags: |
${{ env.CONTAINER_IMAGE }}:${{ github.sha }}