Nightly Binary Build and Publish #20
This file contains hidden or 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: Nightly Binary Build and Publish | |
| permissions: | |
| contents: read | |
| on: | |
| schedule: | |
| - cron: '0 18 * * *' # UTC 18:00, Beijing 02:00 | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to publish (e.g. 0.9.5.dev20260101)' | |
| required: false | |
| type: string | |
| test_pypi: | |
| default: true | |
| description: 'Publish to TestPyPI, for test only' | |
| required: false | |
| type: boolean | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.12' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip setuptools wheel twine | |
| - name: Set nightly version | |
| id: set_version | |
| run: | | |
| base_version=$(grep "__version__" auto_round/version.py | cut -d= -f2 | tr -d ' "') | |
| if [ -z "${{ github.event.inputs.version }}" ]; then | |
| VERSION="${base_version}.dev$(date -u +%Y%m%d)" | |
| else | |
| VERSION="${{ github.event.inputs.version }}" | |
| fi | |
| # Update version in setup.py (assumes version is set as version='...') | |
| sed -i "s/version=get_build_version()/version='$VERSION'/" setup.py | |
| # Update project name in setup.py (assumes name='...') | |
| sed -i "s/name=package_name/name='auto-round-nightly'/" setup.py | |
| - name: Build binary | |
| run: | | |
| python setup.py sdist bdist_wheel | |
| - name: Publish to PyPI or TestPyPI | |
| env: | |
| TWINE_USERNAME: "__token__" | |
| PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
| TESTPYPI_PASSWORD: ${{ secrets.TESTPYPI_PASSWORD }} | |
| run: | | |
| if [[ "${{ github.event.inputs.test_pypi }}" == "true" ]]; then | |
| export TWINE_PASSWORD=${TESTPYPI_PASSWORD} | |
| twine upload --repository testpypi dist/* | |
| else | |
| export TWINE_PASSWORD=${PYPI_PASSWORD} | |
| twine upload --repository pypi dist/* | |
| fi | |