Skip to content

Commit

Permalink
Implement versioning (#163)
Browse files Browse the repository at this point in the history
* driver: Implement versioning for msbuild project
  - While in CI have to overwrite version.info file
* Implement versioning for android project
* Update release.yml
  • Loading branch information
ShootingKing-AM authored Jul 28, 2023
1 parent 134e176 commit 4e6ec68
Show file tree
Hide file tree
Showing 14 changed files with 235 additions and 50 deletions.
68 changes: 32 additions & 36 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
workflow_dispatch:
inputs:
version:
description: "Version string (eg. v0.3-beta)"
description: "Version string (eg. 0.3.1-beta)"
required: false
default: ""

Expand All @@ -31,53 +31,44 @@ jobs:
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
release_id: ${{ steps.create_release.outputs.id }}
release_ref: ${{ steps.output_ref.outputs.release_ref }}
steps:
### TODO: #74 Stream Line Versioning VisualStudio Desktop Project + Android Studio + ALVR Linking, then can automate bumping
# - name: Configure git
# run: git config --global core.autocrlf false
- name: Configure git
run: git config --global core.autocrlf false

# - uses: actions/checkout@v2
- uses: actions/checkout@v2

# - uses: actions-rs/toolchain@v1
# with:
# toolchain: stable
- name: Bump version
if: github.event.inputs.version != ''
run: |
$version = "${{ github.event.inputs.version }}"
$versionInt,$suffix = $version.Split('-')
$versioncomma = $versionInt.replace('.',',')
# - name: Bump version
# id: bump_version
# env:
# RUST_BACKTRACE: 1
# run: |
# $versionarg = "${{ github.event.inputs.version }}"
# $versionarg = If ($versionarg.Length -gt 0) { "--version $versionarg" } else { "" }
# $out = cargo xtask bump $versionarg.split()
# echo $out
# cargo update -p alvr_common
# echo "::set-output name=version_tag::$(echo $out | sls -CaseSensitive -Pattern '^v.*$')"
echo "#define PVR_BINVERSION $versioncomma" "#define PVR_STRVERSION `"$version`"" > code/common/src/version.info
echo "VERSION=$versionInt" "VERSION_NAME=$version" > code/mobile/android/PhoneVR/version.properties
# - name: Push changes
# uses: stefanzweifel/git-auto-commit-action@v4
# with:
# commit_message: "[Auto] Bump version"
- name: Push changes
if: github.event.inputs.version != ''
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "[Auto] Bump version"
tagging_message: v${{ github.event.inputs.version }}

# - name: Output ref for later checkouts
# id: output_ref
# run: echo "::set-output name=release_ref::$(git rev-parse HEAD)"
- name: Output ref for later checkouts
id: output_ref
run: echo "::set-output name=release_ref::$(git rev-parse HEAD)"

- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# tag_name: ${{ steps.bump_version.outputs.version_tag }}
tag: ${{ github.event.inputs.version }}
# release_name: PhoneVR ${{ steps.bump_version.outputs.version_tag }}
name: PhoneVR ${{ github.event.inputs.version }}
tag: v${{ github.event.inputs.version }}
name: PhoneVR v${{ github.event.inputs.version }}
draft: true
prerelease: false
generateReleaseNotes: true
commit: master
# commitish: ${{ steps.output_ref.outputs.release_ref }}
commit: ${{ steps.output_ref.outputs.release_ref }}

Build_PVR_Server:
name: Build PhoneVR Server
Expand All @@ -91,6 +82,8 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
ref: ${{ needs.prepare_release.outputs.release_ref }}

# https://github.com/actions/runner-images/issues/842#issuecomment-1495115166
- name: Install MSVC 2015 (v140) and Windows 8.1 SDK
Expand Down Expand Up @@ -131,6 +124,7 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
ref: ${{ needs.prepare_release.outputs.release_ref }}
submodules: 'true'

# Set Current Date As Env Variable
Expand Down Expand Up @@ -234,7 +228,7 @@ jobs:
with:
upload_url: ${{ needs.prepare_release.outputs.upload_url }}
asset_path: ${{env.GRADLE_DIR}}/${{ env.MAIN_PROJECT_MODULE }}/build/outputs/apk/release/PhoneVR.apk
asset_name: PhoneVR-${{ github.event.inputs.version }}.apk
asset_name: PhoneVR-v${{ github.event.inputs.version }}.apk
asset_content_type: application/vnd.android.package-archive

# Step is needed because the PVRServerBuild runs as a matrix and adds files to the same artifact
Expand All @@ -245,6 +239,8 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
ref: ${{ needs.prepare_release.outputs.release_ref }}

- uses: actions/download-artifact@v3
with:
Expand All @@ -269,5 +265,5 @@ jobs:
with:
upload_url: ${{ needs.prepare_release.outputs.upload_url }}
asset_path: ${{ env.PROJECT_NAME }}-Server-Release.zip
asset_name: ${{ env.PROJECT_NAME }}-Server-${{ github.event.inputs.version }}.zip
asset_name: ${{ env.PROJECT_NAME }}-Server-v${{ github.event.inputs.version }}.zip
asset_content_type: application/gzip
10 changes: 8 additions & 2 deletions code/common/src/PVRGlobals.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,14 @@ inline uint32_t vers2uint(uint8_t rel, uint8_t sub, uint16_t patch) {
return rel << 24 | sub << 16 | patch;
}

#define PVR_SERVER_VERSION vers2uint(0, 6, 0)
#define PVR_CLIENT_VERSION vers2uint(0, 6, 0)
inline std::string versunint2str(uint32_t ver) {
return ( std::to_string(ver >> 24) + "." + std::to_string((ver >> 16) % 0x100) + "." + std::to_string((ver & 0xffff)) );
}

#include "version.info"

#define PVR_SERVER_VERSION vers2uint(PVR_BINVERSION)
#define PVR_CLIENT_VERSION vers2uint(PVR_BINVERSION)

std::wstring _GetExePath(void);

Expand Down
2 changes: 2 additions & 0 deletions code/common/src/version.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#define PVR_BINVERSION 1,0,0
#define PVR_STRVERSION "1.0.0-beta"
8 changes: 4 additions & 4 deletions code/mobile/android/PhoneVR/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply from: '../versioning.gradle'

def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
Expand Down Expand Up @@ -37,8 +38,8 @@ android {
applicationId "viritualisres.phonevr"
minSdkVersion 24
targetSdkVersion 33
versionCode Integer.valueOf(System.env.APPVEYOR_BUILD_NUMBER ?: 1)
versionName System.getenv("APPVEYOR_PVR_TAG")
versionCode buildVersionCode()
versionName buildVersionName()

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments useTestStorageService: 'true'
Expand All @@ -54,7 +55,7 @@ android {

defaultPublishConfig 'release'
publishNonDefault true
archivesBaseName = "PhoneVR-v$versionCode($versionName)"
archivesBaseName = "PhoneVR-v$versionName"
}
buildTypes {
release {
Expand Down Expand Up @@ -178,4 +179,3 @@ preBuild.dependsOn(buildClientLib)
build.dependsOn(extractNdk)
build.dependsOn(buildClientLib)
clean.dependsOn(deleteNdk)

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class InitActivity : AppCompatActivity() {
setContentView(R.layout.activity_init)

val tvVersion : TextView = findViewById<TextView>(R.id.head);
tvVersion.text = "PhoneVR v" + BuildConfig.VERSION_NAME + "_" + BuildConfig.VERSION_CODE;
tvVersion.text = "PhoneVR v" + BuildConfig.VERSION_NAME;

val result = HtmlCompat.fromHtml("<a href=\"https://github.com/PhoneVR-Developers/PhoneVR#readme\">Readme.md</a>", HtmlCompat.FROM_HTML_MODE_LEGACY);
val tvBody = findViewById<TextView>(R.id.body);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class MainActivity : AppCompatActivity() {
}

val VersionTV : TextView = findViewById<TextView>(R.id.tViewVersion);
VersionTV.text = "PhoneVR v" + BuildConfig.VERSION_NAME + "_" + BuildConfig.VERSION_CODE;
VersionTV.text = "PhoneVR v" + BuildConfig.VERSION_NAME;

// MediaCodecInfo[] dmsadas = (new MediaCodecList(MediaCodecList.REGULAR_CODECS)).getCodecInfos();
// for (MediaCodecInfo mci : dmsadas){
Expand Down
2 changes: 2 additions & 0 deletions code/mobile/android/PhoneVR/version.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VERSION=1.0.0
VERSION_NAME=1.0.0-beta
18 changes: 18 additions & 0 deletions code/mobile/android/PhoneVR/versioning.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ext {
versionProps = {
def props = new Properties()
file("../version.properties").withInputStream { props.load(it) }
return props
}
buildVersionCode = {
def props = versionProps()
def version = props.getProperty("VERSION")
def (major, minor, patch) = version.toLowerCase().tokenize('.')
(major, minor, patch) = [major, minor, patch].collect { it.toInteger() }
(major * 10000) + (minor * 100) + patch
}
buildVersionName = {
def props = versionProps()
return props.getProperty("VERSION_NAME")
}
}
5 changes: 4 additions & 1 deletion code/windows/PhoneVR/PhoneVR/PVRSockets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,12 @@ void PVRStartConnectionListener(function<void(string, PVR_MSG)> callback) {
auto msgType = (PVR_MSG)buf[3];
if (msgType == PVR_MSG::PAIR_HMD || msgType == PVR_MSG::PAIR_PHONE_CTRL) {
if (vec2uint(&buf[4]) >= PVR_CLIENT_VERSION)
{
PVR_DB_I("[PVRSockets::PVRStartConnectionListener] Server v" + versunint2str(PVR_SERVER_VERSION) + " connected to Client v" + versunint2str(vec2uint(&buf[4])) );
callback(ip, msgType);
}
else
PVR_DB_I("[PVRSockets::PVRStartConnectionListener] Device " + ip + " needs to be updated");
PVR_DB_I("[PVRSockets::PVRStartConnectionListener] Device " + ip + " needs to be updated, " + "Server v" + versunint2str(PVR_SERVER_VERSION) + " connected to Client v" + versunint2str(vec2uint(&buf[4])));
}
else
PVR_DB_I("[PVRSockets::PVRStartConnectionListener] Invalid message from device: " + ip);
Expand Down
27 changes: 23 additions & 4 deletions code/windows/PhoneVR/PhoneVR/PhoneVR.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,16 @@
<WarningLevel>Level1</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_WIN32_WINNT=0x0601;WIN32;_DEBUG;_WINDOWS;_USRDLL;PHONEVR_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\$(ProjectDir);$(SolutionDir)\..\..\common\src;$(SolutionDir)\..\libs\json;$(SolutionDir)\..\libs\x264\include;$(SolutionDir)\..\..\common\libs\asio;$(SolutionDir)\..\..\common\libs\eigen;$(SolutionDir)\..\..\common\src\Utils;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)\$(ProjectName);$(SolutionDir)\..\..\common\src;$(SolutionDir)\..\libs\json;$(SolutionDir)\..\libs\x264\include;$(SolutionDir)\..\..\common\libs\asio;$(SolutionDir)\..\..\common\libs\eigen;$(SolutionDir)\..\..\common\src\Utils</AdditionalIncludeDirectories>
<LanguageStandard>stdcpplatest</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalLibraryDirectories>$(SolutionDir)\..\libs\x264\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<ResourceCompile>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\common\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
Expand All @@ -109,7 +112,7 @@
</PrecompiledHeader>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_WIN32_WINNT=0x0601;_DEBUG;_WINDOWS;_USRDLL;PHONEVR_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\$(ProjectName);$(SolutionDir)\..\..\common\src;$(SolutionDir)\..\libs\json;$(SolutionDir)\..\libs\x264\include;$(SolutionDir)\..\..\common\libs\asio;$(SolutionDir)\..\..\common\libs\eigen;$(SolutionDir)\..\..\common\src\Utils;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)\$(ProjectName);$(SolutionDir)\..\..\common\src;$(SolutionDir)\..\libs\json;$(SolutionDir)\..\libs\x264\include;$(SolutionDir)\..\..\common\libs\asio;$(SolutionDir)\..\..\common\libs\eigen;$(SolutionDir)\..\..\common\src\Utils;$(SolutionDir)\..\..\common\src\</AdditionalIncludeDirectories>
<LanguageStandard>stdcpplatest</LanguageStandard>
</ClCompile>
<Link>
Expand All @@ -119,6 +122,9 @@
<PostBuildEvent>
<Command>xcopy "$(SolutionDir)$(Configuration)\$(Platform)" "C:\Program Files (x86)\Steam\steamapps\common\SteamVR\drivers\PVRServer\bin\win64" /h /i /c /k /e /r /y</Command>
</PostBuildEvent>
<ResourceCompile>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\common\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
Expand All @@ -129,7 +135,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>_WIN32_WINNT=0x0601;WIN32;NDEBUG;_WINDOWS;_USRDLL;PHONEVR_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\$(ProjectName);$(SolutionDir)\..\..\common\src;$(SolutionDir)\..\libs\json;$(SolutionDir)\..\libs\x264\include;$(SolutionDir)\..\..\common\libs\asio;$(SolutionDir)\..\..\common\libs\eigen;$(SolutionDir)\..\..\common\src\Utils;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)\$(ProjectName);$(SolutionDir)\..\..\common\src;$(SolutionDir)\..\libs\json;$(SolutionDir)\..\libs\x264\include;$(SolutionDir)\..\..\common\libs\asio;$(SolutionDir)\..\..\common\libs\eigen;$(SolutionDir)\..\..\common\src\Utils</AdditionalIncludeDirectories>
<LanguageStandard>stdcpplatest</LanguageStandard>
</ClCompile>
<Link>
Expand All @@ -138,6 +144,9 @@
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(SolutionDir)\..\libs\x264\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<ResourceCompile>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\common\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
Expand All @@ -148,7 +157,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>_WIN32_WINNT=0x0601;NDEBUG;_WINDOWS;_USRDLL;PHONEVR_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\$(ProjectName);$(SolutionDir)\..\..\common\src;$(SolutionDir)\..\libs\json;$(SolutionDir)\..\libs\x264\include;$(SolutionDir)\..\..\common\libs\asio;$(SolutionDir)\..\..\common\libs\eigen;$(SolutionDir)\..\..\common\src\Utils;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)\$(ProjectName);$(SolutionDir)\..\..\common\src;$(SolutionDir)\..\libs\json;$(SolutionDir)\..\libs\x264\include;$(SolutionDir)\..\..\common\libs\asio;$(SolutionDir)\..\..\common\libs\eigen;$(SolutionDir)\..\..\common\src\Utils</AdditionalIncludeDirectories>
<LanguageStandard>stdcpplatest</LanguageStandard>
</ClCompile>
<Link>
Expand All @@ -160,6 +169,9 @@
<PostBuildEvent>
<Command>xcopy "$(SolutionDir)$(Configuration)\$(Platform)" "C:\Program Files (x86)\Steam\steamapps\common\SteamVR\drivers\PVRServer\bin\win64" /h /i /c /k /e /r /y</Command>
</PostBuildEvent>
<ResourceCompile>
<AdditionalIncludeDirectories>$(SolutionDir)\..\..\common\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\common\src\PVRGlobals.cpp" />
Expand All @@ -179,6 +191,13 @@
<ClInclude Include="PVRFileManager.h" />
<ClInclude Include="PVRMath.h" />
<ClInclude Include="PVRSockets.h" />
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="resource.rc" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\common\src\version.info" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
13 changes: 13 additions & 0 deletions code/windows/PhoneVR/PhoneVR/PhoneVR.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,18 @@
<ClInclude Include="..\..\..\common\src\Utils\ThreadUtils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="resource.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\common\src\version.info">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion code/windows/PhoneVR/PhoneVR/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class HMD : public ITrackedDeviceServerDriver, public IVRDisplayComponent, publi
VRProperties()->SetBoolProperty(propCont, Prop_DeviceCanPowerOff_Bool, true);
//VRProperties()->SetInt32Property(propCont, Prop_DeviceClass_Int32, TrackedDeviceClass_HMD);
VRProperties()->SetBoolProperty(propCont, Prop_HasCamera_Bool, false);
VRProperties()->SetStringProperty(propCont, Prop_DriverVersion_String, (to_string(PVR_SERVER_VERSION >> 24) + "." + to_string((PVR_SERVER_VERSION >> 16) % 0x100)).c_str());
VRProperties()->SetStringProperty(propCont, Prop_DriverVersion_String, versunint2str(PVR_SERVER_VERSION).c_str());
VRProperties()->SetBoolProperty(propCont, Prop_Firmware_ForceUpdateRequired_Bool, false); //TODO implement
//VRProperties()->SetBoolProperty(propCont, Prop_ViveSystemButtonFixRequired_Bool, false); // ??
VRProperties()->SetBoolProperty(propCont, Prop_ReportsTimeSinceVSync_Bool, false);
Expand Down
14 changes: 14 additions & 0 deletions code/windows/PhoneVR/PhoneVR/resource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by version.rc

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
Loading

0 comments on commit 4e6ec68

Please sign in to comment.