From af7229990114a1c615eec790f5c0ed0f0a1ad5a0 Mon Sep 17 00:00:00 2001 From: Dargon789 <64915515+Dargon789@users.noreply.github.com> Date: Sat, 27 Dec 2025 02:50:29 +0700 Subject: [PATCH 1/4] Add workflow to publish package distributions Signed-off-by: Dargon789 <64915515+Dargon789@users.noreply.github.com> --- .github/workflows/Publish-Dists.yml | 88 +++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .github/workflows/Publish-Dists.yml diff --git a/.github/workflows/Publish-Dists.yml b/.github/workflows/Publish-Dists.yml new file mode 100644 index 000000000..fd4bb7905 --- /dev/null +++ b/.github/workflows/Publish-Dists.yml @@ -0,0 +1,88 @@ +name: Publish Dists for Packages + +on: + workflow_dispatch: + push: + branches: + - master + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: ./.github/actions/install-dependencies + + - name: Build package + run: pnpm run build + + - name: Prepare dist branch + run: | + PACKAGES=("services/guard" "services/identity-instrument" "services/relayer" "wallet/core" "wallet/primitives" "wallet/wdk" "wallet/dapp-client") + + for PACKAGE in "${PACKAGES[@]}"; do + BRANCH="dists/$PACKAGE" + PKG_DIR="packages/$PACKAGE" + + echo "📦 Publishing $PACKAGE to $BRANCH" + + mkdir -p /tmp/$PACKAGE + shopt -s dotglob + cp -r $PKG_DIR/* /tmp/$PACKAGE || true + + cd /tmp/$PACKAGE + git init + git checkout -b $BRANCH + + git config user.name "github-actions" + git config user.email "actions@github.com" + + echo "🔧 Rewriting workspace: deps in package.json..." + node -e ' + const fs = require("fs"); + const path = require("path"); + const pkgPath = path.resolve("package.json"); + const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8")); + const repo = "github:0xsequence/sequence.js"; + + const versions = { + "@0xsequence/guard": `${repo}#dists/services/guard`, + "@0xsequence/identity-instrument": `${repo}#dists/services/identity-instrument`, + "@0xsequence/relayer": `${repo}#dists/services/relayer`, + "@0xsequence/wallet-core": `${repo}#dists/wallet/core`, + "@0xsequence/wallet-primitives": `${repo}#dists/wallet/primitives`, + "@0xsequence/wallet-wdk": `${repo}#dists/wallet/wdk`, + }; + + const rewrite = (deps = {}) => { + for (const k in deps) { + if (deps[k].startsWith("workspace:")) { + const version = versions[k]; + + if (!version) { + console.warn(`No version found for ${k}, skipping...`); + continue; + } + + deps[k] = version; + console.log(`→ ${k} → ${deps[k]}`); + } + } + }; + + rewrite(pkg.dependencies); + fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2)); + ' + + git add . + git commit -m "Build: publish $PACKAGE dist" + + git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git + git push -f origin HEAD:$BRANCH + + cd - + done From 3084a54df694ca034cd8575a621e132e99e5f8c4 Mon Sep 17 00:00:00 2001 From: Dargon789 <64915515+Dargon789@users.noreply.github.com> Date: Sat, 27 Dec 2025 02:52:33 +0700 Subject: [PATCH 2/4] Potential fix for code scanning alert no. 107: Workflow does not contain permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Dargon789 <64915515+Dargon789@users.noreply.github.com> --- .github/workflows/Publish-Dists.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/Publish-Dists.yml b/.github/workflows/Publish-Dists.yml index fd4bb7905..b8fd53b96 100644 --- a/.github/workflows/Publish-Dists.yml +++ b/.github/workflows/Publish-Dists.yml @@ -1,5 +1,8 @@ name: Publish Dists for Packages +permissions: + contents: write + on: workflow_dispatch: push: From 81bd07f3261ccd7b3b0d375a141f54071b867775 Mon Sep 17 00:00:00 2001 From: Dargon789 <64915515+Dargon789@users.noreply.github.com> Date: Sat, 27 Dec 2025 02:53:42 +0700 Subject: [PATCH 3/4] Update .github/workflows/Publish-Dists.yml Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> Signed-off-by: Dargon789 <64915515+Dargon789@users.noreply.github.com> --- .github/workflows/Publish-Dists.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Publish-Dists.yml b/.github/workflows/Publish-Dists.yml index b8fd53b96..ec69d6865 100644 --- a/.github/workflows/Publish-Dists.yml +++ b/.github/workflows/Publish-Dists.yml @@ -33,9 +33,8 @@ jobs: echo "📦 Publishing $PACKAGE to $BRANCH" - mkdir -p /tmp/$PACKAGE - shopt -s dotglob - cp -r $PKG_DIR/* /tmp/$PACKAGE || true + mkdir -p "/tmp/$PACKAGE" + cp -r "$PKG_DIR"/. "/tmp/$PACKAGE" || true cd /tmp/$PACKAGE git init From e8f87127792a091a907920f5deb5a73978375ad1 Mon Sep 17 00:00:00 2001 From: Dargon789 <64915515+Dargon789@users.noreply.github.com> Date: Sat, 27 Dec 2025 02:54:24 +0700 Subject: [PATCH 4/4] Update .github/workflows/Publish-Dists.yml Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> Signed-off-by: Dargon789 <64915515+Dargon789@users.noreply.github.com> --- .github/workflows/Publish-Dists.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Publish-Dists.yml b/.github/workflows/Publish-Dists.yml index ec69d6865..59b761d5a 100644 --- a/.github/workflows/Publish-Dists.yml +++ b/.github/workflows/Publish-Dists.yml @@ -76,7 +76,11 @@ jobs: } }; - rewrite(pkg.dependencies); + ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'].forEach((field) => { + if (pkg[field]) { + rewrite(pkg[field]); + } + }); fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2)); '