From d7d0253f0ca235d1796916d55557117cd88f8540 Mon Sep 17 00:00:00 2001 From: Yaroslav Grishajev Date: Fri, 12 Apr 2024 16:04:35 +0200 Subject: [PATCH 01/10] chore(ts): removes eslintrc.json from npm package --- ts/.npmignore | 1 + 1 file changed, 1 insertion(+) diff --git a/ts/.npmignore b/ts/.npmignore index c8fc01f8..a83ecf3b 100644 --- a/ts/.npmignore +++ b/ts/.npmignore @@ -5,6 +5,7 @@ jest.config.js tsconfig.build.json tsconfig.json +.eslintrc.json # Source and test files src From 9452e2219fa52b5b1b42a30433352d02f2819f0e Mon Sep 17 00:00:00 2001 From: Yaroslav Grishajev Date: Fri, 12 Apr 2024 16:15:21 +0200 Subject: [PATCH 02/10] fix(ts): uses proper GITHUB_TOKEN --- .github/workflows/release-ts.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-ts.yaml b/.github/workflows/release-ts.yaml index 1741d35a..22fe7d9e 100644 --- a/.github/workflows/release-ts.yaml +++ b/.github/workflows/release-ts.yaml @@ -46,7 +46,7 @@ jobs: - name: Publish npm package if: steps.changes.outputs.ts == 'true' env: - GITHUB_TOKEN: ${{ secrets.AUTH_GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} run: make release-ts From 26c48fe2e77c42eb7cda4c0d7642c4b5201d178f Mon Sep 17 00:00:00 2001 From: Yaroslav Grishajev Date: Fri, 12 Apr 2024 22:21:04 +0200 Subject: [PATCH 03/10] fix(ts): does not mark ts release as latest in github --- make/release-ts.mk | 6 +----- script/release-ts.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 5 deletions(-) create mode 100755 script/release-ts.sh diff --git a/make/release-ts.mk b/make/release-ts.mk index 7351256a..1131fa84 100644 --- a/make/release-ts.mk +++ b/make/release-ts.mk @@ -1,10 +1,6 @@ .PHONY: release-ts release-ts: $(AKASH_TS_NODE_MODULES) $(AKASH_TS_ROOT)/dist - if [ -z "$$CI" ]; then \ - cd $(AKASH_TS_ROOT) && npx semantic-release --no-ci; \ - else \ - cd $(AKASH_TS_ROOT) && npx semantic-release; \ - fi + script/release-ts.sh $(AKASH_TS_ROOT)/dist: $(shell find $(AKASH_TS_ROOT)/src -type f) cd $(AKASH_TS_ROOT) && npm run build \ No newline at end of file diff --git a/script/release-ts.sh b/script/release-ts.sh new file mode 100755 index 00000000..16871caa --- /dev/null +++ b/script/release-ts.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +API_URL="https://api.github.com" + +log() { + echo "$(date +"[%I:%M:%S %p]") [ts-release] $1" +} + +log "Fetching the current latest release information..." +current_latest=$(curl -s -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \ + "$API_URL/repos/$GITHUB_ACTION_REPOSITORY/releases/latest") +current_latest_id=$(echo "$current_latest" | jq -r '.id') + +if [ "$current_latest_id" == "null" ]; then + log "No current latest release found." + exit 1 +else + log "Current latest release ID: $current_latest_id" +fi + +log "Running semantic-release..." +if [ -z "$CI" ]; then + log "Running in non-CI mode..." + cd "$AKASH_TS_ROOT" && npx semantic-release --no-ci +else + log "Running in CI mode..." + cd "$AKASH_TS_ROOT" && npx semantic-release +fi + +log "Attempting to mark the release (ID: $current_latest_id) as the latest again..." +update_response=$(curl -s -X PATCH -H "Authorization: token $GITHUB_TOKEN" -H "Content-Type: application/json" -H "Accept: application/vnd.github.v3+json" \ + -d "{\"make_latest\": \"true\"}" \ + "$API_URL/repos/$GITHUB_ACTION_REPOSITORY/releases/$current_latest_id") + +log "Update response:" +echo "$update_response" | jq + +if echo "$update_response" | jq -e '.id'; then + log "The release was successfully marked as the latest." +else + log "Failed to update the release. Check the response above for errors." +fi From 6a92bcbb8ab8112c08b202bb7693c66e960cfaa3 Mon Sep 17 00:00:00 2001 From: Yaroslav Grishajev Date: Mon, 15 Apr 2024 08:55:18 +0200 Subject: [PATCH 04/10] test(ts): adjusts coverage paths --- ts/README.md | 1 + ts/jest.config.js | 1 + 2 files changed, 2 insertions(+) diff --git a/ts/README.md b/ts/README.md index 6d7fc56c..803077cb 100644 --- a/ts/README.md +++ b/ts/README.md @@ -2,6 +2,7 @@ [![npm version](https://badge.fury.io/js/%40akashnetwork%2Fakash-api.svg)](https://badge.fury.io/js/%40akashnetwork%2Fakash-api) [![License: Apache-2.0](https://img.shields.io/badge/License-apache2.0-yellow.svg)](https://opensource.org/license/apache-2-0) +[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release) This package provides TypeScript bindings for the Akash API, generated from protobuf definitions. diff --git a/ts/jest.config.js b/ts/jest.config.js index b8c1b66a..4c764f59 100644 --- a/ts/jest.config.js +++ b/ts/jest.config.js @@ -10,6 +10,7 @@ module.exports = { collectCoverageFrom: [ '/src/**/*.{js,ts}', '!/src/generated/**/*', + '!/src/patch/index.*', ], projects: [ { From 6b2f5f074076dcb89b44118b1a59c7377eca9db1 Mon Sep 17 00:00:00 2001 From: Yaroslav Grishajev Date: Mon, 15 Apr 2024 09:26:19 +0200 Subject: [PATCH 05/10] ci(ts): ensures cache is only restored once --- .github/workflows/release-ts.yaml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/.github/workflows/release-ts.yaml b/.github/workflows/release-ts.yaml index 22fe7d9e..e272854f 100644 --- a/.github/workflows/release-ts.yaml +++ b/.github/workflows/release-ts.yaml @@ -27,14 +27,6 @@ jobs: cache: npm cache-dependency-path: ts/package-lock.json - - name: Restore node_modules cache - id: deps-cache - if: steps.changes.outputs.ts == 'true' && steps.deps-cache.outputs.cache-hit != 'true' - uses: martijnhols/actions-cache/restore@v3 - with: - path: ts/node_modules - key: ${{ runner.os }}-build-ts-deps-cache-${{ hashFiles('ts/package-lock.json') }} - - name: Setup env if: steps.changes.outputs.ts == 'true' uses: HatsuneMiku3939/direnv-action@v1 @@ -56,10 +48,3 @@ jobs: files: ./ts/coverage token: ${{ secrets.CODECOV_TOKEN }} - - name: Cache node modules - if: steps.deps-cache.outputs.cache-hit != 'true' && steps.changes.outputs.ts == 'true' - uses: martijnhols/actions-cache/save@v3 - with: - path: ts/node_modules - key: ${{ runner.os }}-build-ts-deps-cache-${{ hashFiles('ts/package-lock.json') }} - From 136165c0111abeb2b7ea33229205a5ae362b386a Mon Sep 17 00:00:00 2001 From: Yaroslav Grishajev Date: Mon, 15 Apr 2024 09:27:49 +0200 Subject: [PATCH 06/10] ci(ts): adds nodejs configuration step --- .github/workflows/tests.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index a524ca10..79d4e798 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -30,6 +30,12 @@ jobs: - run: | toolchain=$(./script/tools.sh gotoolchain | sed 's/go*//') echo "GOVERSION=${toolchain}" >> $GITHUB_ENV + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20.8.1 + cache: npm + cache-dependency-path: ts/package-lock.json - uses: actions/setup-go@v5 with: go-version: "${{ env.GOVERSION }}" From b3ae94e0109fa1747557733a5ccd4bd2b97ec067 Mon Sep 17 00:00:00 2001 From: Yaroslav Grishajev Date: Mon, 15 Apr 2024 09:47:49 +0200 Subject: [PATCH 07/10] feat(ts): removes redundant release preset option --- ts/.releaserc | 1 - 1 file changed, 1 deletion(-) diff --git a/ts/.releaserc b/ts/.releaserc index f9e5135e..00db23da 100644 --- a/ts/.releaserc +++ b/ts/.releaserc @@ -21,7 +21,6 @@ } ] ], - "preset": "angular", "working_directory": "ts", "branches": [ { From e7b6431941c0f4baf17e29db2a62fda26bf28c06 Mon Sep 17 00:00:00 2001 From: Yaroslav Grishajev Date: Mon, 15 Apr 2024 10:03:47 +0200 Subject: [PATCH 08/10] chore(ts): removes unused semantic release deps --- ts/package.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/ts/package.json b/ts/package.json index 60916396..93f15ef6 100644 --- a/ts/package.json +++ b/ts/package.json @@ -5,9 +5,7 @@ }, "description": "Akash API TypeScript client", "devDependencies": { - "@semantic-release/changelog": "^6.0.3", "@semantic-release/commit-analyzer": "^12.0.0", - "@semantic-release/git": "^10.0.1", "@semantic-release/github": "^10.0.3", "@semantic-release/release-notes-generator": "^13.0.0", "@types/jest": "^29.5.12", From f945500880ab33224d1de970db93d7cddf78ef95 Mon Sep 17 00:00:00 2001 From: Yaroslav Grishajev Date: Mon, 15 Apr 2024 10:28:39 +0200 Subject: [PATCH 09/10] ci(ts): uses conventionalcommits preset --- ts/.releaserc | 1 + ts/README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ts/.releaserc b/ts/.releaserc index 00db23da..083d58ba 100644 --- a/ts/.releaserc +++ b/ts/.releaserc @@ -21,6 +21,7 @@ } ] ], + "preset": "conventionalcommits", "working_directory": "ts", "branches": [ { diff --git a/ts/README.md b/ts/README.md index 803077cb..30ce8861 100644 --- a/ts/README.md +++ b/ts/README.md @@ -2,7 +2,7 @@ [![npm version](https://badge.fury.io/js/%40akashnetwork%2Fakash-api.svg)](https://badge.fury.io/js/%40akashnetwork%2Fakash-api) [![License: Apache-2.0](https://img.shields.io/badge/License-apache2.0-yellow.svg)](https://opensource.org/license/apache-2-0) -[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release) +[![semantic-release: conventionalcommits](https://img.shields.io/badge/semantic--release-conventionalcommits?logo=semantic-release)](https://github.com/semantic-release/semantic-release) This package provides TypeScript bindings for the Akash API, generated from protobuf definitions. From fd2b045c147f1cbf67fcc7fa04db456e072adbc6 Mon Sep 17 00:00:00 2001 From: Yaroslav Grishajev Date: Mon, 15 Apr 2024 11:04:22 +0200 Subject: [PATCH 10/10] ci: cancels tests and release-ts concurrent workflows --- .github/workflows/release-ts.yaml | 4 ++++ .github/workflows/tests.yaml | 4 ++++ script/release-ts.sh | 18 +++++++++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-ts.yaml b/.github/workflows/release-ts.yaml index e272854f..df65e4bc 100644 --- a/.github/workflows/release-ts.yaml +++ b/.github/workflows/release-ts.yaml @@ -4,6 +4,10 @@ on: branches: - main +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + jobs: release: runs-on: ubuntu-latest diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 79d4e798..f68d86eb 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -5,6 +5,10 @@ on: branches: - main +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + jobs: test: runs-on: ubuntu-latest diff --git a/script/release-ts.sh b/script/release-ts.sh index 16871caa..a52187f9 100755 --- a/script/release-ts.sh +++ b/script/release-ts.sh @@ -1,4 +1,16 @@ -#!/bin/bash +#!/usr/bin/env bash + +GITHUB_REPOSITORY=${GITHUB_REPOSITORY:-$GITHUB_ACTION_REPOSITORY} + +if [ -z "$GITHUB_REPOSITORY" ]; then + echo "Error: GITHUB_REPOSITORY or GITHUB_ACTION_REPOSITORY is not set." + exit 1 +fi + +if [ -z "$GITHUB_TOKEN" ]; then + echo "Error: GITHUB_TOKEN is not set." + exit 1 +fi API_URL="https://api.github.com" @@ -8,7 +20,7 @@ log() { log "Fetching the current latest release information..." current_latest=$(curl -s -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \ - "$API_URL/repos/$GITHUB_ACTION_REPOSITORY/releases/latest") + "$API_URL/repos/$GITHUB_REPOSITORY/releases/latest") current_latest_id=$(echo "$current_latest" | jq -r '.id') if [ "$current_latest_id" == "null" ]; then @@ -30,7 +42,7 @@ fi log "Attempting to mark the release (ID: $current_latest_id) as the latest again..." update_response=$(curl -s -X PATCH -H "Authorization: token $GITHUB_TOKEN" -H "Content-Type: application/json" -H "Accept: application/vnd.github.v3+json" \ -d "{\"make_latest\": \"true\"}" \ - "$API_URL/repos/$GITHUB_ACTION_REPOSITORY/releases/$current_latest_id") + "$API_URL/repos/$GITHUB_REPOSITORY/releases/$current_latest_id") log "Update response:" echo "$update_response" | jq