From 3baac1292d03378736a1ffd5f3e1ed28cb42b097 Mon Sep 17 00:00:00 2001 From: dynco-nym <173912580+dynco-nym@users.noreply.github.com> Date: Fri, 14 Mar 2025 16:31:49 +0100 Subject: [PATCH] Add workflow to check if tag exists (#5617) * Add workflow * Check harbor for tag * Remove leftover comments * Try out cargo metadata * Revert "Try out cargo metadata" This reverts commit b83fbad1cac8e74e4f1f8fcc4bde6b3e5e9f700d. --- .github/workflows/ci-check-ns-api-version.yml | 57 +++++++++++++++++++ Cargo.lock | 1 + .../nym-node-status-api/Cargo.toml | 2 + 3 files changed, 60 insertions(+) create mode 100644 .github/workflows/ci-check-ns-api-version.yml diff --git a/.github/workflows/ci-check-ns-api-version.yml b/.github/workflows/ci-check-ns-api-version.yml new file mode 100644 index 0000000000..2298e1fab7 --- /dev/null +++ b/.github/workflows/ci-check-ns-api-version.yml @@ -0,0 +1,57 @@ +name: ci-check-ns-api-version + +on: + pull_request: + paths: + - "nym-node-status-api/**" + +env: + WORKING_DIRECTORY: "nym-node-status-api/nym-node-status-api" + +jobs: + check-if-tag-exists: + runs-on: arc-ubuntu-22.04-dind + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Get version from cargo.toml + uses: mikefarah/yq@v4.45.1 + id: get_version + with: + cmd: yq -oy '.package.version' ${{ env.WORKING_DIRECTORY }}/Cargo.toml + + - name: Check if git tag exists + uses: actions/checkout@v4 + - run: | + TAG=${{ env.WORKING_DIRECTORY }}-${{ steps.get_version.outputs.result }} + if [[ -z "$TAG" ]]; then + echo "Tag is empty" + exit 1 + fi + if git ls-remote --tags origin | grep -q "refs/tags/$TAG$" ; then + echo "Tag '$TAG' ALREADY EXISTS on the remote" + # TODO uncomment after bumping NS API version + # exit 1 + else + echo "Tag '$TAG' does not exist on the remote" + fi + - name: Check if harbor tag exists + run: | + TAG=${{ steps.get_version.outputs.result }} + registry=https://harbor.nymte.ch + repo_name=nym/node-status-api + if [[ -z $TAG ]]; then + echo "Tag is empty" + exit 1 + fi + curl -su "${{ secrets.HARBOR_ROBOT_USERNAME }}":"${{ secrets.HARBOR_ROBOT_SECRET }}" "$registry/v2/$repo_name/tags/list" | jq + curl -su ${{ secrets.HARBOR_ROBOT_USERNAME }}:${{ secrets.HARBOR_ROBOT_SECRET }} "$registry/v2/$repo_name/tags/list" | jq -e --arg search $TAG '.tags | index($search)' > /dev/null + result=$? + if [ "${result}" -eq 0 ]; then + echo "Version '$TAG' defined in Cargo.toml already exists as tag in harbor repo" + # TODO uncomment after bumping NS API version + # exit 1 + else + echo "Version '$TAG' doesn't exist on the remote" + fi diff --git a/Cargo.lock b/Cargo.lock index 4d30ae54a3..00e49d7ca8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6241,6 +6241,7 @@ dependencies = [ "nym-crypto", "nym-gateway", "nym-gateway-stats-storage", + "nym-http-api-client", "nym-http-api-common", "nym-ip-packet-router", "nym-metrics", diff --git a/nym-node-status-api/nym-node-status-api/Cargo.toml b/nym-node-status-api/nym-node-status-api/Cargo.toml index f78218e246..d3e70db0c6 100644 --- a/nym-node-status-api/nym-node-status-api/Cargo.toml +++ b/nym-node-status-api/nym-node-status-api/Cargo.toml @@ -3,6 +3,8 @@ [package] name = "nym-node-status-api" + + version = "1.0.2" authors.workspace = true repository.workspace = true