diff --git a/.github/workflows/cd-syft.yml b/.github/workflows/cd-syft.yml index c66d32c1724..04d4ca08447 100644 --- a/.github/workflows/cd-syft.yml +++ b/.github/workflows/cd-syft.yml @@ -2,14 +2,18 @@ name: CD - Syft on: schedule: - - cron: "00 12 * * */7" # At 12:00 UTC on every seven days + - cron: "0 12 * * 0" # At 12:00 UTC on every Sunday workflow_dispatch: inputs: skip_tests: - description: "If true, skip tests" + description: "If true, skip pre-release tests" required: false default: "false" + type: choice + options: + - false + - true release_platform: description: "Release Platform" @@ -22,22 +26,56 @@ on: - REAL_AND_TEST_PYPI jobs: + release-checks: + if: github.repository == 'OpenMined/PySyft' # don't run on forks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + # The steps ensure that the cron job is able to run only for + # for beta releases and not for stable releases + # For stable release, we always have to manually run the workflow + - name: Check if the release is a beta release + run: | + if [[ $(python packages/grid/VERSION) != *"beta"* && ${{github.event_name}} == 'schedule' ]]; then + echo "Cron Job could only be run for beta releases" + exit 1 + fi + + # Print the github user triggering the workflow + - name: Github User triggering the workflow + run: | + echo "Github User: ${{ github.actor }}" + call-pr-tests-linting: - if: github.repository == 'OpenMined/PySyft' && (github.event.inputs.skip_tests == 'false' || github.event_name == 'schedule') # don't run on forks + needs: [release-checks] + if: github.repository == 'OpenMined/PySyft' && needs.release-checks.result == 'success' && (github.event.inputs.skip_tests == 'false' || github.event_name == 'schedule') # don't run on forks uses: OpenMined/PySyft/.github/workflows/pr-tests-linting.yml@dev call-pr-tests-syft: - if: github.repository == 'OpenMined/PySyft' && (github.event.inputs.skip_tests == 'false' || github.event_name == 'schedule') # don't run on forks + needs: [release-checks] + if: github.repository == 'OpenMined/PySyft' && needs.release-checks.result == 'success' && (github.event.inputs.skip_tests == 'false' || github.event_name == 'schedule') # don't run on forks uses: OpenMined/PySyft/.github/workflows/pr-tests-syft.yml@dev call-pr-tests-stack: - if: github.repository == 'OpenMined/PySyft' && (github.event.inputs.skip_tests == 'false' || github.event_name == 'schedule') # don't run on forks + needs: [release-checks] + if: github.repository == 'OpenMined/PySyft' && needs.release-checks.result == 'success' && (github.event.inputs.skip_tests == 'false' || github.event_name == 'schedule') # don't run on forks uses: OpenMined/PySyft/.github/workflows/pr-tests-stack.yml@dev secrets: inherit build-and-push-docker-images: - needs: [call-pr-tests-linting, call-pr-tests-syft, call-pr-tests-stack] - if: always() && (needs.call-pr-tests-linting.result == 'success' && needs.call-pr-tests-syft.result == 'success' && needs.call-pr-tests-stack.result == 'success' || github.event.inputs.skip_tests == 'true') + needs: + [ + call-pr-tests-linting, + call-pr-tests-syft, + call-pr-tests-stack, + release-checks, + ] + if: always() && needs.release-checks.result == 'success' && (needs.call-pr-tests-linting.result == 'success' && needs.call-pr-tests-syft.result == 'success' && needs.call-pr-tests-stack.result == 'success' || github.event.inputs.skip_tests == 'true') strategy: matrix: @@ -87,15 +125,6 @@ jobs: python -m pip install --upgrade pip pip install --upgrade bump2version tox - - name: Bump the Version - id: bump-version - run: | - ls **/VERSION | xargs -I {} python {} - cat packages/grid/devspace.yaml | grep '0\.' - bump2version prenum --allow-dirty --no-commit - ls **/VERSION | xargs -I {} python {} - cat packages/grid/devspace.yaml | grep '0\.' - - name: Generate Release Metadata id: release_metadata run: | @@ -114,6 +143,16 @@ jobs: echo "grid_version=$(python packages/grid/VERSION)" >> $GITHUB_OUTPUT echo "seaweedfs_version=$(grep 'SEAWEEDFS_VERSION' packages/grid/default.env | cut -d '=' -f2)" >> $GITHUB_OUTPUT + - name: Bump the Version + id: bump-version + if: steps.release_metadata.outputs.release_tag == 'beta' + run: | + ls **/VERSION | xargs -I {} python {} + cat packages/grid/devspace.yaml | grep '0\.' + bump2version prenum --allow-dirty --no-commit + ls **/VERSION | xargs -I {} python {} + cat packages/grid/devspace.yaml | grep '0\.' + # TODO: Optimize redundant bump protocol version checks - name: Check and Bump Protocol Version run: | @@ -290,8 +329,22 @@ jobs: python -m pip install --upgrade pip pip install --upgrade tox setuptools wheel twine bump2version PyYAML + # Check if the version is a pre-release + - name: Check if the version is a pre-release and modify version string + id: release_checks + run: | + if [[ $(python packages/grid/VERSION) == *"beta"* ]]; then + echo "is_pre_release=true" >> $GITHUB_OUTPUT + echo "github_release_version=$(python packages/grid/VERSION | sed 's/-beta./b/')" >> $GITHUB_OUTPUT + else + echo "is_pre_release=false" >> $GITHUB_OUTPUT + echo "github_release_version=$(python packages/grid/VERSION)" >> $GITHUB_OUTPUT + fi + echo "future_stable_version=$(python packages/grid/VERSION | sed 's/-beta.*//')" >> $GITHUB_OUTPUT + - name: Bump the Version id: bump-version + if: steps.release_checks.outputs.is_pre_release == 'true' run: | ls **/VERSION | xargs -I {} python {} cat packages/grid/devspace.yaml | grep '0\.' @@ -328,19 +381,6 @@ jobs: tox -e syft.build.helm tox -e syft.package.helm - # Check if the version is a pre-release - - name: Check if the version is a pre-release and modify version string - id: release_checks - run: | - if [[ $(python packages/grid/VERSION) == *"beta"* ]]; then - echo "is_pre_release=true" >> $GITHUB_OUTPUT - echo "github_release_version=$(python packages/grid/VERSION | sed 's/-beta./b/')" >> $GITHUB_OUTPUT - else - echo "is_pre_release=false" >> $GITHUB_OUTPUT - echo "github_release_version=$(python packages/grid/VERSION)" >> $GITHUB_OUTPUT - fi - echo "future_stable_version=$(python packages/grid/VERSION | sed 's/-beta.*//')" >> $GITHUB_OUTPUT - - name: Check and Bump Protocol Version run: | if [[ "${{ steps.release_checks.outputs.is_pre_release }}" == "false" ]]; then @@ -356,7 +396,8 @@ jobs: run: | tox -e lint || true - - name: Commit changes to Syft + - name: Changes to commit to Syft Repo during beta release + if: steps.release_checks.outputs.is_pre_release == 'true' uses: EndBug/add-and-commit@v9 with: author_name: ${{ secrets.OM_BOT_NAME }} @@ -364,6 +405,15 @@ jobs: message: "[syft]bump version" add: "['.bumpversion.cfg', 'VERSION', 'packages/grid/VERSION','packages/syft/PYPI.md', 'packages/grid/devspace.yaml', 'packages/syft/src/syft/VERSION', 'packages/syft/setup.cfg', 'packages/grid/frontend/package.json', 'packages/syft/src/syft/__init__.py', 'packages/hagrid/hagrid/manifest_template.yml', 'packages/grid/helm/syft/Chart.yaml','packages/grid/helm/repo', 'packages/hagrid/hagrid/deps.py', 'packages/grid/podman/podman-kube/podman-syft-kube.yaml' ,'packages/grid/podman/podman-kube/podman-syft-kube-config.yaml', 'packages/syftcli/manifest.yml', 'packages/syft/src/syft/protocol/protocol_version.json', 'packages/grid/backend/worker_cpu.dockerfile','packages/grid/helm/syft/values.yaml','packages/grid/helm/syft']" + - name: Changes to commit to Syft Repo during stable release + if: steps.release_checks.outputs.is_pre_release == 'false' + uses: EndBug/add-and-commit@v9 + with: + author_name: ${{ secrets.OM_BOT_NAME }} + author_email: ${{ secrets.OM_BOT_EMAIL }} + message: "[syft] bump protocol version" + add: "['packages/syft/src/syft/protocol/protocol_version.json']" + - name: Scheduled Build and Publish if: github.event_name == 'schedule' run: |