release: 0.20.0 (#384) #362
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: release | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
paths: | |
- .github/workflows/release.yaml | |
branches: ["**"] | |
workflow_dispatch: | |
inputs: | |
publish_s3: | |
description: "Whether publish to S3" | |
type: boolean | |
default: true | |
publish_pypi: | |
description: "Whether publish to PyPI" | |
type: boolean | |
default: false | |
is_release: | |
description: "Is this a release package" | |
type: boolean | |
default: false | |
run_e2e: | |
description: "Whether run end to end testing" | |
type: boolean | |
default: false | |
jobs: | |
build-package: | |
runs-on: self-hosted | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python Environment | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Set up pip | |
run: | | |
pip install -U pip setuptools | |
- name: Build Package | |
id: build-package | |
run: | | |
pip wheel --no-deps . | |
- name: Upload to Github Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: whl-package | |
path: leptonai*.whl | |
test-package: | |
needs: build-package | |
runs-on: self-hosted | |
strategy: | |
matrix: | |
python_version: ["3.8", "3.10"] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python Environment | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "${{ matrix.python_version }}" | |
- name: Set up pip | |
run: | | |
pip install -U pip setuptools | |
- uses: actions/download-artifact@v3 | |
with: | |
name: whl-package | |
- name: Install Package | |
run: | | |
pip install leptonai*.whl | |
- name: Run Basic Tests | |
run: | | |
echo "leptonai package version:" | |
lep -v | |
lep ph create -n gpt2 -m hf:gpt2 | |
cd .. | |
echo "leptonai package path:" | |
python -c "import leptonai; print(leptonai)" | |
cd - | |
- name: Run Runtime Tests | |
run: | | |
whl_file=(leptonai*.whl) | |
pip install ${whl_file}[runtime] ${whl_file}[test] | |
cd .. | |
echo "Run unittests" | |
pytest -x leptonai | |
cd - | |
- name: Run End-To-End Tests | |
if: inputs.run_e2e | |
env: | |
LEPTON_RELEASE_CREDENTIALS: ${{ secrets.LEPTON_STAGING_WORKSPACE_CREDENTIALS }} | |
run: bash release_scripts/e2e_sdk_cli_test.sh | |
publish-s3: | |
if: github.event_name == 'push' || inputs.publish_s3 | |
needs: test-package | |
runs-on: self-hosted | |
steps: | |
- name: Set up Python Environment | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Set up pip | |
run: | | |
pip install -U pip setuptools | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ vars.AWS_REGION }} | |
- name: Install awscli | |
run: | | |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" | |
unzip awscliv2.zip | |
sudo ./aws/install | |
- uses: actions/download-artifact@v3 | |
with: | |
name: whl-package | |
- name: Upload package to S3 | |
run: | | |
s3_url="s3://lepton-sdk" | |
echo "github.event_name = ${{ github.event_name }}" | |
echo "inputs.is_release = ${{ inputs.is_release }}" | |
if [ "${{ github.event_name }}" == 'workflow_dispatch' ] && [ "${{ inputs.is_release }}" == 'true' ]; then | |
s3_url="${s3_url}/release" | |
fi | |
echo "s3_url=${s3_url}" | |
aws s3 cp leptonai*.whl "${s3_url}/" | |
publish-pypi: | |
if: inputs.publish_pypi | |
needs: test-package | |
runs-on: self-hosted | |
steps: | |
- name: Set up Python Environment | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Set up pip | |
run: | | |
pip install -U pip setuptools | |
- name: Install twine | |
run: | | |
pip install twine | |
- uses: actions/download-artifact@v3 | |
with: | |
name: whl-package | |
- name: Upload Package to PyPI | |
run: | | |
twine upload --verbose --username "${{ secrets.PYPI_UPLOAD_USERNAME }}" --password "${{ secrets.PYPI_UPLOAD_PASSWORD }}" leptonai*.whl |