Publish botocore-stubs #22789
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish botocore-stubs | |
concurrency: publish | |
on: | |
schedule: | |
- cron: "0 * * * *" | |
workflow_dispatch: | |
inputs: | |
force: | |
required: false | |
default: false | |
type: boolean | |
description: Force build even if stubs are published | |
version: | |
required: false | |
default: "" | |
type: string | |
description: Use a specific package version, latest otherwise | |
env: | |
PACKAGE: botocore | |
STUBS: botocore-stubs | |
jobs: | |
check-version: | |
name: Check version | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version.outputs.result }} | |
stubs-version: ${{ steps.stubs-version.outputs.result }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Extract version | |
id: version | |
uses: actions/github-script@v7 | |
with: | |
result-encoding: string | |
script: | | |
const { setupGlobals, extractVersions, getLatestVersion } = require('./.github/workflows/helpers.js') | |
setupGlobals({ fetch, core, context }) | |
const package = process.env.PACKAGE | |
const inputVersion = context.payload.inputs?.version | |
const version = inputVersion ? inputVersion : await getLatestVersion(package) | |
core.notice(`${package} version = ${version}`) | |
return version | |
- name: Extract stubs version | |
id: stubs-version | |
uses: actions/github-script@v7 | |
with: | |
result-encoding: string | |
script: | | |
const { setupGlobals, isStableVersionGreater, getLatestStubsVersion, getLatestVersion, getNextVersion } = require('./.github/workflows/helpers.js') | |
setupGlobals({ fetch, core, context }) | |
const stubsPackage = process.env.STUBS | |
const force = context.payload.inputs ? context.payload.inputs.force !== 'false' : false | |
const version = "${{ steps.version.outputs.result }}" | |
if (force) { | |
core.notice('Force release, skipping version check') | |
} | |
const stubsVersion = await getLatestStubsVersion(stubsPackage, version) | |
core.notice(`${stubsPackage} latest version = ${stubsVersion}`) | |
const buildStubsVersion = stubsVersion ? getNextVersion(stubsVersion) : version | |
const isStubsVersionGreater = stubsVersion === null || isStableVersionGreater(buildStubsVersion, stubsVersion) | |
if (!isStubsVersionGreater && !force) { | |
core.notice('Stubs version is not greater than the latest, skipping run') | |
return '' | |
} | |
core.notice(`${stubsPackage} build version = ${buildStubsVersion}`) | |
return buildStubsVersion | |
publish-stubs: | |
name: Publish stubs | |
runs-on: ubuntu-latest | |
needs: check-version | |
if: needs.check-version.outputs.stubs-version | |
env: | |
VERSION: ${{ needs.check-version.outputs.version }} | |
STUBS_VERSION: ${{ needs.check-version.outputs.stubs-version }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Install dependencies | |
run: | | |
python -m pip install -U poetry pip | |
poetry install -n | |
poetry run pip install -U twine | |
- name: Install package | |
run: | | |
poetry run pip install ${PACKAGE}==${VERSION} | |
- name: Stubs consistency check | |
if: "${{ github.event.inputs.force != 'true' }}" | |
run: | | |
poetry run istub -d | |
- name: Bump version | |
run: | | |
echo "Bumping version to ${STUBS_VERSION}" | |
poetry version ${STUBS_VERSION} | |
rm -rf *.egg-info || true | |
poetry install -n | |
- name: Commit changes | |
if: "${{ github.event.inputs.version == '' }}" | |
run: | | |
git config --global user.email "github-actions@github.com" | |
git config --global user.name "github-actions" | |
git add pyproject.toml | |
git commit -m "Release ${STUBS_VERSION}" | |
git push | |
- name: Publish to PyPI | |
env: | |
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
run: | | |
poetry build | |
poetry run twine upload --non-interactive dist/* | |
- name: Report status | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
core.notice(`Released ${process.env.STUBS} ${process.env.STUBS_VERSION}`) |