-
Notifications
You must be signed in to change notification settings - Fork 61
176 lines (161 loc) · 5.46 KB
/
python-package-develop.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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 }}