Browse Source

make script to hit circle ci api point to build for release

Vanessa Yuen 7 years ago
parent
commit
f937f971c1
2 changed files with 49 additions and 22 deletions
  1. 49 0
      script/ci-release-build.js
  2. 0 22
      test-builds.sh

+ 49 - 0
script/ci-release-build.js

@@ -0,0 +1,49 @@
+const args = require('minimist')(process.argv.slice(2))
+const assert = require('assert')
+const request = require('request')
+
+const ciJobs = [
+  'electron-linux-arm64',
+  'electron-linux-ia32',
+  'electron-linux-x64',
+  'electron-linux-arm'
+]
+
+if (args._.length < 1) {
+  console.log(`Trigger Circle CI to build release builds of electron.
+  Usage: ci-release-build.js [--branch=TARGET_BRANCH] CI_JOB_NAME
+  `)
+  process.exit(1)
+}
+
+const targetBranch = args['branch'] || 'master'
+const ciJob = args._[0]
+assert(ciJobs.includes(ciJob), `Unknown ci job name: ${ciJob}.`)
+assert(process.env.CIRCLE_TOKEN, 'CIRCLE_TOKEN not found in environment')
+
+
+const circleBuildURL = `https://circleci.com/api/v1.1/project/github/electron/electron/tree/${targetBranch}?circle-token=${process.env.CIRCLE_TOKEN}`
+
+console.log(`Triggering CircleCI to run build job: ${ciJob} against branch: ${targetBranch} with release flag.`)
+
+request({
+  method: 'POST',
+  url: circleBuildURL,
+  headers: {
+    'Content-Type': 'application/json',
+    'Accept': 'application/json'
+  },
+  body: JSON.stringify({
+    'build_parameters': {
+      'RUN_RELEASE_BUILD': 'true',
+      'CIRCLE_JOB': ciJob
+    }
+  })
+}, (err, res, body) => {
+  if (!err && res.statusCode == 200) {
+    const build = JSON.parse(body)
+    console.log(`check ${build.build_url} for status`)
+  } else {
+    console.log('error', err)
+  }
+})

+ 0 - 22
test-builds.sh

@@ -1,22 +0,0 @@
-#!/bin/bash
-
-_project=$1
-_branch=$2
-_circle_token=$3
-
-trigger_build_url=https://circleci.com/api/v1.1/project/github/${_project}/tree/${_branch}?circle-token=${_circle_token}
-
-post_data=$(cat <<EOF
-{
-  "build_parameters": {
-    "RUN_RELEASE_BUILD": "true",
-    "CIRCLE_JOB": "electron-linux-arm"
-  }
-}
-EOF)
-
-curl \
---header "Accept: application/json" \
---header "Content-Type: application/json" \
---data "${post_data}" \
---request POST ${trigger_build_url}