Skip to content

Commit 3baac12

Browse files
authored
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 b83fbad.
1 parent dc88650 commit 3baac12

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: ci-check-ns-api-version
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "nym-node-status-api/**"
7+
8+
env:
9+
WORKING_DIRECTORY: "nym-node-status-api/nym-node-status-api"
10+
11+
jobs:
12+
check-if-tag-exists:
13+
runs-on: arc-ubuntu-22.04-dind
14+
steps:
15+
- name: Checkout repo
16+
uses: actions/checkout@v4
17+
18+
- name: Get version from cargo.toml
19+
uses: mikefarah/[email protected]
20+
id: get_version
21+
with:
22+
cmd: yq -oy '.package.version' ${{ env.WORKING_DIRECTORY }}/Cargo.toml
23+
24+
- name: Check if git tag exists
25+
uses: actions/checkout@v4
26+
- run: |
27+
TAG=${{ env.WORKING_DIRECTORY }}-${{ steps.get_version.outputs.result }}
28+
if [[ -z "$TAG" ]]; then
29+
echo "Tag is empty"
30+
exit 1
31+
fi
32+
if git ls-remote --tags origin | grep -q "refs/tags/$TAG$" ; then
33+
echo "Tag '$TAG' ALREADY EXISTS on the remote"
34+
# TODO uncomment after bumping NS API version
35+
# exit 1
36+
else
37+
echo "Tag '$TAG' does not exist on the remote"
38+
fi
39+
- name: Check if harbor tag exists
40+
run: |
41+
TAG=${{ steps.get_version.outputs.result }}
42+
registry=https://harbor.nymte.ch
43+
repo_name=nym/node-status-api
44+
if [[ -z $TAG ]]; then
45+
echo "Tag is empty"
46+
exit 1
47+
fi
48+
curl -su "${{ secrets.HARBOR_ROBOT_USERNAME }}":"${{ secrets.HARBOR_ROBOT_SECRET }}" "$registry/v2/$repo_name/tags/list" | jq
49+
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
50+
result=$?
51+
if [ "${result}" -eq 0 ]; then
52+
echo "Version '$TAG' defined in Cargo.toml already exists as tag in harbor repo"
53+
# TODO uncomment after bumping NS API version
54+
# exit 1
55+
else
56+
echo "Version '$TAG' doesn't exist on the remote"
57+
fi

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nym-node-status-api/nym-node-status-api/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
[package]
55
name = "nym-node-status-api"
6+
7+
68
version = "1.0.2"
79
authors.workspace = true
810
repository.workspace = true

0 commit comments

Comments
 (0)