From 92185c9d9e65c8c6b708b91ea22c2b9e30c5d459 Mon Sep 17 00:00:00 2001 From: Robert Steiner Date: Tue, 23 Apr 2024 13:29:17 +0200 Subject: [PATCH] fix(nightly) Wait 30 min before building nightly images (#3294) Signed-off-by: Robert Steiner --- .github/workflows/release-nightly.yml | 30 +++++++++++++-------------- dev/publish-nightly.sh | 8 +++++-- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release-nightly.yml b/.github/workflows/release-nightly.yml index f30f0137324..f5b7bdf20a7 100644 --- a/.github/workflows/release-nightly.yml +++ b/.github/workflows/release-nightly.yml @@ -3,6 +3,7 @@ name: Release nightly on: schedule: - cron: "0 23 * * *" + - cron: "30 23 * * *" env: FLWR_TELEMETRY_ENABLED: 0 @@ -15,36 +16,33 @@ jobs: outputs: name: ${{ steps.release.outputs.name }} version: ${{ steps.release.outputs.version }} + skip: ${{ steps.release.outputs.skip }} steps: - uses: actions/checkout@v4 - name: Bootstrap uses: ./.github/actions/bootstrap - name: Release nightly - id: release + if: github.event.schedule == '0 23 * * *' env: PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} + run: ./dev/publish-nightly.sh + - name: Read nightly version and name + if: github.event.schedule == '30 23 * * *' + id: release run: | - ./dev/publish-nightly.sh + RESULT=$(./dev/publish-nightly.sh --skip-publish) + if [ "$RESULT" == "There were no commits in the last 24 hours." ]; then + echo "skip=true" >> $GITHUB_OUTPUT + fi + echo "name=$(poetry version | awk {'print $1'})" >> $GITHUB_OUTPUT echo "version=$(poetry version -s)" >> $GITHUB_OUTPUT - wait-on-pypi: - runs-on: ubuntu-22.04 - timeout-minutes: 5 - name: Wait on PyPI - needs: release-nightly - steps: - - uses: actions/checkout@v4 - - name: Bootstrap - uses: ./.github/actions/bootstrap - - name: Wait until flwr package is avaiale on PyPI - run: until pip install ${{ needs.release-nightly.outputs.name }}==${{ needs.release-nightly.outputs.version }} --dry-run; do echo "Try again"; sleep 10; done - build-docker-images: name: Build nightly images - if: github.repository == 'adap/flower' + if: github.repository == 'adap/flower' && needs.release-nightly.outputs.skip != 'true' && github.event.schedule == '30 23 * * *' uses: ./.github/workflows/_docker-build.yml - needs: [release-nightly, wait-on-pypi] + needs: release-nightly strategy: fail-fast: false matrix: diff --git a/dev/publish-nightly.sh b/dev/publish-nightly.sh index 0c03cdda9f4..a42af1f17cf 100755 --- a/dev/publish-nightly.sh +++ b/dev/publish-nightly.sh @@ -24,12 +24,16 @@ cd "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/../ # The version name in the pyproject.toml will be appended with "-dev" and the current date. # The result will be a release on PyPi of the package "flwr-nightly" of version e.g. # "0.1.1.dev20200716" as seen at https://pypi.org/project/flwr-nightly/ +# If the script is called with the flag `--skip-publish`, the name and version are changed +# in the pyproject.toml but the package won't be published. if [[ $(git log --since="24 hours ago" --pretty=oneline) ]]; then sed -i -E "s/^name = \"(.+)\"/name = \"\1-nightly\"/" pyproject.toml sed -i -E "s/^version = \"(.+)\"/version = \"\1.dev$(date '+%Y%m%d')\"/" pyproject.toml - python -m poetry build - python -m poetry publish -u __token__ -p $PYPI_TOKEN + if [ "$1" != "--skip-publish" ]; then + python -m poetry build + python -m poetry publish -u __token__ -p $PYPI_TOKEN + fi else echo "There were no commits in the last 24 hours." fi