Skip to content

Commit

Permalink
More automation for releases
Browse files Browse the repository at this point in the history
* Semi-automated release process for QA, Prod, and Standalone builds
* Fixes a bug with standalone builds
  • Loading branch information
calebegg committed Mar 19, 2017
1 parent 91e290e commit 874919f
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 14 deletions.
5 changes: 3 additions & 2 deletions .firebaserc
@@ -1,5 +1,6 @@
{
"projects": {
"prod": "codewich-9c316"
"prod": "codewich-9c316",
"qa": "codewich-qa"
}
}
}
2 changes: 1 addition & 1 deletion firebase.json
@@ -1,6 +1,6 @@
{
"hosting": {
"public": "build/prod",
"public": "build/deploy",
"headers": [{
"source" : "**/*.@(js|css|svg)",
"headers" : [{
Expand Down
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -18,6 +18,7 @@
"@types/jasmine": "^2.5.43",
"concurrently": "^3.4.0",
"firebase-tools": "^3.5.0",
"github": "^9.2.0",
"handlebars-cmd": "^0.1.4",
"jasmine": "^2.5.3",
"jasmine-core": "^2.5.2",
Expand All @@ -28,6 +29,7 @@
"karma-phantomjs-launcher": "^1.0.4",
"karma-requirejs": "^1.1.0",
"live-server": "^1.2.0",
"semver": "^5.3.0",
"tslint": "^4.5.1",
"typescript": "next",
"uglify-js-harmony": "^2.7.5"
Expand Down
58 changes: 58 additions & 0 deletions release.js
@@ -0,0 +1,58 @@
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

const GitHubApi = require("github");
const semver = require('semver')

async function main() {
const github = new GitHubApi();
const owner = 'calebegg', repo = 'codewich';

github.authenticate({
type: 'basic',
username: 'calebegg',
password: process.env.GITHUB_AUTH_TOKEN,
});

const latest = await github.repos.getLatestRelease({
owner, repo,
});

let {tag_name} = latest.data;

tag_name = semver.inc(tag_name, 'minor');

let newRelease = await github.repos.createRelease({
owner, repo,
tag_name,
name: `Codewich ${tag_name}`,
body: '_This release was created automatically by a script._',
draft: true,
});

await github.repos.uploadAsset({
owner, repo,
id: newRelease.data.id,
filePath: 'build/codewich.zip',
name: 'codewich.zip',
});

console.log(`Release created successfully! ${newRelease.html_url}`);
console.log('Add some release notes and publish.');
}

main();
52 changes: 52 additions & 0 deletions release.sh
@@ -0,0 +1,52 @@
#!/bin/sh

# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e

maybe_dry=
if [[ "$1" != "wet" ]]; then
echo "Dry run. Add 'wet' to command to do a real run"
maybe_dry="echo Would run: "
fi

echo "Testing."
$maybe_dry yarn run test

echo "Ready to deploy to QA. ^C to stop, enter to continue."
read

$maybe_dry rm -r build/deploy || true
$maybe_dry mkdir -p build/deploy
$maybe_dry ./build.sh dev
$maybe_dry cp -r build/dev/* build/deploy
$maybe_dry ./node_modules/.bin/firebase deploy -P qa

echo "Deployed to QA. Maybe do manual testing? ^C to stop, enter to deploy to prod."
read

$maybe_dry rm -r build/deploy
$maybe_dry mkdir -p build/deploy
$maybe_dry ./build.sh prod
$maybe_dry cp -r build/prod/* build/deploy
$maybe_dry ./node_modules/.bin/firebase deploy -P prod

echo "Deployed to Prod. Create a new standalone build? ^C to stop, enter to continue."
read

$maybe_dry ./build.sh standalone
$maybe_dry rm build/codewich.zip
$maybe_dry zip -r build/codewich.zip build/standalone
$maybe_dry node release.js
6 changes: 6 additions & 0 deletions src/index.html
Expand Up @@ -35,6 +35,12 @@
<meta property="og:image" content="https://codewich.com/opengraph.png" />
<meta property="og:description" content="Create and share simple web demos using TypeScript, CSS, and HTML. Prototype new ideas quickly." />

<script>
// Fallback fake ga object in case Analytics is blocked or not included.
function ga() {
console.info('Analytics not loaded.');
}
</script>
{{#if GA_ID}}
<!-- Google Analytics -->
<script>
Expand Down
65 changes: 54 additions & 11 deletions yarn.lock
Expand Up @@ -40,6 +40,13 @@ after@0.8.2:
version "0.8.2"
resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f"

agent-base@2:
version "2.0.1"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-2.0.1.tgz#bd8f9e86a8eb221fffa07bd14befd55df142815e"
dependencies:
extend "~3.0.0"
semver "~5.0.1"

align-text@^0.1.1, align-text@^0.1.3:
version "0.1.4"
resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117"
Expand Down Expand Up @@ -755,6 +762,12 @@ debug@0.7.4:
version "0.7.4"
resolved "https://registry.yarnpkg.com/debug/-/debug-0.7.4.tgz#06e1ea8082c2cb14e39806e22e2f6f757f92af39"

debug@2, debug@2.6.1, debug@^2.2.0:
version "2.6.1"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.1.tgz#79855090ba2c4e3115cc7d8769491d58f0491351"
dependencies:
ms "0.7.2"

debug@2.2.0, debug@~2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da"
Expand All @@ -767,12 +780,6 @@ debug@2.3.3:
dependencies:
ms "0.7.2"

debug@2.6.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.1.tgz#79855090ba2c4e3115cc7d8769491d58f0491351"
dependencies:
ms "0.7.2"

decamelize@^1.0.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
Expand Down Expand Up @@ -1072,7 +1079,7 @@ expand-range@^1.8.1:
dependencies:
fill-range "^2.1.0"

extend@^3.0.0, extend@~3.0.0:
extend@3, extend@^3.0.0, extend@~3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.0.tgz#5a474353b9f3353ddd8176dfd37b91c83a46f1d4"

Expand Down Expand Up @@ -1229,6 +1236,13 @@ flat-arguments@^1.0.0:
lodash.isarguments "^3.0.0"
lodash.isobject "^3.0.0"

follow-redirects@0.0.7:
version "0.0.7"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-0.0.7.tgz#34b90bab2a911aa347571da90f22bd36ecd8a919"
dependencies:
debug "^2.2.0"
stream-consume "^0.1.0"

for-in@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
Expand Down Expand Up @@ -1353,6 +1367,15 @@ getpass@^0.1.1:
dependencies:
assert-plus "^1.0.0"

github@^9.2.0:
version "9.2.0"
resolved "https://registry.yarnpkg.com/github/-/github-9.2.0.tgz#8a886dc40dd63636707dcaf99df3df26c59f16fc"
dependencies:
follow-redirects "0.0.7"
https-proxy-agent "^1.0.0"
mime "^1.2.11"
netrc "^0.1.4"

glob-base@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4"
Expand Down Expand Up @@ -1576,6 +1599,14 @@ http-signature@~1.1.0:
jsprim "^1.2.2"
sshpk "^1.7.0"

https-proxy-agent@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-1.0.0.tgz#35f7da6c48ce4ddbfa264891ac593ee5ff8671e6"
dependencies:
agent-base "2"
debug "2"
extend "3"

iconv-lite@0.4.15:
version "0.4.15"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.15.tgz#fe265a218ac6a57cfe854927e9d04c19825eddeb"
Expand Down Expand Up @@ -2131,7 +2162,7 @@ mime-types@^2.0.4, mime-types@^2.1.12, mime-types@~2.1.11, mime-types@~2.1.13, m
dependencies:
mime-db "~1.26.0"

mime@1.3.4, mime@^1.3.4:
mime@1.3.4, mime@^1.2.11, mime@^1.3.4:
version "1.3.4"
resolved "https://registry.yarnpkg.com/mime/-/mime-1.3.4.tgz#115f9e3b6b3daf2959983cb38f149a2d40eb5d53"

Expand All @@ -2153,13 +2184,13 @@ minimist@~0.0.1:
version "0.0.10"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf"

mkdirp@0.5.0, mkdirp@^0.5.0:
mkdirp@0.5.0, mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.0.tgz#1d73076a6df986cd9344e15e71fcc05a4c9abf12"
dependencies:
minimist "0.0.8"

mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@~0.5.1:
mkdirp@~0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
dependencies:
Expand Down Expand Up @@ -2214,6 +2245,10 @@ nested-error-stacks@^1.0.0:
dependencies:
inherits "~2.0.1"

netrc@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/netrc/-/netrc-0.1.4.tgz#6be94fcaca8d77ade0a9670dc460914c94472444"

node-int64@~0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
Expand Down Expand Up @@ -2804,14 +2839,18 @@ semver-diff@^2.0.0:
dependencies:
semver "^5.0.3"

semver@^5.0.1, semver@^5.0.3, semver@^5.1.0, semver@~5.3.0:
semver@^5.0.1, semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@~5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"

semver@~4.3.3:
version "4.3.6"
resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.6.tgz#300bc6e0e86374f7ba61068b5b1ecd57fc6532da"

semver@~5.0.1:
version "5.0.3"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.0.3.tgz#77466de589cd5d3c95f138aa78bc569a3cb5d27a"

send@latest:
version "0.15.1"
resolved "https://registry.yarnpkg.com/send/-/send-0.15.1.tgz#8a02354c26e6f5cca700065f5f0cdeba90ec7b5f"
Expand Down Expand Up @@ -2965,6 +3004,10 @@ stream-combiner@~0.0.4:
dependencies:
duplexer "~0.1.1"

stream-consume@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/stream-consume/-/stream-consume-0.1.0.tgz#a41ead1a6d6081ceb79f65b061901b6d8f3d1d0f"

stream-shift@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.0.tgz#d5c752825e5367e786f78e18e445ea223a155952"
Expand Down

0 comments on commit 874919f

Please sign in to comment.