Skip to content

Commit

Permalink
Merge branch 'start-stop-protocol' of github.com:unlock-protocol/unlo…
Browse files Browse the repository at this point in the history
…ck into start-stop-protocol
  • Loading branch information
clemsos committed Mar 22, 2024
2 parents 29c784b + 8defe75 commit 7e4c98a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/_subgraph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
node-version: 20
- run: yarn
- run: yarn build
- name: Prepare the network files
run: yarn workspace @unlock-protocol/subgraph prepare
- name: Deploying the subgraphs
run: cd subgraph && yarn deploy-all
run: yarn workspace @unlock-protocol/subgraph deploy-all
shell: bash
2 changes: 1 addition & 1 deletion locksmith/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"p-retry": "6.0.0",
"path-to-regexp": "6.2.1",
"pg": "8.11.3",
"rate-limiter-flexible": "4.0.1",
"rate-limiter-flexible": "5.0.0",
"react": "18.2.0",
"remark-html": "15.0.2",
"remark-parse": "10.0.2",
Expand Down
30 changes: 15 additions & 15 deletions subgraph/bin/thegraph
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,27 @@ const executeCommand = async (command) => {
}
}

const incrementVersion = (version) => {
const [_, major, minor, patch] = version.match(
/v([0-9]*)\.([0-9]*)\.([0-9]*)/
)
return `v${major}.${minor}.${parseInt(patch) + 1}`
// use shorthand of git sha commit as version label
const getVersion = () => {
const gitSha = require('child_process')
.execSync('git rev-parse --short HEAD')
.toString()
.trim()
return `${gitSha}`
}

const executeStudioDeployWithVersionIncrement = async ({
const executeStudioDeploy = async ({
subgraphName,
version = 'v0.0.1', // TODO: fetch latest version
version,
flags = '--product=subgraph-studio',
}) => {
const cmd = `graph deploy --version-label="${version}" ${flags} ${subgraphName}`
let stderr = await executeCommand(cmd)
if (stderr) {
if (stderr.includes(`Version label already exists`)) {
const nextVersion = incrementVersion(version)
console.log(
`Studio version for ${subgraphName} exists - attempting deploy with version - ${nextVersion}`
`Studio version '${version}' for ${subgraphName} exists - skipping`
)
return executeStudioDeployWithVersionIncrement({
subgraphName,
version: nextVersion,
})
}
}
}
Expand Down Expand Up @@ -82,7 +79,10 @@ const deployStudio = async (subgraphName, version) => {
await executeCommand(
`graph auth --studio ${process.env.SUBGRAPH_STUDIO_DEPLOY_KEY}`
)
return executeStudioDeployWithVersionIncrement({ subgraphName, version })
if (!version) {
version = getVersion()
}
return executeStudioDeploy({ subgraphName, version })
}

/**
Expand All @@ -102,7 +102,7 @@ const deploy = async (network, studioName, graphLabel) => {
}

if (!studioName) {
; ({ studioName } = networks[network].subgraph)
;({ studioName } = networks[network].subgraph)
}

if (!studioName) {
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -20020,7 +20020,7 @@ __metadata:
parse-data-uri: "npm:0.2.0"
path-to-regexp: "npm:6.2.1"
pg: "npm:8.11.3"
rate-limiter-flexible: "npm:4.0.1"
rate-limiter-flexible: "npm:5.0.0"
react: "npm:18.2.0"
remark-html: "npm:15.0.2"
remark-parse: "npm:10.0.2"
Expand Down Expand Up @@ -45928,10 +45928,10 @@ __metadata:
languageName: node
linkType: hard

"rate-limiter-flexible@npm:4.0.1":
version: 4.0.1
resolution: "rate-limiter-flexible@npm:4.0.1"
checksum: 10/c86b9b188396af3e030eb6f0ab95483057cbdf2480612a95a4fa660401b6daea2960b3155c7cd2f77e3ded3bc97163bb7513ea9ec21bfac7c128dfb5221ff800
"rate-limiter-flexible@npm:5.0.0":
version: 5.0.0
resolution: "rate-limiter-flexible@npm:5.0.0"
checksum: 10/66d254f47bd68639c65e4ee567a8fe6d6cbee9222e69eb191ed5a2a92e7a65bb152afe238d74c2c5a530afdae4461e520cd819484c95be6627dd051c84866bc6
languageName: node
linkType: hard

Expand Down

0 comments on commit 7e4c98a

Please sign in to comment.