mirror of
https://github.com/semaphore-protocol/semaphore.git
synced 2026-01-09 06:38:04 -05:00
* fix(ci): publish pkg if no releases yet * chore(ci): add workflow release trigger * fix: workflow dispatch instead of workflow release
40 lines
1.3 KiB
TypeScript
Executable File
40 lines
1.3 KiB
TypeScript
Executable File
#!/usr/bin/env ts-node
|
|
import compare from "semver/functions/compare"
|
|
import { execSync } from "child_process"
|
|
import contractsPkgJson from "@semaphore-protocol/contracts/package.json"
|
|
|
|
const { version: contractsLocalVersion } = contractsPkgJson
|
|
|
|
async function maybePushToSoldeer() {
|
|
// 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 } = await response.json()
|
|
|
|
if (
|
|
data.length === 0 || // data = [] if no version has ever been published yet
|
|
compare(contractsLocalVersion, data[0].version) === 1
|
|
)
|
|
execSync(`soldeer push semaphore-protocol-contracts~${contractsLocalVersion} packages/contracts/contracts`, {
|
|
stdio: "inherit"
|
|
})
|
|
}
|
|
|
|
async function main() {
|
|
execSync(`yarn build:libraries`, { stdio: "inherit" })
|
|
execSync(`yarn clean:cli-templates`)
|
|
execSync(`yarn workspaces foreach -A --no-private npm publish --tolerate-republish --access public`, {
|
|
stdio: "inherit"
|
|
})
|
|
|
|
await maybePushToSoldeer()
|
|
}
|
|
|
|
main()
|
|
.then(() => process.exit(0))
|
|
.catch((error) => {
|
|
console.error(error)
|
|
process.exit(1)
|
|
})
|