From b64a34b6427c033ff0922e6bd9ddeddf3c94a682 Mon Sep 17 00:00:00 2001 From: dkijania Date: Wed, 10 Sep 2025 23:32:31 +0200 Subject: [PATCH 01/15] add release job --- .github/workflows/release.yaml | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..96d2652 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,42 @@ +--- +name: "release" + +on: + push: + tags: + - "v*" + +jobs: + release: + strategy: + matrix: + include: + - os: ubuntu-latest + arch: x64 + suffix: linux-amd64 + - os: ubuntu-latest + arch: arm64 + suffix: linux-arm64 + name: "Release for ${{ matrix.suffix }}" + runs-on: ${{ matrix.os }} + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + architecture: ${{ matrix.arch }} + - name: Install dependencies + run: npm ci + - name: Build application + run: npm run build + - name: Package application + run: npm pack + - name: Create release + uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.API_TOKEN }}" + prerelease: false + files: | + *.tgz \ No newline at end of file From d149c0862de9835d18079334f46241ad93324888 Mon Sep 17 00:00:00 2001 From: dkijania Date: Wed, 10 Sep 2025 23:36:39 +0200 Subject: [PATCH 02/15] fix arm64 runner --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 96d2652..73d7d87 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -14,7 +14,7 @@ jobs: - os: ubuntu-latest arch: x64 suffix: linux-amd64 - - os: ubuntu-latest + - os: [self-hosted, ARM64, Linux] arch: arm64 suffix: linux-arm64 name: "Release for ${{ matrix.suffix }}" From 2915c1f37302b077d0f3992cdd39c8dd049cf9a6 Mon Sep 17 00:00:00 2001 From: dkijania Date: Wed, 10 Sep 2025 23:49:22 +0200 Subject: [PATCH 03/15] fix token name --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 73d7d87..0318983 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -36,7 +36,7 @@ jobs: - name: Create release uses: "marvinpinto/action-automatic-releases@latest" with: - repo_token: "${{ secrets.API_TOKEN }}" + repo_token: "${{ secrets.GITHUB_TOKEN }}" prerelease: false files: | *.tgz \ No newline at end of file From c33efacb6109163122e4f420cb6cdfeb67e7e36f Mon Sep 17 00:00:00 2001 From: dkijania Date: Thu, 11 Sep 2025 09:32:19 +0200 Subject: [PATCH 04/15] use QEMU for arm64 --- .github/workflows/release.yaml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0318983..616ba94 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,4 +1,3 @@ ---- name: "release" on: @@ -14,7 +13,7 @@ jobs: - os: ubuntu-latest arch: x64 suffix: linux-amd64 - - os: [self-hosted, ARM64, Linux] + - os: ubuntu-latest arch: arm64 suffix: linux-arm64 name: "Release for ${{ matrix.suffix }}" @@ -22,21 +21,31 @@ jobs: steps: - name: Checkout the repository uses: actions/checkout@v4 + + # Enable QEMU for ARM builds + - name: Set up QEMU + if: matrix.arch == 'arm64' + uses: docker/setup-qemu-action@v3 + - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '18' architecture: ${{ matrix.arch }} + - name: Install dependencies run: npm ci + - name: Build application run: npm run build + - name: Package application run: npm pack + - name: Create release - uses: "marvinpinto/action-automatic-releases@latest" + uses: marvinpinto/action-automatic-releases@latest with: repo_token: "${{ secrets.GITHUB_TOKEN }}" prerelease: false files: | - *.tgz \ No newline at end of file + *.tgz From 10bddef001d4558a121ca9d00ac029e262d0694b Mon Sep 17 00:00:00 2001 From: dkijania Date: Thu, 11 Sep 2025 09:45:23 +0200 Subject: [PATCH 05/15] fix arm64 again --- .github/workflows/release.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 616ba94..0d6e0cc 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -23,10 +23,14 @@ jobs: uses: actions/checkout@v4 # Enable QEMU for ARM builds - - name: Set up QEMU + - name: Build in ARM64 Docker container if: matrix.arch == 'arm64' - uses: docker/setup-qemu-action@v3 - + run: | + docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace node:18-bullseye bash -c " + npm ci && + npm run build && + npm pack + " - name: Setup Node.js uses: actions/setup-node@v4 with: From 8af6f5685ab104a88b23cca54bef041884ce2cf7 Mon Sep 17 00:00:00 2001 From: dkijania Date: Thu, 11 Sep 2025 10:02:15 +0200 Subject: [PATCH 06/15] more if else logic --- .github/workflows/release.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0d6e0cc..ab25256 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -22,7 +22,7 @@ jobs: - name: Checkout the repository uses: actions/checkout@v4 - # Enable QEMU for ARM builds + # ARM64 build in Docker - name: Build in ARM64 Docker container if: matrix.arch == 'arm64' run: | @@ -31,19 +31,25 @@ jobs: npm run build && npm pack " + + # x64 steps only - name: Setup Node.js + if: matrix.arch == 'x64' uses: actions/setup-node@v4 with: node-version: '18' architecture: ${{ matrix.arch }} - name: Install dependencies + if: matrix.arch == 'x64' run: npm ci - name: Build application + if: matrix.arch == 'x64' run: npm run build - name: Package application + if: matrix.arch == 'x64' run: npm pack - name: Create release @@ -52,4 +58,4 @@ jobs: repo_token: "${{ secrets.GITHUB_TOKEN }}" prerelease: false files: | - *.tgz + *.tgz \ No newline at end of file From f571246707fbd363669f5b32ff0ca14ba2e4abed Mon Sep 17 00:00:00 2001 From: dkijania Date: Thu, 11 Sep 2025 10:06:55 +0200 Subject: [PATCH 07/15] add suffix for amd64 or arm64 release --- .github/workflows/release.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ab25256..d26fe59 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -52,10 +52,18 @@ jobs: if: matrix.arch == 'x64' run: npm pack + - name: Rename package with suffix + run: | + for file in *.tgz; do + if [ -f "$file" ]; then + mv "$file" "${file%.tgz}-${{ matrix.suffix }}.tgz" + fi + done + - name: Create release uses: marvinpinto/action-automatic-releases@latest with: repo_token: "${{ secrets.GITHUB_TOKEN }}" prerelease: false files: | - *.tgz \ No newline at end of file + *-${{ matrix.suffix }}.tgz \ No newline at end of file From 0b9fe8b3f72aae3fb175fb1bb7a05d8881ab5f55 Mon Sep 17 00:00:00 2001 From: dkijania Date: Thu, 11 Sep 2025 11:55:51 +0200 Subject: [PATCH 08/15] only one job should create release --- .github/workflows/release.yaml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d26fe59..d78ce9f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -60,10 +60,18 @@ jobs: fi done - - name: Create release + # Only one job creates the release + - name: Create Release + if: matrix.arch == 'amd64' uses: marvinpinto/action-automatic-releases@latest with: repo_token: "${{ secrets.GITHUB_TOKEN }}" prerelease: false files: | - *-${{ matrix.suffix }}.tgz \ No newline at end of file + *-${{ matrix.suffix }}.tgz + + # All jobs upload their binaries + - name: Upload Release Asset + run: gh release upload v0.0.1 *-${{ matrix.suffix }}.tgz + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 158fa5f515dfeab41a8a4a269778f274c6e2c7e8 Mon Sep 17 00:00:00 2001 From: dkijania Date: Thu, 11 Sep 2025 12:40:15 +0200 Subject: [PATCH 09/15] fix amd64 suffix -> x64 --- .github/workflows/release.yaml | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d78ce9f..0bcd756 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -32,25 +32,18 @@ jobs: npm pack " - # x64 steps only - - name: Setup Node.js + # x64 build steps + - name: Build and package for x64 if: matrix.arch == 'x64' uses: actions/setup-node@v4 with: node-version: '18' architecture: ${{ matrix.arch }} - - - name: Install dependencies - if: matrix.arch == 'x64' - run: npm ci - - - name: Build application + - run: | + npm ci + npm run build + npm pack if: matrix.arch == 'x64' - run: npm run build - - - name: Package application - if: matrix.arch == 'x64' - run: npm pack - name: Rename package with suffix run: | @@ -62,7 +55,7 @@ jobs: # Only one job creates the release - name: Create Release - if: matrix.arch == 'amd64' + if: matrix.arch == 'x64' uses: marvinpinto/action-automatic-releases@latest with: repo_token: "${{ secrets.GITHUB_TOKEN }}" From f4e015fad754f09231e683c56934806f80938842 Mon Sep 17 00:00:00 2001 From: dkijania Date: Thu, 11 Sep 2025 13:10:00 +0200 Subject: [PATCH 10/15] do not upload asset when it's x64 --- .github/workflows/release.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0bcd756..5e03f0b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -63,8 +63,9 @@ jobs: files: | *-${{ matrix.suffix }}.tgz - # All jobs upload their binaries + # Other jobs upload their binaries to existing release - name: Upload Release Asset + if: matrix.arch != 'x64' run: gh release upload v0.0.1 *-${{ matrix.suffix }}.tgz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 4398e5d4b3f31b362b2092d0ea8ccc9e3fd5a984 Mon Sep 17 00:00:00 2001 From: dkijania Date: Thu, 11 Sep 2025 17:16:20 +0200 Subject: [PATCH 11/15] use ref_name instead of hardcoded tag version --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 5e03f0b..37c4b49 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -66,6 +66,6 @@ jobs: # Other jobs upload their binaries to existing release - name: Upload Release Asset if: matrix.arch != 'x64' - run: gh release upload v0.0.1 *-${{ matrix.suffix }}.tgz + run: gh release upload ${{ github.ref_name }} *-${{ matrix.suffix }}.tgz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From c99e9612e9b6ce50a5faa3e96c795fc6f776118e Mon Sep 17 00:00:00 2001 From: dkijania Date: Thu, 11 Sep 2025 18:52:19 +0200 Subject: [PATCH 12/15] use different approach without matrix --- .github/workflows/release.yaml | 67 +++++++++++++++++----------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 37c4b49..919b2fc 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -6,66 +6,65 @@ on: - "v*" jobs: - release: - strategy: - matrix: - include: - - os: ubuntu-latest - arch: x64 - suffix: linux-amd64 - - os: ubuntu-latest - arch: arm64 - suffix: linux-arm64 - name: "Release for ${{ matrix.suffix }}" - runs-on: ${{ matrix.os }} + build-x64: + name: "Release for linux-amd64" + runs-on: ubuntu-latest steps: - name: Checkout the repository uses: actions/checkout@v4 - # ARM64 build in Docker - - name: Build in ARM64 Docker container - if: matrix.arch == 'arm64' - run: | - docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace node:18-bullseye bash -c " - npm ci && - npm run build && - npm pack - " - - # x64 build steps - - name: Build and package for x64 - if: matrix.arch == 'x64' + - name: Set up Node uses: actions/setup-node@v4 with: node-version: '18' - architecture: ${{ matrix.arch }} + architecture: x64 + - run: | npm ci npm run build npm pack - if: matrix.arch == 'x64' - name: Rename package with suffix run: | for file in *.tgz; do if [ -f "$file" ]; then - mv "$file" "${file%.tgz}-${{ matrix.suffix }}.tgz" + mv "$file" "${file%.tgz}-linux-amd64.tgz" fi done - # Only one job creates the release - name: Create Release - if: matrix.arch == 'x64' uses: marvinpinto/action-automatic-releases@latest with: repo_token: "${{ secrets.GITHUB_TOKEN }}" prerelease: false files: | - *-${{ matrix.suffix }}.tgz + *-linux-amd64.tgz + + build-arm64: + name: "Release for linux-arm64" + runs-on: ubuntu-latest + needs: build-x64 + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + + - name: Build in ARM64 Docker container + run: | + docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace node:18-bullseye bash -c " + npm ci && + npm run build && + npm pack + " + + - name: Rename package with suffix + run: | + for file in *.tgz; do + if [ -f "$file" ]; then + mv "$file" "${file%.tgz}-linux-arm64.tgz" + fi + done - # Other jobs upload their binaries to existing release - name: Upload Release Asset - if: matrix.arch != 'x64' - run: gh release upload ${{ github.ref_name }} *-${{ matrix.suffix }}.tgz + run: gh release upload ${{ github.ref_name }} *-linux-arm64.tgz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From a06a559544765ff32b8b21e4de7951db578b05f2 Mon Sep 17 00:00:00 2001 From: dkijania Date: Fri, 12 Sep 2025 23:13:03 +0200 Subject: [PATCH 13/15] making binary --- package.json | 4 +++- src/index.ts | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index ed0074b..55a3e5d 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,9 @@ "url": "https://github.com/o1-labs/Archive-Node-API" }, "main": "build/src/index.js", - "start": "build/src/index.js", + "bin": { + "archive-node-api": "build/src/index.js" + }, "type": "module", "scripts": { "build": "npm run clean && npx tsc", diff --git a/src/index.ts b/src/index.ts index 93efa70..29904b3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,4 @@ +#!/usr/bin/env node import * as dotenv from 'dotenv'; dotenv.config(); From 26536fd7fa288831659b9401ef261844315c00f5 Mon Sep 17 00:00:00 2001 From: dkijania Date: Sat, 13 Sep 2025 21:01:55 +0200 Subject: [PATCH 14/15] fix package.json --- .github/workflows/release.yaml | 17 ++++++++++++++--- package.json | 4 ++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 919b2fc..f06702d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -16,7 +16,7 @@ jobs: - name: Set up Node uses: actions/setup-node@v4 with: - node-version: '18' + node-version: '20' architecture: x64 - run: | @@ -24,6 +24,13 @@ jobs: npm run build npm pack + - name: Verify package contents + run: | + echo "Verifying package contains required files..." + tar -tzf *.tgz | grep "package/build/src/context.js" || (echo "ERROR: context.js not found in package" && exit 1) + tar -tzf *.tgz | grep "package/build/src/index.js" || (echo "ERROR: index.js not found in package" && exit 1) + echo "Package verification successful" + - name: Rename package with suffix run: | for file in *.tgz; do @@ -50,10 +57,14 @@ jobs: - name: Build in ARM64 Docker container run: | - docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace node:18-bullseye bash -c " + docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace node:20-bullseye bash -c " npm ci && npm run build && - npm pack + npm pack && + echo 'Verifying package contents...' && + tar -tzf *.tgz | grep 'package/build/src/context.js' || (echo 'ERROR: context.js not found in package' && exit 1) && + tar -tzf *.tgz | grep 'package/build/src/index.js' || (echo 'ERROR: index.js not found in package' && exit 1) && + echo 'Package verification successful' " - name: Rename package with suffix diff --git a/package.json b/package.json index 55a3e5d..b7276db 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,10 @@ "archive-node-api": "build/src/index.js" }, "type": "module", + "files": [ + "build/**/*", + "schema.graphql" + ], "scripts": { "build": "npm run clean && npx tsc", "start": "node build/src/index.js", From 3ea5c6f23ae47a0951921cb672b86e344a296382 Mon Sep 17 00:00:00 2001 From: dkijania Date: Sat, 13 Sep 2025 21:09:48 +0200 Subject: [PATCH 15/15] fix paths to graphql --- src/resolvers.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/resolvers.ts b/src/resolvers.ts index 6052eef..c2315b1 100644 --- a/src/resolvers.ts +++ b/src/resolvers.ts @@ -1,6 +1,8 @@ import { makeExecutableSchema } from '@graphql-tools/schema'; import { loadSchemaSync } from '@graphql-tools/load'; import { GraphQLFileLoader } from '@graphql-tools/graphql-file-loader'; +import { fileURLToPath } from 'url'; +import { dirname, join } from 'path'; import { Resolvers } from './resolvers-types.js'; import { @@ -45,9 +47,16 @@ const resolvers: Resolvers = { }, }; +// Get the directory containing this module file +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +// Resolve schema.graphql relative to the package root (two levels up from build/src/) +const schemaPath = join(__dirname, '..', '..', 'schema.graphql'); + const schema = makeExecutableSchema({ resolvers: [resolvers], - typeDefs: loadSchemaSync('./schema.graphql', { + typeDefs: loadSchemaSync(schemaPath, { loaders: [new GraphQLFileLoader()], }), });