From 67b80e901c840e5c81fa1c7ea5c45bfdcb7445f8 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 22 Nov 2023 17:01:09 -0600 Subject: [PATCH 01/11] Test publishing --- .gitea/workflows/publish.yaml | 26 ++++++++++++++++++ package.json | 3 +++ scripts/publish-app-record.sh | 50 +++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 .gitea/workflows/publish.yaml create mode 100755 scripts/publish-app-record.sh diff --git a/.gitea/workflows/publish.yaml b/.gitea/workflows/publish.yaml new file mode 100644 index 0000000..6964a89 --- /dev/null +++ b/.gitea/workflows/publish.yaml @@ -0,0 +1,26 @@ +name: Publish npm package to gitea +on: + release: + types: [published] +jobs: + cns_publish: + runs-on: ubuntu-latest + steps: + - name: "Clone project repository" + uses: actions/checkout@v3 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + - name: "Install Yarn" + run: npm install -g yarn + - name: "Install registry CLI" + run: | + npm config set @cerc-io:registry https://git.vdb.to/api/packages/cerc-io/npm/ + yarn global add @cerc-io/laconic-registry-cli + - name: "Publish Record" + run: | + CERC_REPO_TAG=${{ github.sha }} \ + CERC_LACONIC_BOND_ID=$CICD_LACONIC_BOND_ID \ + CERC_LACONIC_USER_KEY=$CICD_LACONIC_USER_KEY \ + scripts/publish-app-record.sh diff --git a/package.json b/package.json index 6335967..f99862c 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,8 @@ { "private": true, + "name": "@cerc-io/test-progressive-web-app", + "version": "0.1.0", + "repository": "https://git.vdb.to/cerc-io/test-progressive-web-app", "scripts": { "dev": "next dev", "build": "next build", diff --git a/scripts/publish-app-record.sh b/scripts/publish-app-record.sh new file mode 100755 index 0000000..5f07731 --- /dev/null +++ b/scripts/publish-app-record.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +set -e + +RECORD_FILE=tmp.rf.$$ +CONFIG_FILE=`mktemp` + +CERC_APP_TYPE=${CERC_APP_TYPE:-"webapp"} +CERC_REPO_TAG=${CERC_REPO_TAG:-"main"} + +rcd_name=$(jq -r '.name' package.json | sed 's/null//') +rcd_desc=$(jq -r '.description' package.json | sed 's/null//') +rcd_repository=$(jq -r '.repository' package.json | sed 's/null//') +rcd_homepage=$(jq -r '.homepage' package.json | sed 's/null//') +rcd_license=$(jq -r '.license' package.json | sed 's/null//') +rcd_author=$(jq -r '.license' package.json | sed 's/null//') +rcd_app_version=$(jq -r '.version' package.json | sed 's/null//') + +cat < "$CONFIG_FILE" +services: + cns: + restEndpoint: '${CERC_LACONIC_REST_ENDPOINT:-http://console.laconic.com:1317}' + gqlEndpoint: '${CERC_LACONIC_GQL_ENDPOINT:-http://console.laconic.com:9473/api}' + chainId: ${CERC_LACONIC_CHAIN_ID:-laconic_9000-1} + gas: 350000 + fees: 200000aphoton +EOF + +next_ver=$(laconic -c $CONFIG_FILE cns record list --type ApplicationRecord --all --name "$rcd_name" 2>/dev/null | jq -r '.[0].attributes.version' | awk -F. -v OFS=. '{$NF += 1 ; print}') + +cat < "$RECORD_FILE" +record: + type: ApplicationRecord + version: ${next_ver:-0.0.1} + name: "$rcd_name" + description: "$rcd_desc" + homepage: "$rcd_homepage" + license: "$rcd_license" + author: "$rcd_author" + repository: "$rcd_repository" + repository_tag: "$CERC_REPO_TAG" + app_version: "$rcd_app_version" + app_type: "$CERC_APP_TYPE" +EOF + + +cat $RECORD_FILE +laconic -c $CONFIG_FILE cns record publish --filename $RECORD_FILE --user-key "${CERC_LACONIC_USER_KEY}" --bond-id $CERC_LACONIC_BOND_ID + +rm -f $RECORD_FILE $CONFIG_FILE -- 2.45.2 From f4b8b2bd055185319868983d2da526865830bca6 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 22 Nov 2023 17:03:08 -0600 Subject: [PATCH 02/11] Trigger --- .gitea/workflows/publish.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/publish.yaml b/.gitea/workflows/publish.yaml index 6964a89..0483f41 100644 --- a/.gitea/workflows/publish.yaml +++ b/.gitea/workflows/publish.yaml @@ -1,5 +1,8 @@ -name: Publish npm package to gitea +name: Publish ApplicationRecord to Laconic Registry on: + pull_request: + branches: + - '*' release: types: [published] jobs: -- 2.45.2 From 571cb8b4e2f63eeaae66c25041fcccb25fae269f Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 22 Nov 2023 17:04:00 -0600 Subject: [PATCH 03/11] Trigger --- .gitea/workflows/publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/publish.yaml b/.gitea/workflows/publish.yaml index 0483f41..d6a05c1 100644 --- a/.gitea/workflows/publish.yaml +++ b/.gitea/workflows/publish.yaml @@ -1,4 +1,4 @@ -name: Publish ApplicationRecord to Laconic Registry +name: Publish ApplicationRecord to Registry on: pull_request: branches: -- 2.45.2 From b8069ee6880ed27c830a536cd5a909e51532526d Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 22 Nov 2023 17:07:16 -0600 Subject: [PATCH 04/11] Trigger --- .gitea/workflows/publish.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitea/workflows/publish.yaml b/.gitea/workflows/publish.yaml index d6a05c1..8433974 100644 --- a/.gitea/workflows/publish.yaml +++ b/.gitea/workflows/publish.yaml @@ -21,6 +21,8 @@ jobs: run: | npm config set @cerc-io:registry https://git.vdb.to/api/packages/cerc-io/npm/ yarn global add @cerc-io/laconic-registry-cli + - name: "Install jq" + run: apt -y update && apt -y install jq - name: "Publish Record" run: | CERC_REPO_TAG=${{ github.sha }} \ -- 2.45.2 From bf8c53d97ae0bc86f771c1793362035eb909f81b Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 22 Nov 2023 17:13:43 -0600 Subject: [PATCH 05/11] env --- scripts/publish-app-record.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/publish-app-record.sh b/scripts/publish-app-record.sh index 5f07731..d575198 100755 --- a/scripts/publish-app-record.sh +++ b/scripts/publish-app-record.sh @@ -45,6 +45,7 @@ EOF cat $RECORD_FILE +env laconic -c $CONFIG_FILE cns record publish --filename $RECORD_FILE --user-key "${CERC_LACONIC_USER_KEY}" --bond-id $CERC_LACONIC_BOND_ID rm -f $RECORD_FILE $CONFIG_FILE -- 2.45.2 From 72ddd8af8d586089afd5d820132d6ca7bb6d3e53 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 22 Nov 2023 17:22:59 -0600 Subject: [PATCH 06/11] Defaults --- .gitea/workflows/publish.yaml | 6 +----- scripts/publish-app-record.sh | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.gitea/workflows/publish.yaml b/.gitea/workflows/publish.yaml index 8433974..af52fc1 100644 --- a/.gitea/workflows/publish.yaml +++ b/.gitea/workflows/publish.yaml @@ -24,8 +24,4 @@ jobs: - name: "Install jq" run: apt -y update && apt -y install jq - name: "Publish Record" - run: | - CERC_REPO_TAG=${{ github.sha }} \ - CERC_LACONIC_BOND_ID=$CICD_LACONIC_BOND_ID \ - CERC_LACONIC_USER_KEY=$CICD_LACONIC_USER_KEY \ - scripts/publish-app-record.sh + run: scripts/publish-app-record.sh diff --git a/scripts/publish-app-record.sh b/scripts/publish-app-record.sh index d575198..8c3e730 100755 --- a/scripts/publish-app-record.sh +++ b/scripts/publish-app-record.sh @@ -6,7 +6,7 @@ RECORD_FILE=tmp.rf.$$ CONFIG_FILE=`mktemp` CERC_APP_TYPE=${CERC_APP_TYPE:-"webapp"} -CERC_REPO_TAG=${CERC_REPO_TAG:-"main"} +CERC_REPO_TAG=${CERC_REPO_TAG:-${GITHUB_SHA:-main}} rcd_name=$(jq -r '.name' package.json | sed 's/null//') rcd_desc=$(jq -r '.description' package.json | sed 's/null//') @@ -46,6 +46,6 @@ EOF cat $RECORD_FILE env -laconic -c $CONFIG_FILE cns record publish --filename $RECORD_FILE --user-key "${CERC_LACONIC_USER_KEY}" --bond-id $CERC_LACONIC_BOND_ID +laconic -c $CONFIG_FILE cns record publish --filename $RECORD_FILE --user-key "${CERC_LACONIC_USER_KEY:-$CICD_LACONIC_USER_KEY}" --bond-id ${CERC_LACONIC_BOND_ID:-$CICD_LACONIC_BOND_ID} rm -f $RECORD_FILE $CONFIG_FILE -- 2.45.2 From 84b45ccb5c4e04a5684db0e373eab3e029d6b9ea Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 22 Nov 2023 17:27:20 -0600 Subject: [PATCH 07/11] Bond ID --- .gitea/workflows/publish.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitea/workflows/publish.yaml b/.gitea/workflows/publish.yaml index af52fc1..f4b8b67 100644 --- a/.gitea/workflows/publish.yaml +++ b/.gitea/workflows/publish.yaml @@ -24,4 +24,7 @@ jobs: - name: "Install jq" run: apt -y update && apt -y install jq - name: "Publish Record" + env: + CERC_LACONIC_USER_KEY: ${{ secrets.CICD_LACONIC_USER_KEY }} + CERC_LACONIC_BOND_ID: ${{ secrets.CICD_LACONIC_BOND_ID }} run: scripts/publish-app-record.sh -- 2.45.2 From cea7e96ffa0afdaf6b972e48bdd656a52e398b09 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 22 Nov 2023 17:29:17 -0600 Subject: [PATCH 08/11] Remove en v --- scripts/publish-app-record.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/publish-app-record.sh b/scripts/publish-app-record.sh index 8c3e730..412686e 100755 --- a/scripts/publish-app-record.sh +++ b/scripts/publish-app-record.sh @@ -45,7 +45,6 @@ EOF cat $RECORD_FILE -env laconic -c $CONFIG_FILE cns record publish --filename $RECORD_FILE --user-key "${CERC_LACONIC_USER_KEY:-$CICD_LACONIC_USER_KEY}" --bond-id ${CERC_LACONIC_BOND_ID:-$CICD_LACONIC_BOND_ID} rm -f $RECORD_FILE $CONFIG_FILE -- 2.45.2 From ee983aae74572281d92c7ed3ba5633c40d6cda6b Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 22 Nov 2023 17:35:44 -0600 Subject: [PATCH 09/11] Reverse sort --- scripts/publish-app-record.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/publish-app-record.sh b/scripts/publish-app-record.sh index 412686e..1f94a8b 100755 --- a/scripts/publish-app-record.sh +++ b/scripts/publish-app-record.sh @@ -26,7 +26,7 @@ services: fees: 200000aphoton EOF -next_ver=$(laconic -c $CONFIG_FILE cns record list --type ApplicationRecord --all --name "$rcd_name" 2>/dev/null | jq -r '.[0].attributes.version' | awk -F. -v OFS=. '{$NF += 1 ; print}') +next_ver=$(laconic -c $CONFIG_FILE cns record list --type ApplicationRecord --all --name "$rcd_name" 2>/dev/null | jq -s '.[] | sort_by(.createTime) | reverse' | jq -r '.[0].attributes.version' | awk -F. -v OFS=. '{$NF += 1 ; print}') cat < "$RECORD_FILE" record: -- 2.45.2 From 6da833aaab716970bc611cd123f8155e3bf76622 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 22 Nov 2023 17:36:23 -0600 Subject: [PATCH 10/11] Only on release --- .gitea/workflows/publish.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitea/workflows/publish.yaml b/.gitea/workflows/publish.yaml index f4b8b67..75a01ea 100644 --- a/.gitea/workflows/publish.yaml +++ b/.gitea/workflows/publish.yaml @@ -1,8 +1,5 @@ name: Publish ApplicationRecord to Registry on: - pull_request: - branches: - - '*' release: types: [published] jobs: -- 2.45.2 From c99a2ccdea94eae39b64e0669b9049d2f68f9647 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 22 Nov 2023 17:58:03 -0600 Subject: [PATCH 11/11] Filter by bond ID --- scripts/publish-app-record.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/publish-app-record.sh b/scripts/publish-app-record.sh index 1f94a8b..81f1a93 100755 --- a/scripts/publish-app-record.sh +++ b/scripts/publish-app-record.sh @@ -26,7 +26,7 @@ services: fees: 200000aphoton EOF -next_ver=$(laconic -c $CONFIG_FILE cns record list --type ApplicationRecord --all --name "$rcd_name" 2>/dev/null | jq -s '.[] | sort_by(.createTime) | reverse' | jq -r '.[0].attributes.version' | awk -F. -v OFS=. '{$NF += 1 ; print}') +next_ver=$(laconic -c $CONFIG_FILE cns record list --type ApplicationRecord --all --name "$rcd_name" 2>/dev/null | jq -r -s ".[] | sort_by(.createTime) | reverse | [ .[] | select(.bondId == \"$CERC_LACONIC_BOND_ID\") ] | .[0].attributes.version" | awk -F. -v OFS=. '{$NF += 1 ; print}') cat < "$RECORD_FILE" record: @@ -45,6 +45,6 @@ EOF cat $RECORD_FILE -laconic -c $CONFIG_FILE cns record publish --filename $RECORD_FILE --user-key "${CERC_LACONIC_USER_KEY:-$CICD_LACONIC_USER_KEY}" --bond-id ${CERC_LACONIC_BOND_ID:-$CICD_LACONIC_BOND_ID} +laconic -c $CONFIG_FILE cns record publish --filename $RECORD_FILE --user-key "${CERC_LACONIC_USER_KEY}" --bond-id ${CERC_LACONIC_BOND_ID} rm -f $RECORD_FILE $CONFIG_FILE -- 2.45.2