Skip to content

Commit 1659c0e

Browse files
author
Val Brodsky
committed
Add a gitflow to publish lbox packages to pypi
1 parent 78cc779 commit 1659c0e

File tree

2 files changed

+165
-1
lines changed

2 files changed

+165
-1
lines changed

.github/workflows/lbox-publish.yml

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
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"

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
- name: Create build
4343
working-directory: libs/labelbox
4444
run: |
45-
rye sync -f --update-all
45+
rye sync
4646
rye build
4747
- name: "Generate hashes"
4848
id: hash

0 commit comments

Comments
 (0)