diff --git a/.github/workflows/vespacli.yml b/.github/workflows/vespacli.yml new file mode 100644 index 00000000..7700e0f1 --- /dev/null +++ b/.github/workflows/vespacli.yml @@ -0,0 +1,179 @@ +name: vespacli - Check, Update, Test, Create PR, Release + +defaults: + run: + working-directory: ./vespacli + +on: + workflow_dispatch: + schedule: + # Run at midnight sunday-thursday + - cron: "0 0 * * 1-4" + +jobs: + check-and-update: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.set_output.outputs.version }} + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install dependencies and this repo + run: | + python -m pip install --upgrade pip + pip install -e .[build] + - name: Check latest version and set version variable + id: check_latest_version + run: | + version=$(python utils/check_latest_version.py) + echo "Latest version is $version" + # Set the output variable + echo "version=$version" >> $GITHUB_OUTPUT + + - name: Update the version (if not NA) + if: ${{ (steps.check_latest_version.outputs.version != 'NA') }} + run: | + # Print evaluation of the condition + echo "Version is not NA, updating version to ${{ steps.check_latest_version.outputs.version }}" + echo "Updating Vespa CLI version to ${{ steps.check_latest_version.outputs.version }}" + python utils/update_version.py --version ${{ steps.check_latest_version.outputs.version }} + + - name: Download latest binaries + if: ${{ steps.check_latest_version.outputs.version != 'NA' }} + run: | + python utils/download_binaries.py --version ${{ steps.check_latest_version.outputs.version }} + + - name: Upload binaries as artifact + uses: actions/upload-artifact@v4 + with: + name: binaries + path: vespacli/vespacli/go-binaries + + - name: Set the output variable + id: set_output + if: ${{ steps.check_latest_version.outputs.version != 'NA' }} + run: | + echo "version=${{ steps.check_latest_version.outputs.version }}" >> $GITHUB_OUTPUT + test: + needs: check-and-update + if: ${{ needs.check-and-update.outputs.version != 'NA' }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-12, macos-14] + python-version: ["3.10", "3.11"] # Update or modify Python versions as needed + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: binaries + path: vespacli/vespacli/go-binaries + + - name: Set permissions on all files in go-binaries + run: | + chmod -R +x vespacli/go-binaries/* + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e .[build] + + - name: Update latest version + run: | + python utils/update_version.py --version ${{ needs.check-and-update.outputs.version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e .[build] + + - name: Verify installation + run: | + vespa version + + create-pr: + needs: [check-and-update, test] + outputs: + version: ${{ needs.check-and-update.outputs.version }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install dependencies and this repo + run: | + python -m pip install --upgrade pip + pip install -e .[build] + + - name: Update latest version + run: | + python utils/update_version.py --version ${{ needs.check-and-update.outputs.version }} + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "Update Vespa CLI version to ${{ needs.check-and-update.outputs.version }}" + title: "Update Vespa CLI version to ${{ needs.check-and-update.outputs.version }}" + body: "This PR updates the Vespa CLI version to ${{ needs.check-and-update.outputs.version }}" + branch: "update-vespa-cli-version-${{ needs.check-and-update.outputs.version }}" + base: "master" + labels: "vespacli" + + release: + needs: create-pr + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install dependencies and this repo + run: | + python -m pip install --upgrade pip + pip install -e .[build] + + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: binaries + path: vespacli/vespacli/go-binaries + + - name: Set permissions on all files in go-binaries + run: | + chmod -R +x vespacli/go-binaries/* + + - name: Update latest version + run: | + python utils/update_version.py --version ${{ needs.create-pr.outputs.version }} + + - name: Build + run: | + python -m build + + - name: Upload to PyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN_VESPACLI }} + run: | + python -m twine upload dist/* \ No newline at end of file diff --git a/.github/workflows/vespacli_check_version.yml b/.github/workflows/vespacli_check_version.yml deleted file mode 100644 index f0f19e62..00000000 --- a/.github/workflows/vespacli_check_version.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: vespacli - Check for Vespa CLI version update - -defaults: - run: - working-directory: ./vespacli - -on: - workflow_dispatch: - schedule: - - cron: "0 0 * * *" # Runs at 00:00 UTC daily - -jobs: - check-and-update: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.10" - - - name: Install dependencies and this repo - run: | - python -m pip install --upgrade pip - pip install -r requirements_build.txt - pip install -e . - - name: Check latest version and set version variable - id: check_latest_version - run: | - version=$(python utils/check_latest_version.py) - echo "Latest version is $version" - # Set the output variable - echo "version=$version" >> $GITHUB_OUTPUT - - - name: Update the version (if not NA) - if: ${{ (steps.check_latest_version.outputs.version != 'NA') && (github.ref == 'refs/heads/master') }} - run: | - # Print evaluation of the condition - echo "Version is not NA, updating version to ${{ steps.check_latest_version.outputs.version }}" - echo "Updating Vespa CLI version to ${{ steps.check_latest_version.outputs.version }}" - python utils/update_version.py --version ${{ steps.check_latest_version.outputs.version }} - - - name: Commit the changes (if not NA) - if: ${{ (steps.check_latest_version.outputs.version != 'NA') && (github.ref == 'refs/heads/master') }} - uses: EndBug/add-and-commit@v9 - with: - add: | # Action does not use working-directory - 'vespacli/pyproject.toml' - 'vespacli/vespacli/_version_generated.py' - # Add `cli-vX.Y.Z` tag to the commit - tag: ${{ format('cli-v{0}', steps.check_latest_version.outputs.version) }} - default_author: github_actions - message: "Update Vespa CLI version to ${{ steps.check_latest_version.outputs.version }}" diff --git a/.github/workflows/vespacli_release_publish.yml b/.github/workflows/vespacli_release_publish.yml deleted file mode 100644 index 55b4506e..00000000 --- a/.github/workflows/vespacli_release_publish.yml +++ /dev/null @@ -1,81 +0,0 @@ -name: vespacli - Release and upload PyPI - -defaults: - run: - working-directory: ./vespacli - -on: - workflow_run: - workflows: ["vespacli - tests"] - branches: [master] - types: - - completed - workflow_dispatch: - # push: - # tags: - # - cli-v*.*.* # Push events to matching cli-v*.*.* tags - -jobs: - prepare-binaries: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.10" - - - name: Download latest binaries - run: | - python -m pip install --upgrade pip - pip install -r requirements_build.txt - pip install -e . - - - name: Get current version, set as variable and download binaries - id: get_current_version - run: | - version=$(python -c "import vespacli; print(vespacli.__version__)") - echo "Current version is $version" - echo "version=$version" >> $GITHUB_ENV - python utils/download_binaries.py --version $version - - - name: Upload binaries as artifact - uses: actions/upload-artifact@v4 - with: - name: binaries - path: vespacli/vespacli/go-binaries - - build-and-release: - needs: prepare-binaries - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - - - name: Install build dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements_build.txt - - - name: Download artifact - uses: actions/download-artifact@v4 - with: - name: binaries - path: vespacli/vespacli/go-binaries - - - name: Set permissions on all files in go-binaries - run: | - chmod -R +x vespacli/go-binaries/* - - - name: Build - run: | - python -m build - - - name: Upload to PyPI - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN_VESPACLI }} - run: twine upload dist/* --non-interactive diff --git a/.github/workflows/vespacli_test.yml b/.github/workflows/vespacli_test.yml deleted file mode 100644 index f2283562..00000000 --- a/.github/workflows/vespacli_test.yml +++ /dev/null @@ -1,68 +0,0 @@ -name: vespacli - tests - -defaults: - run: - working-directory: ./vespacli - -on: - workflow_dispatch: - schedule: - - cron: "0 0 * * 0" # Run once a week - -jobs: - prepare-binaries: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.10" - - - name: Download latest binaries - run: | - python -m pip install --upgrade pip - pip install -r requirements_build.txt - pip install -e . - python utils/download_binaries.py --version current - - - name: Upload binaries as artifact - uses: actions/upload-artifact@v4 - with: - name: binaries - path: vespacli/vespacli/go-binaries - - build-and-test: - needs: prepare-binaries - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-12, macos-14] - python-version: ["3.10", "3.11"] # Update or modify Python versions as needed - steps: - - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Download artifact - uses: actions/download-artifact@v4 - with: - name: binaries - path: vespacli/vespacli/go-binaries - - - name: Set permissions on all files in go-binaries - run: | - chmod -R +x vespacli/go-binaries/* - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -e .[test] requests - - - name: Verify installation - run: | - vespa version diff --git a/vespacli/requirements_build.txt b/vespacli/requirements_build.txt deleted file mode 100644 index 3611dcee..00000000 --- a/vespacli/requirements_build.txt +++ /dev/null @@ -1,5 +0,0 @@ -setuptools==69.0.3 -build==1.0.3 -twine==4.0.1 -toml==0.10.2 -requests==2.32.2 \ No newline at end of file diff --git a/vespacli/requirements_dev.txt b/vespacli/requirements_dev.txt deleted file mode 100644 index 2309b208..00000000 --- a/vespacli/requirements_dev.txt +++ /dev/null @@ -1,27 +0,0 @@ -# Development requirements -# TODO remove some -black==23.11.0 -httpx~=0.23.0 -invoke~=2.2 -mypy~=1.4 -mypy-protobuf~=3.3.0 # TODO: can't use mypy-protobuf>=3.4 because of protobuf==3.19 support -pre-commit>=2.21,<4 -pytest~=7.4 -pytest-env~=0.6.2 -pytest-markdown-docs==0.4.3 -pytest-timeout~=2.1.0 -pytest-mock==3.12.0 -python-dotenv~=1.0.0;python_version>='3.8' -requests~=2.32.2 -ruff>=0.0.291 -types-croniter~=1.0.8 -types-python-dateutil~=2.8.10 -types-requests~=2.31.0 -types-setuptools~=57.4.11 -types-six==1.16.21 -types-toml~=0.10.4 -twine~=4.0.1 -wheel~=0.37.1 -nbclient==0.6.8 -notebook==6.5.1 -jupytext==1.14.1