Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 23 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
# - src/**
# - bin/**
# - yarn.lock

permissions:
id-token: write # Required for OIDC
contents: write
actions: write

jobs:
build-publish:
name: Build & publish
Expand All @@ -31,12 +35,13 @@
access_token: ${{ github.token }}

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install node
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 22
registry-url: 'https://registry.npmjs.org'

- name: Install Yarn
run: corepack enable
Expand All @@ -48,24 +53,29 @@
with:
cache: yarn

- name: Write npm credentials
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" >> .npmrc
npm whoami
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}


- name: Install
run: yarn install --immutable

- name: Build
run: yarn build

- name: Update npm
run: npm install -g npm@latest

- name: Release
run: npm publish --tag ${{ github.event.inputs.tag }} --access public
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

- name: Get version
id: package-version
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT

- name: Create GitHub Release
uses: softprops/action-gh-release@v2

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'Release' step
Uses Step
uses 'softprops/action-gh-release' with ref 'v2', not a pinned commit hash
with:
tag_name: v${{ steps.package-version.outputs.version }}
name: v${{ steps.package-version.outputs.version }}
generate_release_notes: true
prerelease: ${{ github.event.inputs.tag != 'latest' }}

# - name: Build packages
# run: |
Expand Down
2 changes: 1 addition & 1 deletion bin/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
(async () => {
const oclif = await import('@oclif/core')
await oclif.execute({development: false, dir: __dirname})
})()
})()
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"name": "@subsquid/cli",
"description": "squid cli tool",
"version": "3.2.3",
"version": "3.3.0",
"license": "GPL-3.0-or-later",
"repository": "git@github.com:subsquid/squid-cli.git",
"repository": {
"type": "git",
"url": "git+https://github.com/subsquid/squid-cli.git"
},
"publishConfig": {
"access": "public"
},
Expand Down
32 changes: 32 additions & 0 deletions src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,14 @@ export default class Deploy extends DeployCommand {
if (!update) return;
}

/**
* Warn if the existing squid has a Postgres addon but the new manifest removes it
*/
if (!hardReset && target?.addons?.postgres && !manifest.deploy?.addons?.postgres) {
const confirmed = await this.promptPostgresDeletion(target, { interactive });
if (!confirmed) return;
}

/**
* Squid exists we should check if tag belongs to another squid
*/
Expand Down Expand Up @@ -374,6 +382,30 @@ export default class Deploy extends DeployCommand {
return !!confirm;
}

private async promptPostgresDeletion(
squid: Squid,
{ using = 'using "--allow-postgres-deletion" flag', interactive }: { using?: string; interactive?: boolean } = {},
) {
const warning = `The new manifest does not include "addons.postgres", but the squid ${printSquid(squid)} currently has a Postgres database. Deploying will permanently delete the database and all its data.`;

if (!interactive) {
this.error([warning, `Please do it explicitly ${using}`].join('\n'));
}

this.warn(warning);

const { confirm } = await inquirer.prompt([
{
name: 'confirm',
type: 'confirm',
message: 'Are you sure you want to continue?',
prefix: `The Postgres database will be permanently deleted.`,
},
]);

return !!confirm;
}

private async promptSquidName(
name?: string | null | undefined,
{ using = 'using "--name" flag', interactive }: { using?: string; interactive?: boolean } = {},
Expand Down
Loading