poetry-publish-nightly #767
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: poetry-publish-nightly | |
on: | |
schedule: | |
- cron: '39 23 * * *' | |
workflow_dispatch: | |
jobs: | |
# nightly release check from https://stackoverflow.com/a/67527144 | |
check-date: | |
runs-on: ubuntu-latest | |
outputs: | |
should_run: ${{ steps.should_run.outputs.should_run }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: print latest_commit | |
run: echo ${{ github.sha }} | |
- id: should_run | |
continue-on-error: true | |
name: check latest commit is less than a day | |
if: ${{ github.event_name == 'schedule' }} | |
run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "::set-output name=should_run::false" | |
nightly-publish-test-pypi: | |
runs-on: ubuntu-latest | |
needs: check-date | |
if: ${{ needs.check_date.outputs.should_run != 'false' }} | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.8 | |
- name: Install Poetry | |
run: curl -sSL https://install.python-poetry.org | python3 - --version 1.5.1 | |
- name: Cache Poetry virtualenv | |
uses: actions/cache@v1 | |
id: cache | |
with: | |
path: ~/.virtualenvs | |
key: poetry-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('pyproject.toml') }} | |
restore-keys: | | |
poetry-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('pyproject.toml') }} | |
- name: Set Poetry config | |
run: | | |
poetry config virtualenvs.in-project false | |
poetry config virtualenvs.path ~/.virtualenvs | |
poetry config repositories.test-pypi https://test.pypi.org/legacy/ | |
poetry config pypi-token.test-pypi ${{ secrets.TEST_PYPI_API_TOKEN }} | |
- name: Install Dependencies | |
run: | | |
poetry install -E gateway -E solver -E aws -E azure -E gcp | |
poetry run pip install -r requirements-dev.txt | |
if: steps.cache.outputs.cache-hit != 'true' | |
- name: Build package | |
run: | | |
export RELEASEDATE=$(date +%Y%m%d) | |
echo "gateway_version = 'nightly-$RELEASEDATE'" > skyplane/gateway_version.py | |
sed -i 's/name = "skyplane"/name = "skyplane-nightly"/g' pyproject.toml | |
sed -i "s/version = \"\([0-9]\+\.[0-9]\+\.[0-9]\+\)\(.*\)\"/version = \"\1.dev$RELEASEDATE\"/" pyproject.toml | |
poetry build | |
- name: Archive poetry package (sdist and wheel) | |
uses: actions/upload-artifact@v3 | |
with: | |
name: skyplane-nightly | |
path: dist/ | |
- name: Publish package | |
run: poetry publish -r test-pypi | |
nightly-publish-pypi: | |
runs-on: ubuntu-latest | |
needs: [ check-date, nightly-publish-test-pypi ] | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.8 | |
- name: Install Poetry | |
run: curl -sSL https://install.python-poetry.org | python3 - --version 1.5.1 | |
- name: Cache Poetry virtualenv | |
uses: actions/cache@v1 | |
id: cache | |
with: | |
path: ~/.virtualenvs | |
key: poetry-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('pyproject.toml') }} | |
restore-keys: | | |
poetry-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('pyproject.toml') }} | |
- name: Set Poetry config | |
run: | | |
poetry config virtualenvs.in-project false | |
poetry config virtualenvs.path ~/.virtualenvs | |
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }} | |
- name: Install Dependencies | |
run: | | |
poetry install -E gateway -E solver -E aws -E azure -E gcp | |
poetry run pip install -r requirements-dev.txt | |
if: steps.cache.outputs.cache-hit != 'true' | |
- name: Build package under skyplane-dev name | |
run: | | |
export RELEASEDATE=$(date +%Y%m%d) | |
echo "gateway_version = 'nightly-$RELEASEDATE'" > skyplane/gateway_version.py | |
sed -i 's/name = "skyplane"/name = "skyplane-nightly"/g' pyproject.toml | |
sed -i "s/version = \"\([0-9]\+\.[0-9]\+\.[0-9]\+\)\(.*\)\"/version = \"\1.dev$RELEASEDATE\"/" pyproject.toml | |
poetry build | |
- name: Archive poetry package (sdist and wheel) | |
uses: actions/upload-artifact@v3 | |
with: | |
name: skyplane | |
path: dist/ | |
- name: Publish package | |
run: poetry publish |