From dc4205fde22fa6d15f2a5b6b17c41bf32e8a142e Mon Sep 17 00:00:00 2001 From: Marlon Saglia Date: Fri, 20 Sep 2024 14:47:30 +0200 Subject: [PATCH] fixes after testing the workflow --- .github/workflows/publish-cli.yml | 20 ++++++++++++++++---- client/go/Makefile | 14 +++++++------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/.github/workflows/publish-cli.yml b/.github/workflows/publish-cli.yml index 5a3d65564878..5923c8f0880d 100644 --- a/.github/workflows/publish-cli.yml +++ b/.github/workflows/publish-cli.yml @@ -53,11 +53,21 @@ jobs: - name: Check for Changes id: check-diff env: - VERSION_PREFIX: 'v8*' # We need the 8 or else "vespa-7." will match and sort before "v8.x.y" + VERSION_PATTERN: '^v8\.' # We need the 8 prefix or else "vespa-7." will match and sort before "v8.x.y" + GH_TOKEN: ${{ github.token }} run: | + set -x + # Checks for changes since the last release. new_tag="v${{ steps.meta.outputs.version }}" - previous_tag=$(git tag --list "${VERSION_PREFIX}" --sort="-version:refname" | grep -v "${new_tag}" | head -n 1) + previous_tag=$(gh release list --exclude-drafts --exclude-pre-releases --json tagName --jq '.[0].tagName' | grep -E "${VERSION_PATTERN}" | head -n 1) + + # If the previous tag and the current tag are the same, there are no changes. + if [[ "${previous_tag}" == "${new_tag}" ]]; then + echo "No changes detected between ${previous_tag} and ${new_tag}." + echo "has-changes=false" >> "${GITHUB_OUTPUT}" + exit 0 + fi # Detect if we are using a dev version (starts with "0.0.0-dev"). if [[ "${new_tag:0:}" == "0.0.0-dev" ]]; then @@ -88,14 +98,16 @@ jobs: # This workflow only interacts with the client/go directory, so we can set the working directory here. working-directory: client/go + env: + VERSION: ${{ needs.prepare.outputs.build-version }} + HAS_CHANGES: ${{ needs.prepare.outputs.changes-detected }} + steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 - name: build - env: - VERSION: ${{ needs.prepare.outputs.build-version }} run: | make clean dist diff --git a/client/go/Makefile b/client/go/Makefile index 2f700571fb10..055f0d43ea44 100644 --- a/client/go/Makefile +++ b/client/go/Makefile @@ -52,13 +52,13 @@ dist-homebrew: # # $ make dist-github --dist-github: dist - RELEASE_URL="$(gh release create v$(VERSION) - --verify-tag - --repo vespa-engine/vespa - --notes-file $(CURDIR)/README.md - --title "Vespa CLI $(VERSION)" - $(DIST)/vespa-cli_$(VERSION)_sha256sums.txt - $(DIST)/vespa-cli_$(VERSION)_*.zip + RELEASE_URL="$(gh release create v$(VERSION) \ + --verify-tag \ + --repo vespa-engine/vespa \ + --notes-file $(CURDIR)/README.md \ + --title "Vespa CLI $(VERSION)" \ + $(DIST)/vespa-cli_$(VERSION)_sha256sums.txt \ + $(DIST)/vespa-cli_$(VERSION)_*.zip \ $(DIST)/vespa-cli_$(VERSION)_*.tar.gz)" echo $RELEASE_URL > /tmp/vespa-cli-release-url.txt