name: ci-check-ns-api-version on: pull_request: paths: - "nym-node-status-api/nym-node-status-api/**" env: WORKING_DIRECTORY: "nym-node-status-api/nym-node-status-api" jobs: check-if-tag-exists: runs-on: arc-linux-latest-dind steps: - name: Checkout repo uses: actions/checkout@v6 - name: Get version from cargo.toml uses: mikefarah/yq@v4.52.4 id: get_version with: cmd: yq -oy '.package.version' ${{ env.WORKING_DIRECTORY }}/Cargo.toml - name: Check if git tag exists run: | TAG=${{ env.WORKING_DIRECTORY }}-${{ steps.get_version.outputs.result }} if [[ -z "$TAG" ]]; then echo "Tag is empty" exit 1 fi git ls-remote --tags origin | awk '{print $2}' if git ls-remote --tags origin | awk '{print $2}' | grep -q "refs/tags/$TAG$" ; then echo "Tag '$TAG' ALREADY EXISTS on the remote" 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 # first, list all tags for logging purposes curl -su ${{ secrets.HARBOR_ROBOT_USERNAME }}:${{ secrets.HARBOR_ROBOT_SECRET }} "$registry/v2/$repo_name/tags/list" | jq # check if there's a matching tag exists=$(curl -su ${{ secrets.HARBOR_ROBOT_USERNAME }}:${{ secrets.HARBOR_ROBOT_SECRET }} "$registry/v2/$repo_name/tags/list" | jq -r --arg tag "$TAG" 'any(.tags[]; . == $tag)' ) if [[ $exists = "true" ]]; then echo "Version '$TAG' defined in Cargo.toml ALREADY EXISTS as tag in harbor repo" exit 1 elif [[ $exists = "false" ]]; then echo "Version '$TAG' doesn't exist on the remote" else echo "Unknown output '$exists'" exit 2 fi