-
Notifications
You must be signed in to change notification settings - Fork 71
189 lines (184 loc) · 6.08 KB
/
lbox-publish.yml
File metadata and controls
189 lines (184 loc) · 6.08 KB
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
177
178
179
180
181
182
183
184
185
186
187
188
189
name: LBox Publish
on:
workflow_dispatch:
inputs:
tag:
description: 'Release Tag'
required: true
prev_sdk_tag:
description: 'Prev SDK Release Tag, used to determine which lbox files have changed'
required: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
id-token: write
jobs:
path-filter:
runs-on: ubuntu-latest
outputs:
lbox: ${{ steps.filter.outputs.lbox }}
test-matrix: ${{ steps.matrix.outputs.test-matrix }}
package-matrix: ${{ steps.matrix.outputs.publish-matrix }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag }}
- uses: dorny/paths-filter@v3
id: filter
with:
base: ${{ inputs.prev_sdk_tag }}
list-files: 'json'
filters: |
lbox:
- 'libs/lbox-!(example)/**'
- id: matrix
uses: ./.github/actions/lbox-matrix
with:
files-changed: ${{ steps.filter.outputs.lbox_files }}
build:
runs-on: ubuntu-latest
needs: ['path-filter', 'test-build']
outputs:
hashes: ${{ steps.hash.outputs.hashes_lbox-clients }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.path-filter.outputs.package-matrix) }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag }}
- name: Install the latest version of rye
uses: eifinger/setup-rye@v2
with:
version: ${{ vars.RYE_VERSION }}
enable-cache: true
- name: Rye Setup
run: |
rye config --set-bool behavior.use-uv=true
- name: Create build
working-directory: libs/${{ matrix.package }}
run: |
rye sync
rye build
- name: "Generate hashes"
id: hash
run: |
cd dist && echo "hashes_${{ matrix.package }}=$(sha256sum * | base64 -w0)" >> $GITHUB_OUTPUT
echo "hashes_${{ matrix.package }}=$(sha256sum * | base64 -w0)"
- uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.package }}
path: ./dist
provenance_python:
needs: [build]
permissions:
actions: read
contents: write
id-token: write # Needed to access the workflow's OIDC identity.
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.0.0
with:
base64-subjects: "${{ needs.build.outputs.hashes }}"
upload-assets: true
upload-tag-name: ${{ inputs.tag }} # Tag from the initiation of the workflow
provenance-name: lbox-clients.intoto.jsonl
test-build:
needs: ['path-filter']
if: ${{ needs.path-filter.outputs.lbox == 'true' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.path-filter.outputs.test-matrix) }}
concurrency:
group: lbox-staging-${{ matrix.python-version }}-${{ matrix.package }}
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag }}
- uses: ./.github/actions/python-package-shared-setup
with:
rye-version: ${{ vars.RYE_VERSION }}
python-version: ${{ matrix.python-version }}
- name: Format
run: rye format --check -v -p ${{ matrix.package }}
- name: Linting
run: rye lint -v -p ${{ matrix.package }}
- name: Unit
working-directory: libs/${{ matrix.package }}
run: rye run unit
- name: Integration
working-directory: libs/${{ matrix.package }}
env:
LABELBOX_TEST_API_KEY: ${{ secrets[matrix.api-key] }}
DA_GCP_LABELBOX_API_KEY: ${{ secrets[matrix.da-test-key] }}
LABELBOX_TEST_ENVIRON: 'staging'
run: rye run integration
pypi-publish:
runs-on: ubuntu-latest
needs: ['build', 'test-build', 'path-filter']
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.path-filter.outputs.package-matrix) }}
environment:
name: publish-${{ matrix.package }}
url: 'https://pypi.org/project/${{ matrix.package }}'
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: build-${{ matrix.package }}
path: ./artifact
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: artifact/
verbose: true
container-publish:
runs-on: ubuntu-latest
needs: ['build', 'path-filter']
if: ${{ needs.path-filter.outputs.lbox == 'true' }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.path-filter.outputs.package-matrix) }}
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
packages: write
steps:
- uses: actions/checkout@v4
with:
# ref: ${{ inputs.tag }}
ref: ${{ inputs.tag }}
- 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
uses: docker/build-push-action@v5
id: build_container
with:
context: .
file: ./libs/${{ matrix.package }}/Dockerfile
github-token: ${{ secrets.GITHUB_TOKEN }}
push: true
platforms: |
linux/amd64
linux/arm64
tags: |
ghcr.io/labelbox/${{ matrix.package }}:latest
ghcr.io/labelbox/${{ matrix.package }}:${{ inputs.tag }}
- name: Output image
id: image
run: |
echo "ghcr.io/labelbox/${{ matrix.package }}:latest" >> "$GITHUB_STEP_SUMMARY"
echo "ghcr.io/labelbox/${{ matrix.package }}:${{ inputs.tag }}" >> "$GITHUB_STEP_SUMMARY"