Skip to content

Commit

Permalink
Start on canary deploy workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubox76 committed Jul 24, 2023
1 parent 8e3e216 commit 3ff6db5
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 12 deletions.
36 changes: 36 additions & 0 deletions .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


8 changes: 4 additions & 4 deletions firebase-vscode/package.json
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -134,4 +134,4 @@
"webpack-cli": "^5.0.1",
"webpack-merge": "^5.8.0"
}
}
}
24 changes: 24 additions & 0 deletions 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" }
);
}
30 changes: 22 additions & 8 deletions 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
Expand All @@ -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."
Expand All @@ -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."
Expand Down

0 comments on commit 3ff6db5

Please sign in to comment.