1+ name : LBox Publish
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ tag :
7+ description : ' Release Tag'
8+ required : true
9+
10+ concurrency :
11+ group : ${{ github.workflow }}-${{ github.ref }}
12+ cancel-in-progress : true
13+
14+ permissions :
15+ id-token : write
16+
17+ jobs :
18+ path-filter :
19+ runs-on : ubuntu-latest
20+ outputs :
21+ lbox : ${{ steps.filter.outputs.lbox }}
22+ test-matrix : ${{ steps.matrix.outputs.test-matrix }}
23+ package-matrix : ${{ steps.matrix.outputs.publish-matrix }}
24+ steps :
25+ - uses : actions/checkout@v4
26+ with :
27+ ref : ${{ github.head_ref }}
28+ - uses : dorny/paths-filter@v3
29+ id : filter
30+ with :
31+ list-files : ' json'
32+ filters : |
33+ lbox:
34+ - 'libs/lbox*/**'
35+ - id : matrix
36+ uses : ./.github/actions/lbox-matrix
37+ with :
38+ files-changed : ${{ steps.filter.outputs.lbox_files }}
39+ build :
40+ runs-on : ubuntu-latest
41+ needs : ['path-filter', 'test-build']
42+ strategy :
43+ fail-fast : false
44+ matrix :
45+ include : ${{ fromJSON(needs.path-filter.outputs.package-matrix) }}
46+ steps :
47+ - uses : actions/checkout@v4
48+ with :
49+ ref : ${{ inputs.tag }}
50+ - name : Install the latest version of rye
51+ uses : eifinger/setup-rye@v2
52+ with :
53+ version : ${{ vars.RYE_VERSION }}
54+ enable-cache : true
55+ - name : Rye Setup
56+ run : |
57+ rye config --set-bool behavior.use-uv=true
58+ - name : Create build
59+ working-directory : libs/${{ matrix.package }}
60+ run : |
61+ rye sync
62+ rye build
63+ - uses : actions/upload-artifact@v4
64+ with :
65+ name : build
66+ path : ./dist/${{ matrix.package }}
67+ test-build :
68+ needs : ['path-filter']
69+ if : ${{ needs.path-filter.outputs.lbox == 'true' }}
70+ runs-on : ubuntu-latest
71+ strategy :
72+ fail-fast : false
73+ matrix :
74+ include : ${{ fromJSON(needs.path-filter.outputs.test-matrix) }}
75+ concurrency :
76+ group : lbox-staging-${{ matrix.python-version }}-${{ matrix.package }}
77+ cancel-in-progress : false
78+ steps :
79+ - uses : actions/checkout@v4
80+ with :
81+ token : ${{ secrets.ACTIONS_ACCESS_TOKEN }}
82+ ref : ${{ inputs.tag }}
83+ - uses : ./.github/actions/python-package-shared-setup
84+ with :
85+ rye-version : ${{ vars.RYE_VERSION }}
86+ python-version : ${{ matrix.python-version }}
87+ - name : Format
88+ run : rye format --check -v -p ${{ matrix.package }}
89+ - name : Linting
90+ run : rye lint -v -p ${{ matrix.package }}
91+ - name : Unit
92+ working-directory : libs/${{ matrix.package }}
93+ run : rye run unit
94+ - name : Integration
95+ working-directory : libs/${{ matrix.package }}
96+ env :
97+ LABELBOX_TEST_API_KEY : ${{ secrets[matrix.api-key] }}
98+ DA_GCP_LABELBOX_API_KEY : ${{ secrets[matrix.da-test-key] }}
99+ LABELBOX_TEST_ENVIRON : ' staging'
100+ run : rye run integration
101+ pypi-publish :
102+ runs-on : ubuntu-latest
103+ needs : ['build', 'test-build', 'path-filter']
104+ strategy :
105+ fail-fast : false
106+ matrix :
107+ include : ${{ fromJSON(needs.path-filter.outputs.package-matrix) }}
108+ environment :
109+ name : PyPI-${{ matrix.package }}
110+ url : ' https://pypi.org/project/${{ matrix.package }}'
111+ permissions :
112+ # IMPORTANT: this permission is mandatory for trusted publishing
113+ id-token : write
114+ steps :
115+ - uses : actions/download-artifact@v4
116+ with :
117+ name : build
118+ path : ./artifact/{{ matrix.package }}
119+ - name : Publish package distributions to PyPI
120+ uses : pypa/gh-action-pypi-publish@release/v1
121+ with :
122+ packages-dir : artifact/
123+ container-publish :
124+ runs-on : ubuntu-latest
125+ needs : ['build', 'path-filter']
126+ if : ${{ needs.path-filter.outputs.lbox == 'true' }}
127+ strategy :
128+ fail-fast : false
129+ matrix :
130+ include : ${{ fromJSON(needs.path-filter.outputs.package-matrix) }}
131+ permissions :
132+ # IMPORTANT: this permission is mandatory for trusted publishing
133+ packages : write
134+ steps :
135+ - uses : actions/checkout@v4
136+ with :
137+ ref : ${{ inputs.tag }}
138+ - name : Set up Docker Buildx
139+ uses : docker/setup-buildx-action@v3
140+ - name : Log in to the Container registry
141+ uses : docker/login-action@v3
142+ with :
143+ registry : ghcr.io
144+ username : ${{ github.actor }}
145+ password : ${{ secrets.GITHUB_TOKEN }}
146+ - name : Build and push
147+ uses : docker/build-push-action@v5
148+ id : build_container
149+ with :
150+ context : .
151+ file : ./libs/${{ matrix.package }}/Dockerfile
152+ github-token : ${{ secrets.GITHUB_TOKEN }}
153+ push : true
154+ platforms : |
155+ linux/amd64
156+ linux/arm64
157+ tags : |
158+ ghcr.io/labelbox/${{ matrix.package }}:latest
159+ ghcr.io/labelbox/${{ matrix.package }}:${{ inputs.tag }}
160+ - name : Output image
161+ id : image
162+ run : |
163+ echo "ghcr.io/labelbox/${{ matrix.package }}:latest" >> "$GITHUB_STEP_SUMMARY"
164+ echo "ghcr.io/labelbox/${{ matrix.package }}:${{ github.sha }}" >> "$GITHUB_STEP_SUMMARY"
0 commit comments