Skip to content

Commit

Permalink
New project tooling, 4.0.6 updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
walterpg committed Mar 20, 2021
1 parent c0a0650 commit a49cf6d
Show file tree
Hide file tree
Showing 13 changed files with 306 additions and 494 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,6 @@ src/GdsDefs.Data.cs

# Private key for release version signing.
lib/src/GenVerInfo/PrivateKey.xml

# More VS-generated backups
MigrationBackup*/
122 changes: 49 additions & 73 deletions BUILDME.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# Building and Releasing
### Build Tools
* Visual Studio for Windows. Currently, releases are built with
[Visual Studio Community](https://visualstudio.microsoft.com/vs/community),
but any updated version/edition of Visual Studio 2017 or later should suffice.
* [nuget.exe](https://www.nuget.org/downloads/) command-line tool in the current PATH.
* [Zip](https://en.wikipedia.org/wiki/ZIP_(file_format)) command-line tool
([7zip](https://www.7-zip.org/) recommended).
* Visual Studio for Windows. Currently, releases are built with [Visual Studio Community](https://visualstudio.microsoft.com/vs/community), but any updated version/edition of Visual Studio 2017 or later should suffice. A migration to `dotnet` CLI is in work, but it will likely require a higher target framework dependency for the plugin.
* [Zip](https://en.wikipedia.org/wiki/ZIP_(file_format)) command-line tool ([7zip](https://www.7-zip.org/) recommended).
* (optional) [Pandoc](https://pandoc.org/) command-line tool

### Setup
Expand All @@ -17,9 +13,7 @@ set msbuildcmd="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Co
set pandoc="%LOCALAPPDATA%\Pandoc\pandoc.exe"
```

Modify them if necessary to match the paths to the ``VsMSBuildCmd.bat`` and zip
tool. Note that ``pandoc`` is used to generate an "ascii" version of README.md
and is not required to successfully build the project.
Modify them if necessary to match the paths to the ``VsMSBuildCmd.bat`` and zip tool. Note that ``pandoc`` is used to generate a plain-text version of README.md for a software release, and is not required to successfully build the project.

### Build
Run ``BuildMe.bat``.
Expand All @@ -30,96 +24,78 @@ If successful, the ``build`` directory contains three subdirectories:
* ``dist``: release PLGX, ZIP, and text documentation files.
* ``log``: contains build status logging.

As a convenience, the build script also updates the version manifest
file ``kpsync_version_4.txt``. See
[Posting a Release](#posting-a-release) below for details.
As a convenience, the build script also updates the version manifest file ``kpsync_final.txt``. See [Posting a Release](#posting-a-release) below for details.

### Preparing for Release
Release versioning should be clear and consistent, and is critical for
supporting the "Check for Updates" command in KeePass.
Release version notation should be clear and consistent. This is critical for supporting the "Check for Updates" command in KeePass. KeePass looks for the `[AssemblyVersion]` attribute for the update check using the `v.r.u` three-integer scheme. The `[AssemblyInformationalVersion]` attribute should be used to reflect the *matching* git tag for the release.

Update the release tag version strings with [SemVer](https://semver.org)-compatible version strings:
* ``set version=`` at the top of ``BuildMe.bat``
* ``src\Properties\AssemblyInfo.cs``: all ``a.b.c`` version values should be the same,
and the ``.d`` suffix, *if* specified, should always be 0. For example, ``0.1.0.0``.

Suppose the version of the current development cycle is
``0.1.0-unstable``. Thus the release tag could be
``0.1.0-alpha``, which will be used in the following examples.

The release tag string must be passed to the attribute constructor of
``AssemblyInformationalVersion`` in ``AssemblyInfo.cs``:

```
[assembly: AssemblyInformationalVersion("0.1.0-alpha")]
```

The ``AssemblyVersion`` and ``AssemblyFileVersion`` attributes should only
be assigned ``a.b.c`` or preferrably ``a.b.c.d`` version numbers. They should
also "match" the release tag string:
Create tag version strings with [SemVer](https://semver.org)-compatible strings:
* ``set versionPrefix=`` and ``set versionSuffix=`` at the top of ``BuildMe.bat`` to reflect the tagged version ID, e.g., "4.0.6-beta".
* ``versionPrefix`` will reflect the "check for updates" version.

For example, if the tag version should be "4.0.6-beta" edit ``BuildMe.bat`` to modify the ``set`` commands as shown:
```
[assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyFileVersion("0.1.0.0")]
```

Finally, the same release tag string must be used to update ``BuildMe.bat``.
Using the same example above:

```
set version=0.1.0-alpha
set versionPrefix=4.0.6
set versionSuffix=beta
```

### Tagging a Release

Document the release in ``ChangeLog.md``.

Commit ``AssemblyInfo.cs``, ``ChangeLog.md``, and any remaining
release changes. Only commit ``BuildMe.bat`` if something else besides the version
number changed.
Commit ``ChangeLog.md``, and any remaining release changes. Only commit ``BuildMe.bat`` if something else besides the version number changed.

*DO NOT* commit changes, if any, to the following files:
```
kpsync_version_4.txt
kpsync_final.txt
src/GdsDefs.OAuthCreds.txt
```

You may eventually commit ``kpsync_version_4.txt``,
if you [post a release](#posting-a-release), **but the other file
must never be committed to remote**. And it should remain in the repo
as-is.
You may eventually commit ``kpsync_final.txt``, if you [post a release](#posting-a-release), **but `src/GdsDefs.OAuthCreds.txt` must never be committed to remote**. And it should remain in the repo as-is.

>###### *Hint*
>The `GdsDefs.OAuthCreds.txt` file is a special case in source code control; it contains "placeholder" content that *usually* must be changed before a development activity but never committed. Ordinarily, leaving the file "untracked" and using the `.gitignore` file is a good way to avoid committing sensitive data. The subtlety here is that the originally committed, tracked file contains "fake data" - useful for, say, a CI test build of a freshly cloned branch, but not for developing or releasing software. If the file were untracked and specified in `.gitignore`, such a build would fail without intervention between cloning the branch and building. Also, in this case, the fake data includes information on its usage which should be retained. There is no single, perfect solution here known to this author. Below is *one* approach to the problem.
>
>Use the following [command](https://www.git-scm.com/docs/git-update-index#Documentation/git-update-index.txt---no-assume-unchanged) to set the "assume unchanged bit" on the file:
>
> ```sh
>git update-index --assume-unchanged src/GdsDefs.OAuthCreds.txt`
>```
>This forces git to ignore changes to the file in the **local repo**, even though it is still "tracked" in the index and remote branch. This way, local changes to the file do not show in `git status`, VisualStudio, etc., helping to prevent accidental commits. This technique is particularly useful when preparing commits for a posted release.
>
>Note however, the assume-unchanged bit may (safely) change the behavior of other git commands and tools. In the event of a commit of the file in the remote repo, errors will occur in `git pull`, et.al., performed on a local repo. In such cases, reset the bit (and for safety stash the local copy) then deal with the changed remote file:
>
> ```sh
>git update-index --no-assume-unchanged src/GdsDefs.OAuthCreds.txt
># Optionally stash the local changes.
>git stash push src/GdsDefs.OauthCreds.Txt
># Do the git op that failed before flipping the bit.
>git pull
># In the case of pull, etc., get local changes back to resolve differences.
>git stash pop
># Optionally set the bit again.
>git update-index --assume-unchanged src/GdsDefs.OAuthCreds.txt
>```
Ensure there are no build errors by running ``BuildMe.bat``.
Tag the release with the release tag string used to set the version in
the [previous section](#preparing-for-release).
Tag the release with the release tag string used to set the version in the [previous section](#preparing-for-release).
Before running the "final" release build, edit ``GdsDefs.OAuthCreds.txt``
to insert the valid "built-in" credentials. Again, never commit this file to
remote, lest you post your clear-text OAuth 2.0 credentials to the world.
Before running the "final" release build, edit ``GdsDefs.OAuthCreds.txt`` to insert the valid "built-in" credentials. Again, never commit this file to remote, lest you post your clear-text OAuth 2.0 credentials to the world.
Produce the release binaries with ``BuildMe.bat``.
### Posting a Release
"Draft" a new release on github with the tag created in the [previous
section](#tagging-a-release).

Try to do all of the following the steps, after the first, in a single
commit/push (the first step doesn't require a commit). This helps
ensure that new releases are not detected by the public or KeePass
before they are actually available.

1. Upload the binaries. At the moment these are simply appended as
"assets" to the github tag/release post.
2. Ensure ``kpsync_version_4.txt`` is correct before committing it.
It is mechanically updated by ``BuildMe.bat``, and if it doesn't match the
tagged release version, there is something wrong in ``AssemblyInfo.cs``; fix
it, run ``BuildMe.bat`` again, and start again at step 1.
3. Update ``AssemblyInformationalVersion`` in ``AssemblyInfo.cs``
a final time, to reflect the next, post-release development cycle. For
"Draft" a new release on Github with the tag created in the [previous section](#tagging-a-release).
Try to do all of the following the steps, after the first, in a single commit/push (the first step doesn't require a commit). This helps
ensure that new releases are not detected by the public or KeePass before they are actually available.
1. Upload the binaries. At the moment these are simply appended as "assets" to the Github tag/release post.
2. Ensure ``kpsync_final.txt`` is correct before committing it. It is mechanically updated by ``BuildMe.bat``, and if it doesn't match the tagged release version, there is something wrong with ``versionPrefix``; fix it, run ``BuildMe.bat`` again, and start again at step 1.
3. Update ``<VersionPrefix>`` in ``KPSyncForDrive.csproj``, to reflect the next, post-release development cycle. For
example, ``0.1.0-alpha`` &#x21D2; ``0.1.0-unstable``.
Commit and push the above changes. If this is a versioned release,
verify that KeePass detects it via the "Check for Updates" command.
Commit and push the above changes. If this is a generally-available release, install and verify that KeePass detects it via the "Check for Updates" command.
38 changes: 20 additions & 18 deletions BuildMe.bat
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
::
::
:: Google Sync Plugin for KeePass Password Safe
:: Copyright © 2012-2016 DesignsInnovate
:: Copyright © 2014-2016 Paul Voegler
::
::
:: KPSync for Google Drive
:: Copyright © 2020-2021 Walter Goodwin
::
::
:: This program is free software: you can redistribute it and/or modify
:: it under the terms of the GNU General Public License as published by
:: the Free Software Foundation, either version 3 of the License, or
Expand All @@ -15,18 +15,21 @@
:: but WITHOUT ANY WARRANTY; without even the implied warranty of
:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
:: GNU General Public License for more details.
::
::
:: You should have received a copy of the GNU General Public License
:: along with this program. If not, see <http://www.gnu.org/licenses/>.
::
::

@echo off

set archname=KPSyncForDrive
set kp_version_manifest_name=kpsync_final
set version=4.0.5-unstable
set versionPrefix=4.0.6
set versionSuffix=beta
set netsdkver=net45

set sevenzip="%ProgramFiles%\7-Zip\7z.exe"
:: set dotnetPgm="%ProgramFiles%\dotnet\dotnet.exe"
set msbuildcmd="%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\Common7\Tools\VsMSBuildCmd.bat"
set pandoc="%LOCALAPPDATA%\Pandoc\pandoc.exe"

Expand All @@ -36,22 +39,21 @@ call %msbuildcmd%

if not exist build mkdir build
del /s /f /q build\*
for /d %%o in (build\*) do rmdir "%%o" /s /q

if not exist build\bin mkdir build\bin
if not exist build\dist mkdir build\dist
if not exist build\log mkdir build\log
del /s /f /q build\bin\*
rmdir /s /q build\bin\*
del /s /f /q build\dist\*
del /s /f /q build\log\*
mkdir build\bin
mkdir build\dist
mkdir build\log

msbuild -t:clean,restore,build -p:Configuration=Release;Platform="Any CPU" -flp:logfile=build\log\build.log GoogleDriveSync.sln
:: TODO modify project(s) to use `dotnet msbuild`. May require net461
:: runtime support. See https://github.com/dotnet/msbuild/issues/4704
msbuild -t:clean,restore,build -m -p:TargetFramework=%netsdkver% -p:Configuration=Release;Platform="Any CPU" -flp:logfile=build\log\build.log GoogleDriveSync.sln
if %errorlevel% NEQ 0 goto error

xcopy src\bin\Release\*.* build\bin /e /h
copy src\bin\Release\%archname%.plgx build\dist\%archname%-%version%.plgx
%sevenzip% a -tzip -r build\dist\%archname%-%version%.zip .\build\bin\*.dll .\build\bin\*.pdb .\build\bin\es\*
.\lib\src\GenVerInfo\bin\Release\GenVerInfo.exe .\build\bin\%archname%.dll .\%kp_version_manifest_name%.txt
xcopy src\bin\Release\%netsdkver%\*.* build\bin /e /h
copy build\bin\*.plgx build\dist\
%sevenzip% a -tzip -r build\dist\%archname%-%versionPrefix%-%versionSuffix%.zip .\build\bin\*.dll .\build\bin\*.pdb .\build\bin\es\*
.\lib\src\GenVerInfo\bin\Release\%netsdkver%\GenVerInfo.exe .\build\bin\%archname%.dll .\%kp_version_manifest_name%.txt

if not exist %pandoc% goto end
%pandoc% -f gfm -t plain --wrap=auto doc\README.md -o build\dist\readme.txt
Expand Down
19 changes: 19 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
## 4.0.6-beta

* #31 REBRANDING. The name of the plugin has changed yet again, this time in deference to KP preferences. This is the first release with the new name, matching changes already made to the [website](https://kpsync.org) and the Google Sign-in consent screen. See further notes below regarding this change.
* Internal changes to project tooling used to create releases.
* Documentation updates for the above changes.

#### Release Notes: "KPSync for Google Drive"
This is almost a purely cosmetic update. For that reason you may wish to skip this release. If so, be aware that the Google Sign-in screen will reflect the new plugin name, even when used with a prior release. If you do eventually update to a new release, be vigilant regarding the names of the component files, past and present.

The upgrade is similar to the prior "ALPHA" plugin upgrade, [the notes for which have been updated to include details for this upgrade](https://www.kpsync.org/install/upgrade0). In short, the names of some major component files have changed. Before installing the upgrade, remove prior release files with the following name *prefixes* from the KP installation and Plugins folders, and clear the [KP plugin cache](https://keepass.info/help/v2/plugins.html#cache):

* KeePassSyncForDrive
* GoogleDriveSync

The file prefix name is now **KPSyncForDrive**. This will be used in the name of the portable zip file, the .PLGX file, and the plugin assembly .DLL file.

If you spot a problem or need a new feature, [please raise an issue](https://github.com/walterpg/google-drive-sync/issues)! Thanks for your help.

---
## 4.0.5-beta

* Transparently support [Drive shortcuts](https://support.google.com/drive/answer/9700156?co=GENIE.Platform%3DDesktop&oco=1) (issue #20).
Expand Down
3 changes: 3 additions & 0 deletions kpsync_final.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:KAicLftNCeRMnM+M5nTh9CNNIAcBVlGxgblzXqNSqIIufj7phYP8sqc8/RpwNzAPPc4FpTrxo//fxx3+7j2RoMc/pR4bW4TocxZcADZmWBDPEubfAYAV17a1+zLgukdT5LOydvBjNrCsJ51npjxywIkQWKiN1Yk8qjuPrbHaggkuy7A/9EglNWRVKGZWcf55zqvBk05D6AzSwCHC6qwmTamw7wVeXYc5dq8PgM8nGwqZlxYQLAObdq0nMPj2R3tClgPVmik3fpfLLSJO5DfMPJDUoebt+Uu3S17vOgAwDeisHsn9eW0Z96nVhC/zTUHMCYdIhnY8xsDK2ctlOfBSIXaWrrfv09hHe0hq1yj1RZpt9EBy6GTElJEwdwqygZf8aclwVQcPMhPMrmGaqHuRz452OICJVRJkvRRrUJbf37t2UmrDy16Q/sVTf5TbuSn0kYzYZeOspnyG85Pd3zqiTQAWLiT2D/7BedIlawNnJP5Sy3zGcmeyOT7xhLdk7DrCzjXijEPEaFJS5apFI70/adXKAb6/RwQ77mSiAVofkIXk4397+jh9TSYrwo90dk8SrTaliI6i0ZP0psU3xnvFPno3BmyP7mXzneUWXqe9TW6D38vUR5KB2uMGY9c81UeEwWu9hUTs00heORr1VWvxePv6r9iais2gTZXZI5irv6A=
KPSync For Google Drive:4.0.6.0
:
79 changes: 26 additions & 53 deletions lib/src/GenClientId/GenClientId.csproj
Original file line number Diff line number Diff line change
@@ -1,53 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F7B92FBF-F5D8-45E0-B357-4CA8F05AD652}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>GenClientId</RootNamespace>
<AssemblyName>GenClientId</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="KeePass">
<HintPath>..\..\bin\KeePass.exe</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Generator.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net45</TargetFramework>
<Version>1.0.0</Version>
<FileVersion>1.0.0.0</FileVersion>
<Product>KPSync For Google Drive</Product>
<Title>GenClientId</Title>
<Description>Build-time helper for credential obfuscation.</Description>
<Copyright>Copyright © 2020-2021</Copyright>
<NeutralLanguage>en-US</NeutralLanguage>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>DEBUG;$(DefineConstants)</DefineConstants>
</PropertyGroup>

<ItemGroup>
<Reference Include="KeePass">
<HintPath>..\..\bin\KeePass.exe</HintPath>
</Reference>
</ItemGroup>

</Project>
Loading

0 comments on commit a49cf6d

Please sign in to comment.