thousandeyes-sdk-python/.github/workflows/release.yaml
Kevin Han 175a631c72
Some checks failed
Python CI / build (push) Has been cancelled
feature: Support new release workflow (#94)
* refacotr to the manual release workflow

* add tag after all of the python package published

* simplify input var reference

* add type to input var

* add type to input var

* add type to input var
2025-03-20 10:37:30 +00:00

72 lines
2.2 KiB
YAML

name: Release
on:
workflow_dispatch:
inputs:
releaseVersion:
description: 'The target version you want to update and release'
required: true
type: string
jobs:
set-package-matrix:
# This action returns all sub-packages to be published.
# It thens exports the variable to `matrix`, so that the deployment job is run individually for each sub-package
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.packages.outputs.packages }}
steps:
- uses: actions/checkout@v4
- id: packages
run: |
FOLDERS_JSON=$(find . -maxdepth 1 -type d -name "thousandeyes-sdk-*" | cut -c 3- | jq -R -s -c 'split("\n")[:-1]')
echo "packages=$FOLDERS_JSON" >> "$GITHUB_OUTPUT"
deployment:
needs: set-package-matrix
strategy:
matrix:
package-name: ${{ fromJSON(needs.set-package-matrix.outputs.packages) }}
runs-on: ubuntu-latest
permissions:
id-token: write
environment:
name: release
url: https://pypi.org/p/${{ matrix.package-name }}
steps:
- uses: actions/checkout@v4
with:
ref: main
python-version: '3.11'
token: ${{ secrets.CHECKOUT_PAT }}
- name: Set up Python
uses: actions/setup-python@v5
with:
cache: pip
cache-dependency-path: '**/pyproject.toml'
- name: Install dependencies
run: |
pip install setuptools wheel build
- name: Build
run: |
echo ${{ inputs.releaseVersion }} >> ${{ matrix.package-name }}/.version
cp LICENSE NOTICE ${{ matrix.package-name }}/
python -m build ${{ matrix.package-name }} --outdir dist/
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
add-tag:
runs-on: ubuntu-latest
needs: deployment
steps:
- name: Checkout latest code
uses: actions/checkout@v4
- name: Add tag and push to the repository
run: |
git config user.name "API Team"
git config user.email "api-team@thousandeyes.com"
git tag ${{ inputs.releaseVersion }}
git push origin ${{ inputs.releaseVersion }}