Skip to content

Commit

Permalink
ci: fetch latest contract version from soldeer
Browse files Browse the repository at this point in the history
  • Loading branch information
sripwoud committed Jul 8, 2024
1 parent bc87691 commit 1ab7aa8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions scripts/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import contractsPkgJson from "@semaphore-protocol/contracts/package.json"

const { version: contractsLocalVersion } = contractsPkgJson

async function getContractsLatestPublishedVersion() {
const response = await fetch("https://registry.npmjs.org/@semaphore-protocol/contracts")
const data = await response.json()
return data["dist-tags"].latest
}

async function maybePushToSoldeer() {
const contractsLatestPublishedVersion = await getContractsLatestPublishedVersion()
if (compare(contractsLocalVersion, contractsLatestPublishedVersion) === 1)
// api not documented, may change, found by inspecting the network tab
const response = await fetch(
"https://api.soldeer.xyz/api/v1/revision?project_name=semaphore-protocol-contracts&limit=1"
)
const { data, status } = await response.json()

// fail status is no version published at all yet
if (status === "fail" || compare(contractsLocalVersion, data[0].version) === 1)
await execa(
"soldeer",
["push", `semaphore-protocol-contracts~${contractsLocalVersion}`, "packages/contracts/contracts"],
Expand Down

0 comments on commit 1ab7aa8

Please sign in to comment.