Skip to content

Commit

Permalink
fix: Error publishing to github when building on travis #261
Browse files Browse the repository at this point in the history
Closes #261
  • Loading branch information
develar committed Mar 25, 2016
1 parent 65d8126 commit 92f7a38
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 29 deletions.
25 changes: 22 additions & 3 deletions docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,26 @@ See [OS X options](https://www.npmjs.com/package/appdmg#json-specification) and

Here documented only `electron-builder` specific options:

| Name | Description
<!-- do not edit. start of generated block -->
<a class="anchor" href="#AppMetadata" aria-hidden="true"></a>
# Application `package.json`
| Name | Description
| --- | ---
| <a name="iconUrl"></a>iconUrl<br/> | <p>*windows-only.* A URL to an ICO file to use as the application icon (displayed in Control Panel > Programs and Features). Defaults to the Atom icon.</p><p>Please note — [local icon file url is not accepted](https://github.com/atom/grunt-electron-installer/issues/73), must be https/http.</p><ul><li>If you don't plan to build windows installer, you can omit it.</li><li>If your project repository is public on GitHub, it will be `https://raw.githubusercontent.com/${info.user}/${info.project}/master/build/icon.ico` by default.</li></ul>
| <a name="extraResources"></a>extraResources | <p>A [glob expression](https://www.npmjs.com/package/glob#glob-primer), when specified, copy the file or directory with matching names directly into the app's directory (`Contents/Resources` for OS X).</p><p>You can use `${os}` (expanded to osx, linux or win according to current platform) and `${arch}` in the pattern.</p><p>If directory matched, all contents are copied. So, you can just specify `foo` to copy `<project_dir>/foo` directory.</p><p>May be specified in the platform options (i.e. in the `build.osx`).
| <a class="anchor" href="#AppMetadata-name" aria-hidden="true"></a>name | The application name.
| <a class="anchor" href="#AppMetadata-productName" aria-hidden="true"></a>productName | <p>As [name](#AppMetadata-name), but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the [name property](https://docs.npmjs.com/files/package.json#name}).</p>

<a class="anchor" href="#DevMetadata" aria-hidden="true"></a>
# Development `package.json`
| Name | Description
| --- | ---
| <a class="anchor" href="#DevMetadata-build" aria-hidden="true"></a>build | See [build](#BuildMetadata).

<a class="anchor" href="#BuildMetadata" aria-hidden="true"></a>
## `.build`
| Name | Description
| --- | ---
| <a class="anchor" href="#BuildMetadata-iconUrl" aria-hidden="true"></a>iconUrl | <p>*windows-only.* A URL to an ICO file to use as the application icon (displayed in Control Panel &gt; Programs and Features). Defaults to the Atom icon.</p> <p>Please note — [local icon file url is not accepted](https://github.com/atom/grunt-electron-installer/issues/73), must be https/http.</p> <ul> <li>If you don’t plan to build windows installer, you can omit it.</li> <li>If your project repository is public on GitHub, it will be <code>https://raw.githubusercontent.com/${info.user}/${info.project}/master/build/icon.ico</code> by default.</li> </ul>
| <a class="anchor" href="#BuildMetadata-productName" aria-hidden="true"></a>productName | See [AppMetadata.productName](#AppMetadata-productName).
| <a class="anchor" href="#BuildMetadata-extraResources" aria-hidden="true"></a>extraResources | <p>A [glob expression](https://www.npmjs.com/package/glob#glob-primer), when specified, copy the file or directory with matching names directly into the app’s directory (<code>Contents/Resources</code> for OS X).</p> <p>You can use <code>${os}</code> (expanded to osx, linux or win according to current platform) and <code>${arch}</code> in the pattern.</p> <p>If directory matched, all contents are copied. So, you can just specify <code>foo</code> to copy <code>&lt;project_dir&gt;/foo</code> directory.</p> <p>May be specified in the platform options (i.e. in the <code>build.osx</code>).</p>

<!-- end of generated block -->
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"pre-commit": "^1.1.2",
"semantic-release": "^4.3.5",
"should": "^8.3.0",
"ts-babel": "^0.6.1",
"ts-babel": "^0.6.3",
"tsconfig-glob": "^0.4.2",
"tslint": "next",
"typescript": "^1.9.0-dev.20160323",
Expand Down
33 changes: 13 additions & 20 deletions src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,28 @@ export async function createPublisher(packager: Packager, options: BuildOptions,
export interface BuildOptions extends PackagerOptions, PublishOptions {
}

export async function build(options: BuildOptions = {}): Promise<void> {
if (options.cscLink == null) {
options.cscLink = process.env.CSC_LINK
}
if (options.csaLink == null) {
options.csaLink = process.env.CSA_LINK
}
if (options.cscKeyPassword == null) {
options.cscKeyPassword = process.env.CSC_KEY_PASSWORD
}

if (options.githubToken == null) {
options.githubToken = process.env.GH_TOKEN || process.env.GH_TEST_TOKEN
}
export async function build(originalOptions?: BuildOptions): Promise<void> {
const options = Object.assign({
cscLink: process.env.CSC_LINK,
csaLink: process.env.CSA_LINK,
cscKeyPassword: process.env.CSC_KEY_PASSWORD,
githubToken: process.env.GH_TOKEN || process.env.GH_TEST_TOKEN,
}, originalOptions)

const lifecycleEvent = process.env.npm_lifecycle_event
if (options.dist === undefined) {
options.dist = lifecycleEvent === "dist" || lifecycleEvent === "build"
}

if (options.publish) {
options.dist = true
}
else if (options.dist === undefined) {
options.dist = lifecycleEvent === "dist" || lifecycleEvent === "build"
}

let isPublishOptionGuessed = false
if (options.publish === undefined) {
if (lifecycleEvent === "release") {
options.publish = "always"
}
else {
else if (options.githubToken != null) {
const tag = process.env.TRAVIS_TAG || process.env.APPVEYOR_REPO_TAG_NAME || process.env.CIRCLE_TAG
if (tag != null && tag.length !== 0) {
log("Tag %s is defined, so artifacts will be published", tag)
Expand All @@ -82,7 +74,8 @@ export async function build(options: BuildOptions = {}): Promise<void> {
}

if (publisher != null) {
publisher.then(it => publishTasks.push(<BluebirdPromise<any>>it.upload(event.file, event.artifactName)))
publisher
.then(it => publishTasks.push(<BluebirdPromise<any>>it.upload(event.file, event.artifactName)))
}
})
}
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { Packager } from "./packager"
export { PackagerOptions, ArtifactCreated } from "./platformPackager"
export { BuildOptions, build, createPublisher } from "./builder"
export { AppMetadata, DevMetadata, Platform, getProductName } from "./metadata"
33 changes: 28 additions & 5 deletions src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ export interface Metadata {
readonly repository: string | RepositoryInfo
}

/*
Application `package.json`
/**
Application `package.json`
*/
export interface AppMetadata extends Metadata {
readonly version: string
Expand All @@ -14,7 +14,7 @@ export interface AppMetadata extends Metadata {
readonly name: string

/**
As [name](#name), but allows you to specify a product name for your executable which contains spaces and other special characters
As [name](#AppMetadata-name), but allows you to specify a product name for your executable which contains spaces and other special characters
not allowed in the [name property](https://docs.npmjs.com/files/package.json#name}).
*/
readonly productName?: string
Expand All @@ -24,10 +24,13 @@ export interface AppMetadata extends Metadata {
readonly author: AuthorMetadata
}

/*
Development `package.json`
/**
Development `package.json`
*/
export interface DevMetadata extends Metadata {
/**
See [BuildMetadata](#BuildMetadata).
*/
readonly build?: BuildMetadata

readonly directories?: MetadataDirectories
Expand All @@ -46,10 +49,21 @@ export interface MetadataDirectories {
readonly buildResources?: string
}

/**
Development `package.json` `.build`
*/
export interface BuildMetadata {
readonly "app-bundle-id": string
readonly "app-category-type": string

/**
*windows-only.* A URL to an ICO file to use as the application icon (displayed in Control Panel > Programs and Features). Defaults to the Atom icon.
Please note — [local icon file url is not accepted](https://github.com/atom/grunt-electron-installer/issues/73), must be https/http.
* If you don't plan to build windows installer, you can omit it.
* If your project repository is public on GitHub, it will be `https://raw.githubusercontent.com/${info.user}/${info.project}/master/build/icon.ico` by default.
*/
readonly iconUrl: string

/**
Expand All @@ -61,6 +75,15 @@ export interface BuildMetadata {
readonly win?: any,
readonly linux?: any

/**
A [glob expression](https://www.npmjs.com/package/glob#glob-primer), when specified, copy the file or directory with matching names directly into the app's directory (`Contents/Resources` for OS X).
You can use `${os}` (expanded to osx, linux or win according to current platform) and `${arch}` in the pattern.
If directory matched, all contents are copied. So, you can just specify `foo` to copy `<project_dir>/foo` directory.
May be specified in the platform options (i.e. in the `build.osx`).
*/
readonly extraResources?: Array<string>
}

Expand Down
2 changes: 2 additions & 0 deletions test/src/helpers/expectedContents.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//noinspection SpellCheckingInspection
export const expectedLinuxContents = [
"/",
"/opt/",
Expand Down Expand Up @@ -53,6 +54,7 @@ export const expectedLinuxContents = [
"/usr/share/icons/hicolor/96x96/apps/TestApp.png"
]

//noinspection SpellCheckingInspection
export const expectedWinContents = [
"lib/net45/content_resources_200_percent.pak",
"lib/net45/content_shell.pak",
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"electron-builder": "out/electron-builder.d.ts",
"": "test/out/electron-builder.d.ts"
},
"docs": "docs/options.md",
"filesGlob": [
"src/*.ts",
"lib/*.d.ts",
Expand Down

0 comments on commit 92f7a38

Please sign in to comment.