Skip to content

Commit

Permalink
fix(nightly) Wait 30 min before building nightly images (#3294)
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Steiner <robert@flower.ai>
  • Loading branch information
Robert-Steiner authored and mohammadnaseri committed May 2, 2024
1 parent 3e1b90e commit 4235708
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
30 changes: 14 additions & 16 deletions .github/workflows/release-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Release nightly
on:
schedule:
- cron: "0 23 * * *"
- cron: "30 23 * * *"

env:
FLWR_TELEMETRY_ENABLED: 0
Expand All @@ -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:
Expand Down
8 changes: 6 additions & 2 deletions dev/publish-nightly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4235708

Please sign in to comment.