Python package release #12
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: Python package release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version to release' | |
required: true | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
cache: "pip" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install setuptools wheel twine | |
- name: Update __version__ in __init__.py | |
run: python .github/workflows/set_version.py ${{ github.event.inputs.version }} | |
- name: Configure Git | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
- name: Commit and push if changed | |
run: | | |
git diff | |
git diff --quiet || (git add . && git commit -m 'update __version__') | |
git push https://${{secrets.GITHUB_TOKEN}}@github.com/tatsu-lab/alpaca_eval.git HEAD:main | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push Tag | |
run: | | |
git pull --tags | |
git tag v${{ github.event.inputs.version }} | |
git push origin v${{ github.event.inputs.version }} | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: Release v${{ github.event.inputs.version }} | |
tag_name: v${{ github.event.inputs.version }} | |
draft: false | |
prerelease: false | |
repository: tatsu-lab/alpaca_eval | |
generate_release_notes: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and publish | |
env: | |
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
run: | | |
python3 -m pip install --upgrade build | |
python3 -m build | |
python3 -m pip install --upgrade twine | |
python3 -m twine upload dist/* |