diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 07c6894..5348462 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,11 @@ on: # - src/** # - bin/** # - yarn.lock - +permissions: + id-token: write # Required for OIDC + contents: write + actions: write + jobs: build-publish: name: Build & publish @@ -31,12 +35,13 @@ jobs: 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 @@ -48,24 +53,29 @@ jobs: 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 + 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: | diff --git a/bin/run.js b/bin/run.js index 894a370..405685d 100755 --- a/bin/run.js +++ b/bin/run.js @@ -4,4 +4,4 @@ (async () => { const oclif = await import('@oclif/core') await oclif.execute({development: false, dir: __dirname}) -})() \ No newline at end of file +})() diff --git a/package.json b/package.json index 7767916..58ee351 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/src/commands/deploy.ts b/src/commands/deploy.ts index b41721b..b55006a 100644 --- a/src/commands/deploy.ts +++ b/src/commands/deploy.ts @@ -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 */ @@ -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 } = {},