Skip to content

Commit

Permalink
Add basic version info to win32 dll. (#2592)
Browse files Browse the repository at this point in the history
  • Loading branch information
acoates-ms authored Jun 7, 2019
1 parent 2f9da4a commit 5c7b313
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 27 deletions.
69 changes: 53 additions & 16 deletions .ado/updateVersion.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
// Used to update the package version
// Used to update the package version

const fs = require("fs");
const path = require("path");
Expand All @@ -19,36 +19,51 @@ function exec(command) {
}

function updateVersion() {
const publishBranchName = process.env.BUILD_SOURCEBRANCH.match(/refs\/heads\/(.*)/)[1];
const publishBranchName = process.env.BUILD_SOURCEBRANCH.match(
/refs\/heads\/(.*)/
)[1];

// Set env variable to allow npm publish task to publish to correct tag
console.log(`##vso[task.setvariable variable=npmTag]${publishBranchName === 'master' ? 'vnext' : publishBranchName}`);
console.log(
`##vso[task.setvariable variable=npmTag]${
publishBranchName === "master" ? "vnext" : publishBranchName
}`
);
console.log(`Target branch to publish to: ${publishBranchName}`);

const tempPublishBranch = `auto-update-version-publish-temp-${Date.now()}`;

console.log(`Using ${`(.*-microsoft)(-${publishBranchName})?\\.([0-9]*)`} to match version`);
const branchVersionSuffix = (publishBranchName.match(/(fb.*merge)|(fabric)/) ? `-${publishBranchName}` : '');

console.log(
`Using ${`(.*-microsoft)(-${publishBranchName})?\\.([0-9]*)`} to match version`
);
const branchVersionSuffix = publishBranchName.match(/(fb.*merge)|(fabric)/)
? `-${publishBranchName}`
: "";

exec(`npm install -g yarn`);

// Ensure publishBranchName is same locally as remote
exec(`git fetch origin ${publishBranchName}`);
exec(`git checkout ${publishBranchName} --force`);
exec(`git reset --hard origin/${publishBranchName}`);

exec(`git checkout -b ${tempPublishBranch}`);

const pkgJsonPath = path.resolve(__dirname, "../vnext/package.json");
let pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));

let releaseVersion = pkgJson.version;

const versionStringRegEx = new RegExp(`(.*-vnext)(-${publishBranchName})?\\.([0-9]*)`);

