233 lines (213 loc) · 8.26 KB
/
publish_boto3_stubs.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
name: Publish boto3-stubs
concurrency: update_boto3_stubs
on:
schedule:
- cron: "*/15 * * * *"
workflow_dispatch:
inputs:
boto3_version:
description: Target boto3 version
required: false
default: ""
type: string
stubs_version:
description: Specify version explicitly instead of finding it automatically
required: false
default: ""
type: string
force:
description: Continue if version is already published
required: false
default: false
type: boolean
build_all:
description: Build all packages instead of updated only
required: false
default: false
type: boolean
skip_published:
description: Skip already published packages
required: false
default: true
type: boolean
no_smart_version:
description: Use exact version provided in stubs_version
required: false
default: false
type: boolean
jobs:
versions:
runs-on: ubuntu-latest
outputs:
boto3: ${{ steps.boto3.outputs.result }}
botocore: ${{ steps.botocore.outputs.result }}
boto3-url: ${{ steps.boto3-url.outputs.result }}
botocore-url: ${{ steps.botocore-url.outputs.result }}
version: ${{ steps.version.outputs.result }}
build-all: ${{ steps.build-all.outputs.result }}
extra-flags: ${{ steps.extra-flags.outputs.result }}
steps:
- uses: actions/checkout@v4
- name: Find boto3 version
id: boto3
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const { getBoto3Version, setupGlobals } = require('./.github/workflows/helpers.js')
setupGlobals({ core, context, fetch })
const inputVersion = context.payload.inputs && context.payload.inputs.boto3_version
const version = inputVersion ? inputVersion : await getBoto3Version()
core.notice(`boto3 version ${version}`)
return version
- name: Find botocore version
id: botocore
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const { getBotocoreVersion, setupGlobals } = require('./.github/workflows/helpers.js')
setupGlobals({ core, context, fetch })
const version = getBotocoreVersion("${{ steps.boto3.outputs.result }}")
core.notice(`botocore version ${version}`)
return version
- name: Find build version
id: version
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const { getStubsVersions, getNextPostVersion, setupGlobals } = require('./.github/workflows/helpers.js')
setupGlobals({ core, context, fetch })
if (context.payload.inputs && context.payload.inputs.stubs_version) {
const version = context.payload.inputs.stubs_version
core.notice(`stubs version ${version}`)
return version
}
const force = context.payload.inputs ? context.payload.inputs.force !== 'false' : false
const boto3Version = "${{ steps.boto3.outputs.result }}"
const versions = await getStubsVersions(boto3Version)
core.info(`Built versions ${versions}`)
if (!versions.length) {
core.notice(`No builds found, building initial ${boto3Version}`)
return boto3Version
}
if (!force) {
core.notice(`Builds ${versions} found, skipping`)
return ''
}
const lastVersion = versions.pop()
core.notice(`Last version ${lastVersion}`)
const version = getNextPostVersion(lastVersion)
core.notice(`Version ${version}`)
return version
- name: Build all
id: build-all
if: steps.version.outputs.result
uses: actions/github-script@v7
with:
result-encoding: string
script: |
if (context.payload.inputs && context.payload.inputs.build_all !== 'false') {
core.notice('Build all = true')
return 'true'
}
const boto3Version = "${{ steps.boto3.outputs.result }}"
if (boto3Version.endsWith('.0')) {
core.notice('Build all = true (due to minor version update)')
return 'true'
}
core.notice('Build all = false')
return 'false'
- name: Extra flags
id: extra-flags
if: steps.version.outputs.result
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const extraFlags = []
const skipPublished = context.payload.inputs ? context.payload.inputs.skip_published !== 'false' : true
const noSmartVersion = context.payload.inputs ? context.payload.inputs.no_smart_version !== 'false' : true
if (skipPublished) extraFlags.push('--skip-published')
if (noSmartVersion) extraFlags.push('--no-smart-version')
core.notice(`Extra flags = ${extraFlags}`)
return extraFlags.join(' ')
- name: Boto3 download URL
id: boto3-url
if: steps.version.outputs.result
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const { getDownloadURL, setupGlobals } = require('./.github/workflows/helpers.js')
setupGlobals({ core, context, fetch })
const url = await getDownloadURL('boto3', "${{ steps.boto3.outputs.result }}")
core.notice(`boto3 download URL ${url}`)
return url
- name: Botocore download URL
id: botocore-url
if: steps.version.outputs.result
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const { getDownloadURL, setupGlobals } = require('./.github/workflows/helpers.js')
setupGlobals({ core, context, fetch })
const url = await getDownloadURL('botocore', "${{ steps.botocore.outputs.result }}")
core.notice(`botocore download URL ${url}`)
return url
publish-boto3-stubs:
name: Publish boto3-stubs
runs-on: ubuntu-latest
needs: versions
if: needs.versions.outputs.version
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml
- name: Install boto3
run: |
mkdir installtemp
cd installtemp
wget ${{ needs.versions.outputs.boto3-url }}
wget ${{ needs.versions.outputs.botocore-url }}
pip uninstall -y s3transfer
pip install botocore*.whl
pip install boto3*.whl
cd ..
rm -rf installtemp
python -m pip install newversion
- name: Install builder
run: |
rm -rf mypy_boto3_builder
python -m pip install mypy_boto3_builder
- name: Build updated packages only
if: needs.versions.outputs.build-all == 'false'
env:
VERSION: ${{ needs.versions.outputs.version }}
EXTRA_FLAGS: ${{ needs.versions.outputs.extra-flags }}
run: |
rm -rf mypy_boto3_output/*
echo "Building updated packages"
python -m mypy_boto3_builder mypy_boto3_output -b ${VERSION} --product boto3 boto3-services ${EXTRA_FLAGS} -s updated -d
- name: Build all packages
if: needs.versions.outputs.build-all == 'true'
env:
VERSION: ${{ needs.versions.outputs.version }}
EXTRA_FLAGS: ${{ needs.versions.outputs.extra-flags }}
run: |
rm -rf mypy_boto3_output/*
echo "Building all packages"
python -m mypy_boto3_builder mypy_boto3_output -b ${VERSION} --product boto3 boto3-services ${EXTRA_FLAGS} -s all -d
- name: Install dependencies for publishing
run: |
python -m pip install setuptools wheel twine
- name: Publish to PyPI
env:
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python ./scripts/release.py