diff --git a/.github/workflows/plugin-deploy.yml b/.github/workflows/plugin-deploy.yml new file mode 100644 index 00000000000..b981568b991 --- /dev/null +++ b/.github/workflows/plugin-deploy.yml @@ -0,0 +1,36 @@ +name: VSCode Plugin Deploy + +on: + workflow_dispatch: + inputs: + release-type: + description: "Release Type" + type: choice + default: "canary" + required: true + options: + - canary + - production + +jobs: + deploy: + name: Canary Deploy + runs-on: ubuntu-latest + steps: + - name: Set up node (16) + uses: actions/setup-node@v3 + with: + node-version: 16.x + - name: Checkout current branch (with history) + uses: actions/checkout@master + - name: Install top level + run: npm install + - name: Bump version and package the plugin for Monospace + run: | + cd firebase-vscode + npm install + npm run pkg:monospace + - name: Upload to GCS + run: #TODO + + \ No newline at end of file diff --git a/firebase-vscode/package.json b/firebase-vscode/package.json index 9b963dd7103..2b621aa4100 100644 --- a/firebase-vscode/package.json +++ b/firebase-vscode/package.json @@ -3,7 +3,7 @@ "displayName": "firebase-vscode", "publisher": "firebase", "description": "VSCode Extension for Firebase", - "version": "0.0.24-alpha.1", + "version": "0.0.25-alpha.8e3e2161", "engines": { "vscode": "^1.69.0" }, @@ -85,8 +85,8 @@ "scripts": { "vscode:prepublish": "npm run build", "copyfiles": "cp -r node_modules/@vscode/codicons/dist resources/dist", - "pkg:vsce": "node scripts/swap-pkg.js vsce && vsce package", - "pkg:monospace": "node scripts/swap-pkg.js monospace && vsce package", + "pkg:vsce": "node scripts/swap-pkg.js --platform vsce && vsce package", + "pkg:monospace": "node scripts/swap-pkg.js --platform monospace && vsce package", "dev": "npm run copyfiles && webpack --config webpack.dev.js", "dev:extension": "npm run copyfiles && webpack --config webpack.dev.js --config-name extension", "dev:sidebar": "npm run copyfiles && webpack --config webpack.dev.js --config-name sidebar", @@ -134,4 +134,4 @@ "webpack-cli": "^5.0.1", "webpack-merge": "^5.8.0" } -} \ No newline at end of file +} diff --git a/firebase-vscode/scripts/bump-version.js b/firebase-vscode/scripts/bump-version.js new file mode 100644 index 00000000000..932c74b02f0 --- /dev/null +++ b/firebase-vscode/scripts/bump-version.js @@ -0,0 +1,24 @@ +const { writeFileSync } = require("fs"); +const { execSync } = require("child_process"); +const path = require("path"); +const { argv } = require("yargs"); +const semver = require("semver"); +const pkg = require(path.join(__dirname, "../package.json")); + +const releaseType = argv['release-type']; + +const currentVersion = pkg.version; + +if (releaseType === 'canary') { + const nextPatchVersion = semver.inc(currentVersion, 'patch'); + const headSha = execSync('git rev-parse --short HEAD').toString().trim(); + // Should we use sha or timestamp? Does sha read as always incrementing? + // Pros: sha lets you trace back to the exact commit + pkg.version = `${nextPatchVersion}-alpha.${headSha}`; + + writeFileSync( + path.join(__dirname, "../package.json"), + JSON.stringify(pkg, null, 2), + { encoding: "utf8" } + ); +} diff --git a/firebase-vscode/scripts/swap-pkg.js b/firebase-vscode/scripts/swap-pkg.js index 92f68fce843..d77b86d590e 100644 --- a/firebase-vscode/scripts/swap-pkg.js +++ b/firebase-vscode/scripts/swap-pkg.js @@ -1,5 +1,8 @@ const { writeFileSync } = require("fs"); +const { execSync } = require("child_process"); const path = require("path"); +const { argv } = require("yargs"); +const semver = require("semver"); const pkg = require(path.join(__dirname, "../package.json")); // Swaps package.json config as appropriate for packaging for @@ -9,15 +12,26 @@ const pkg = require(path.join(__dirname, "../package.json")); // create a generated one in dist/ - redo .vscodeignore to package // dist/ -let target = "vsce"; +const releaseType = argv['release-type']; +const platform = argv.platform; -process.argv.forEach((arg) => { - if (arg === "vsce" || arg === "monospace") { - target = arg; - } -}); +const currentVersion = pkg.version; -if (target === "vsce") { +if (releaseType === 'canary') { + const nextPatchVersion = semver.inc(currentVersion, 'patch'); + const headSha = execSync('git rev-parse --short HEAD').toString().trim(); + // Should we use sha or timestamp? Does sha read as always incrementing? + // Pros: sha lets you trace back to the exact commit + pkg.version = `${nextPatchVersion}-alpha.${headSha}`; + + writeFileSync( + path.join(__dirname, "../package.json"), + JSON.stringify(pkg, null, 2), + { encoding: "utf8" } + ); +} + +if (platform === "vsce") { delete pkg.extensionDependencies; console.log( "Removing google.monospace extensionDependency for VSCE packaging." @@ -27,7 +41,7 @@ if (target === "vsce") { console.log( "Setting default debug log settings to off for VSCE packaging." ); -} else if (target === "monospace") { +} else if (platform === "monospace") { pkg.extensionDependencies = ["google.monospace"]; console.log( "Adding google.monospace extensionDependency for Monospace packaging."