Skip to content

Commit

Permalink
Add commitid to product version of binaries (#11316)
Browse files Browse the repository at this point in the history
* Add commitid to product version of binaries

* Change files

* Undo the validation logic of the extra argument
  • Loading branch information
dannyvv committed Feb 28, 2023
1 parent ec99a93 commit 87e36a8
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Add commitid to product version of binaries",
"packageName": "react-native-windows",
"email": "dannyvv@microsoft.com",
"dependentChangeType": "patch"
}
2 changes: 2 additions & 0 deletions packages/@rnw-scripts/stamp-version/src/renderPropsFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import semver from 'semver';
*/
export default async function renderPropsFile(
version: string,
commitId: string,
): Promise<string> {
const templatePath = path.join(
__dirname,
Expand All @@ -30,5 +31,6 @@ export default async function renderPropsFile(
minor: semver.minor(version),
patch: semver.patch(version),
canary: semver.prerelease(version)?.[0] === 'canary',
commitId: commitId,
});
}
6 changes: 5 additions & 1 deletion packages/@rnw-scripts/stamp-version/src/stampVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ const {argv} = yargs
* Rewrites PackageVersion.g.props
*/
async function setPackageVersionProps(version: string) {
const propsStr = await renderPropsFile(version);
const commitId =
process.env.BUILD_SOURCEVERSION ?? // Azure DevOps Pipelines
process.env.GITHUB_SHA ?? // GitHub Actions
'developer-build';
const propsStr = await renderPropsFile(version, commitId);

const rnwPackage = await findRepoPackage('react-native-windows');
const propsPath = path.join(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ exports[`0.0.0-canary.100 1`] = `
<ReactNativeWindowsMinor>0</ReactNativeWindowsMinor>
<ReactNativeWindowsPatch>0</ReactNativeWindowsPatch>
<ReactNativeWindowsCanary>true</ReactNativeWindowsCanary>
<ReactNativeWindowsCommitId>abc123</ReactNativeWindowsCommitId>
</PropertyGroup>
</Project>"
`;
Expand All @@ -40,6 +41,7 @@ exports[`0.66.5 1`] = `
<ReactNativeWindowsMinor>66</ReactNativeWindowsMinor>
<ReactNativeWindowsPatch>5</ReactNativeWindowsPatch>
<ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
<ReactNativeWindowsCommitId>123abc</ReactNativeWindowsCommitId>
</PropertyGroup>
</Project>"
`;
Expand All @@ -62,6 +64,7 @@ exports[`0.67.0-preview.1 1`] = `
<ReactNativeWindowsMinor>67</ReactNativeWindowsMinor>
<ReactNativeWindowsPatch>0</ReactNativeWindowsPatch>
<ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
<ReactNativeWindowsCommitId>def456</ReactNativeWindowsCommitId>
</PropertyGroup>
</Project>"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import renderPropsFile from '../renderPropsFile';

test('0.0.0-canary.100', async () => {
expect(await renderPropsFile('0.0.0-canary.100')).toMatchSnapshot();
expect(await renderPropsFile('0.0.0-canary.100', 'abc123')).toMatchSnapshot();
});

test('0.67.0-preview.1', async () => {
expect(await renderPropsFile('0.67.0-preview.1')).toMatchSnapshot();
expect(await renderPropsFile('0.67.0-preview.1', 'def456')).toMatchSnapshot();
});

test('0.66.5', async () => {
expect(await renderPropsFile('0.66.5')).toMatchSnapshot();
expect(await renderPropsFile('0.66.5', '123abc')).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
<ReactNativeWindowsMinor>{{minor}}</ReactNativeWindowsMinor>
<ReactNativeWindowsPatch>{{patch}}</ReactNativeWindowsPatch>
<ReactNativeWindowsCanary>{{canary}}</ReactNativeWindowsCanary>
<ReactNativeWindowsCommitId>{{commitId}}</ReactNativeWindowsCommitId>
</PropertyGroup>
</Project>
1 change: 1 addition & 0 deletions vnext/Desktop.DLL/React.Windows.Desktop.DLL.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
RNW_MAJOR=$(ReactNativeWindowsMajor);
RNW_MINOR=$(ReactNativeWindowsMinor);
RNW_PATCH=$(ReactNativeWindowsPatch);
RNW_COMMITID=$(ReactNativeWindowsCommitId);
_UNICODE;
UNICODE;
%(PreprocessorDefinitions)
Expand Down
7 changes: 5 additions & 2 deletions vnext/Desktop.DLL/Version.rc
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
#define VER_FILEVERSION_STR XSTRINGIZE(RNW_VERSION)
#define VER_FILEVERSION RNW_MAJOR,RNW_MINOR,RNW_PATCH,RNW_PKG_VERSION_BUILD

#define VER_PRODUCTVERSION_STR XSTRINGIZE(RNW_VERSION+RNW_COMMITID)
#define VER_PRODUCTVERSION RNW_MAJOR,RNW_MINOR,RNW_PATCH,RNW_PKG_VERSION_BUILD

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

VS_VERSION_INFO VERSIONINFO FILEVERSION VER_FILEVERSION PRODUCTVERSION
VS_VERSION_INFO VERSIONINFO FILEVERSION VER_PRODUCTVERSION 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",
Expand All @@ -27,7 +30,7 @@ VS_VERSION_INFO VERSIONINFO FILEVERSION VER_FILEVERSION PRODUCTVERSION
"(c) Microsoft Corporation. All rights reserved." VALUE "OriginalFilename",
"react-native-win32.dll" VALUE "ProductName",
"React-Native-Windows" VALUE "ProductVersion",
VER_FILEVERSION_STR END END
VER_PRODUCTVERSION_STR END END

BLOCK "VarFileInfo" BEGIN
/* The following line should only be modified for localized versions. */
Expand Down
1 change: 1 addition & 0 deletions vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@
RNW_MAJOR=$(ReactNativeWindowsMajor);
RNW_MINOR=$(ReactNativeWindowsMinor);
RNW_PATCH=$(ReactNativeWindowsPatch);
RNW_COMMITID=$(ReactNativeWindowsCommitId);
_UNICODE;
UNICODE;
%(PreprocessorDefinitions)
Expand Down
8 changes: 6 additions & 2 deletions vnext/Microsoft.ReactNative/Version.rc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#define VER_FILEVERSION_STR XSTRINGIZE(RNW_VERSION)
#define VER_FILEVERSION RNW_MAJOR,RNW_MINOR,RNW_PATCH,RNW_PKG_VERSION_BUILD

#define VER_PRODUCTVERSION_STR XSTRINGIZE(RNW_VERSION+RNW_COMMITID)
#define VER_PRODUCTVERSION RNW_MAJOR,RNW_MINOR,RNW_PATCH,RNW_PKG_VERSION_BUILD


#ifndef DEBUG
#define VER_DEBUG 0
#else
Expand All @@ -18,7 +22,7 @@

VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_FILEVERSION
PRODUCTVERSION VER_PRODUCTVERSION
FILEFLAGSMASK (VS_FF_DEBUG)
FILEFLAGS(VER_DEBUG)
FILEOS VOS__WINDOWS32
Expand All @@ -36,7 +40,7 @@ VALUE "InternalName", "Microsoft.ReactNative.dll"
VALUE "LegalCopyright", "(c) Microsoft Corporation. All rights reserved."
VALUE "OriginalFilename", "Microsoft.ReactNative.dll"
VALUE "ProductName", "React-Native-Windows"
VALUE "ProductVersion", VER_FILEVERSION_STR
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
END
END

Expand Down
1 change: 1 addition & 0 deletions vnext/PropertySheets/Generated/PackageVersion.g.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
<ReactNativeWindowsMinor>0</ReactNativeWindowsMinor>
<ReactNativeWindowsPatch>0</ReactNativeWindowsPatch>
<ReactNativeWindowsCanary>true</ReactNativeWindowsCanary>
<ReactNativeWindowsCommitId>a4b3e985d2361263dabf3155e3b2411f20213eb8</ReactNativeWindowsCommitId>
</PropertyGroup>
</Project>
2 changes: 2 additions & 0 deletions vnext/PropertySheets/PackageVersionDefinitions.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
RNW_MAJOR=$(ReactNativeWindowsMajor);
RNW_MINOR=$(ReactNativeWindowsMinor);
RNW_PATCH=$(ReactNativeWindowsPatch);
RNW_COMMITID=$(ReactNativeWindowsCommitId);
%(PreprocessorDefinitions)
</PreprocessorDefinitions>

Expand All @@ -31,6 +32,7 @@
RNW_MAJOR=$(ReactNativeWindowsMajor);
RNW_MINOR=$(ReactNativeWindowsMinor);
RNW_PATCH=$(ReactNativeWindowsPatch);
RNW_COMMITID=$(ReactNativeWindowsCommitId);
%(PreprocessorDefinitions)
</PreprocessorDefinitions>

Expand Down

0 comments on commit 87e36a8

Please sign in to comment.