Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use buildVersion not buildNumber for fpm --iteration flag #7075

Merged
merged 5 commits into from Aug 28, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/app-builder-lib/scheme.json
Expand Up @@ -6315,8 +6315,15 @@
"description": "Whether to build the application native dependencies from source.",
"type": "boolean"
},
"buildNumber": {
"description": "The build number. Maps to the `--iteration` flag for builds using FPM on Linux. If not defined then will fallback to `BUILD_NUMBER` or `TRAVIS_BUILD_NUMBER` or `APPVEYOR_BUILD_NUMBER` or `CIRCLE_BUILD_NUM` or `BUILD_BUILDNUMBER` or `CI_PIPELINE_IID` env.",
"type": [
"null",
"string"
]
},
"buildVersion": {
"description": "The build version. Maps to the `CFBundleVersion` on macOS, and `FileVersion` metadata property on Windows. Defaults to the `version`.\nIf `TRAVIS_BUILD_NUMBER` or `APPVEYOR_BUILD_NUMBER` or `CIRCLE_BUILD_NUM` or `BUILD_NUMBER` or `bamboo.buildNumber` or `CI_PIPELINE_IID` env defined, it will be used as a build version (`version.build_number`).",
"description": "The build version. Maps to the `CFBundleVersion` on macOS, and `FileVersion` metadata property on Windows. Defaults to the `version`.\nIf `buildVersion` is not defined and `buildNumber` (or one of the `buildNumber envs) is defined, it will be used as a build version (`version.buildNumber`).",
"type": [
"null",
"string"
Expand Down
3 changes: 2 additions & 1 deletion packages/app-builder-lib/src/appInfo.ts
Expand Up @@ -39,13 +39,14 @@ export class AppInfo {
buildVersion = info.config.buildVersion
}

this.buildNumber =
const buildNumberEnvs =
process.env.BUILD_NUMBER ||
process.env.TRAVIS_BUILD_NUMBER ||
process.env.APPVEYOR_BUILD_NUMBER ||
process.env.CIRCLE_BUILD_NUM ||
process.env.BUILD_BUILDNUMBER ||
process.env.CI_PIPELINE_IID
this.buildNumber = info.config.buildNumber || buildNumberEnvs
if (buildVersion == null) {
buildVersion = this.version
if (!isEmptyOrSpaces(this.buildNumber)) {
Expand Down
8 changes: 7 additions & 1 deletion packages/app-builder-lib/src/configuration.ts
Expand Up @@ -129,9 +129,15 @@ export interface Configuration extends PlatformSpecificBuildOptions {
*/
readonly npmRebuild?: boolean

/**
* The build number. Maps to the `--iteration` flag for builds using FPM on Linux.
* If not defined then will fallback to `BUILD_NUMBER` or `TRAVIS_BUILD_NUMBER` or `APPVEYOR_BUILD_NUMBER` or `CIRCLE_BUILD_NUM` or `BUILD_BUILDNUMBER` or `CI_PIPELINE_IID` env.
Copy link
Collaborator

@mmaietta mmaietta Aug 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor grammar change (comma + 'it'): "If not defined, then it will fallback"

Thanks for also specifying its relationship to --iteration

*/
readonly buildNumber?: string | null

/**
* The build version. Maps to the `CFBundleVersion` on macOS, and `FileVersion` metadata property on Windows. Defaults to the `version`.
* If `TRAVIS_BUILD_NUMBER` or `APPVEYOR_BUILD_NUMBER` or `CIRCLE_BUILD_NUM` or `BUILD_NUMBER` or `bamboo.buildNumber` or `CI_PIPELINE_IID` env defined, it will be used as a build version (`version.build_number`).
* If `buildVersion` is not defined and `buildNumber` (or one of the `buildNumber envs) is defined, it will be used as a build version (`version.buildNumber`).
Copy link
Collaborator

@mmaietta mmaietta Aug 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"`buildNumber envs" is missing a closing backtick around buildNumber

You'll need to re-run pnpm generate-all after adjusting these jsdocs

*/
readonly buildVersion?: string | null

Expand Down
15 changes: 11 additions & 4 deletions packages/app-builder-lib/src/targets/fpm.ts
Expand Up @@ -180,10 +180,17 @@ export default class FpmTarget extends Target {
}
}

use(packager.info.metadata.license, it => args.push("--license", it!))
use(appInfo.buildNumber, it => args.push("--iteration", it!))

use(options.fpm, it => args.push(...(it as any)))
use(packager.info.metadata.license, it => args.push("--license", it))
use(appInfo.buildNumber, it =>
args.push(
"--iteration",
// dashes are not supported for iteration in older versions of fpm
// https://github.com/jordansissel/fpm/issues/1833
it.split("-").join("_")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to it.replaceAll('-', '_')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaceAll isn't supported in Node 14.

)
)

use(options.fpm, it => args.push(...it))

args.push(`${appOutDir}/=${installPrefix}/${appInfo.sanitizedProductName}`)
for (const icon of await this.helper.icons) {
Expand Down
2 changes: 1 addition & 1 deletion packages/app-builder-lib/src/winPackager.ts
Expand Up @@ -297,7 +297,7 @@ export class WinPackager extends PlatformPackager<WindowsConfiguration> {
}

use(appInfo.companyName, it => args.push("--set-version-string", "CompanyName", it))
use(this.platformSpecificBuildOptions.legalTrademarks, it => args.push("--set-version-string", "LegalTrademarks", it!))
use(this.platformSpecificBuildOptions.legalTrademarks, it => args.push("--set-version-string", "LegalTrademarks", it))
const iconPath = await this.getIconPath()
use(iconPath, it => {
files.push(it)
Expand Down
3 changes: 2 additions & 1 deletion packages/builder-util/src/util.ts
Expand Up @@ -265,7 +265,8 @@ export class ExecError extends Error {
}
}

export function use<T, R>(value: T | null, task: (it: T) => R): R | null {
type Nullish = null | undefined
export function use<T, R>(value: T | Nullish, task: (value: T) => R): R | null {
return value == null ? null : task(value)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/src/cli/install-app-deps.ts
Expand Up @@ -50,7 +50,7 @@ export async function installAppDeps(args: any) {
const [appDir, version] = await Promise.all<string>([
computeDefaultAppDirectory(
projectDir,
use(config.directories, it => it!.app)
use(config.directories, it => it.app)
),
getElectronVersion(projectDir, config, packageMetadata),
])
Expand Down