const versionStringRegEx = new RegExp(
`(.*-vnext)(-${publishBranchName})?\\.([0-9]*)`
);
const versionGroups = versionStringRegEx.exec(releaseVersion);
if (versionGroups) {
releaseVersion = versionGroups[1] + branchVersionSuffix + '.' + (parseInt(versionGroups[3]) + 1);
releaseVersion =
versionGroups[1] +
branchVersionSuffix +
"." +
(parseInt(versionGroups[3]) + 1);
} else {
if (releaseVersion.indexOf("-") === -1) {
releaseVersion = releaseVersion + `-vnext${branchVersionSuffix}.0`;
Expand All @@ -62,13 +77,37 @@ function updateVersion() {
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
console.log(`Updating package.json to version ${releaseVersion}`);

const win32VersionRcPath = path.resolve(
__dirname,
"../vnext/Desktop.DLL/Version.rc"
);

let versionRC = fs.readFileSync(win32VersionRcPath).toString();
versionRC = versionRC.replace(
/#define VER_FILEVERSION_STR\s+"[^"]+"/,
`#define VER_FILEVERSION_STR "${releaseVersion}"`
);
versionRC = versionRC.replace(
/#define VER_FILEVERSION\s+.+/,
`#define VER_FILEVERSION ${releaseVersion.split(".")[0]},${
releaseVersion.split(".")[1]
},${releaseVersion.split(".")[2].split("-")[0]},${parseInt(
versionGroups[3]
) + 1}`
);
fs.writeFileSync(win32VersionRcPath, versionRC);

process.chdir(path.resolve(__dirname, "../vnext"));
exec(`${process.env.APPDATA}\\npm\\node_modules\\yarn\\bin\\yarn.cmd install`);
exec(
`${process.env.APPDATA}\\npm\\node_modules\\yarn\\bin\\yarn.cmd install`
);
exec(`${process.env.APPDATA}\\npm\\node_modules\\yarn\\bin\\yarn.cmd build`);

const tagName = 'vnext-' + releaseVersion;
const tagName = "vnext-" + releaseVersion;

exec(`git add ${pkgJsonPath}`);
exec(`git add ${win32VersionRcPath}`);

exec(`git commit -m "Applying package update to ${releaseVersion}`);
exec(`git tag ${tagName}`);
exec(`git push origin HEAD:${tempPublishBranch} --follow-tags --verbose`);
Expand All @@ -77,11 +116,9 @@ function updateVersion() {
exec(`git checkout ${publishBranchName}`);
exec(`git pull origin ${publishBranchName}`);
exec(`git merge ${tempPublishBranch} --no-edit`);
exec(
`git push origin HEAD:${publishBranchName} --follow-tags --verbose`
);
exec(`git push origin HEAD:${publishBranchName} --follow-tags --verbose`);
exec(`git branch -d ${tempPublishBranch}`);
exec(`git push origin --delete -d ${tempPublishBranch}`);
}

updateVersion();
updateVersion();
3 changes: 3 additions & 0 deletions vnext/Desktop.DLL/React.Windows.Desktop.DLL.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@
<Project>{95048601-C3DC-475F-ADF8-7C0C764C10D5}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Version.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(SolutionDir)\packages\OpenSSL.Windows-1.0.2n.0.0.1\build\native\OpenSSL.Windows-1.0.2n.targets" Condition="Exists('$(SolutionDir)\packages\OpenSSL.Windows-1.0.2n.0.0.1\build\native\OpenSSL.Windows-1.0.2n.targets')" />
Expand Down
3 changes: 3 additions & 0 deletions vnext/Desktop.DLL/React.Windows.Desktop.DLL.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@
<None Include="react-native-win32.x64.def" />
<None Include="react-native-win32.x86.def" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Version.rc" />
</ItemGroup>
</Project>
48 changes: 48 additions & 0 deletions vnext/Desktop.DLL/Version.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include <winver.h>

#define VER_FILEVERSION 3,10,349,0
#define VER_FILEVERSION_STR "3.10.349.0\0"

#ifndef DEBUG
#define VER_DEBUG 0
#else
#define VER_DEBUG VS_FF_DEBUG
#endif

VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_FILEVERSION
FILEFLAGSMASK (VS_FF_DEBUG)
FILEFLAGS(VER_DEBUG)
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", "Microsoft"
VALUE "FileDescription", "React-Native-Windows"
VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "InternalName", "react-native-win32.dll"
VALUE "LegalCopyright", "(c) Microsoft Corporation. All rights reserved."
VALUE "OriginalFilename", "react-native-win32.dll"
VALUE "ProductName", "React-Native-Windows"
VALUE "ProductVersion", VER_FILEVERSION_STR
END
END

BLOCK "VarFileInfo"
BEGIN
/* The following line should only be modified for localized versions. */
/* It consists of any number of WORD,WORD pairs, with each pair */
/* describing a language,codepage combination supported by the file. */
/* */
/* For example, a file might have values "0x409,1252" indicating that it */
/* supports English language (0x409) in the Windows ANSI codepage (1252). */

VALUE "Translation", 0x409, 1252

END
END
2 changes: 1 addition & 1 deletion vnext/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"react": "16.6.3",
"tslint": "^5.11.0",
"tslint-microsoft-contrib": "^5.0.1",
"tslint-react": "^3.5.0",
"tslint-react": "^4",
"typescript": "3.5.1",
"react-native": "0.58.6-microsoft.60"
},
Expand Down
27 changes: 17 additions & 10 deletions vnext/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4939,12 +4939,12 @@ tslint-microsoft-contrib@^5.0.1:
dependencies:
tsutils "^2.27.2 <2.29.0"

tslint-react@^3.5.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/tslint-react/-/tslint-react-3.6.0.tgz#7f462c95c4a0afaae82507f06517ff02942196a1"
integrity sha512-AIv1QcsSnj7e9pFir6cJ6vIncTqxfqeFF3Lzh8SuuBljueYzEAtByuB6zMaD27BL0xhMEqsZ9s5eHuCONydjBw==
tslint-react@^4:
version "4.0.0"
resolved "https://registry.yarnpkg.com/tslint-react/-/tslint-react-4.0.0.tgz#b4bb4c01c32448cb14d23f143a2f5e4989bb961e"
integrity sha512-9fNE0fm9zNDx1+b6hgy8rgDN2WsQLRiIrn3+fbqm0tazBVF6jiaCFAITxmU+WSFWYE03Xhp1joCircXOe1WVAQ==
dependencies:
tsutils "^2.13.1"
tsutils "^3.9.1"

tslint@^5.11.0:
version "5.15.0"
Expand All @@ -4965,17 +4965,24 @@ tslint@^5.11.0:
tslib "^1.8.0"
tsutils "^2.29.0"

tsutils@^2.13.1, tsutils@^2.29.0:
"tsutils@^2.27.2 <2.29.0":
version "2.28.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.28.0.tgz#6bd71e160828f9d019b6f4e844742228f85169a1"
integrity sha512-bh5nAtW0tuhvOJnx1GLRn5ScraRLICGyJV5wJhtRWOLsxW70Kk5tZtpK3O/hW6LDnqKS9mlUMPZj9fEMJ0gxqA==
dependencies:
tslib "^1.8.1"

tsutils@^2.29.0:
version "2.29.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.29.0.tgz#32b488501467acbedd4b85498673a0812aca0b99"
integrity sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==
dependencies:
tslib "^1.8.1"

"tsutils@^2.27.2 <2.29.0":
version "2.28.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.28.0.tgz#6bd71e160828f9d019b6f4e844742228f85169a1"
integrity sha512-bh5nAtW0tuhvOJnx1GLRn5ScraRLICGyJV5wJhtRWOLsxW70Kk5tZtpK3O/hW6LDnqKS9mlUMPZj9fEMJ0gxqA==
tsutils@^3.9.1:
version "3.14.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.14.0.tgz#bf8d5a7bae5369331fa0f2b0a5a10bd7f7396c77"
integrity sha512-SmzGbB0l+8I0QwsPgjooFRaRvHLBLNYM8SeQ0k6rtNDru5sCGeLJcZdwilNndN+GysuFjF5EIYgN8GfFG6UeUw==
dependencies:
tslib "^1.8.1"

Expand Down

0 comments on commit 5c7b313

Please sign in to comment.