Skip to content

Commit

Permalink
Try to fix versioning in AppVeyor build
Browse files Browse the repository at this point in the history
  • Loading branch information
t1m0thyj committed Dec 24, 2020
1 parent eb72283 commit 974b83c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
7 changes: 4 additions & 3 deletions appveyor.yml
Expand Up @@ -2,14 +2,15 @@ version: 1.0.{build}
skip_branch_with_pr: true
image: Visual Studio 2019
configuration: Release
init:
- ps: "$assemblyFile = \"$env:APPVEYOR_BUILD_FOLDER\\src\\Properties\\AssemblyInfo.cs\"\n\n$regex = new-object System.Text.RegularExpressions.Regex ('(AssemblyVersion(Attribute)?\\s*\\(\\s*\\\")(.*)(\\\"\\s*\\))', \n [System.Text.RegularExpressions.RegexOptions]::MultiLine)\n\n$content = [IO.File]::ReadAllText($assemblyFile)\n\n$version = $null\n$match = $regex.Match($content)\nif($match.Success) {\n $version = $match.groups[3].value\n}\n\n# new version\n$version = \"$version.$env:APPVEYOR_BUILD_NUMBER\"\n\n# update assembly info\n$content = $regex.Replace($content, '${1}' + $version + '${4}')\n[IO.File]::WriteAllText($assemblyFile, $content)\n\n# update AppVeyor build\nUpdate-AppveyorBuild -Version $version"
environment:
UseTemporarySignCert: true
install:
- ps: choco install innosetup -y -r
before_build:
- ps: nuget restore src\WinDynamicDesktop.sln
- ps: >-
powershell scripts\prebuild_appveyor.ps1
nuget restore src\WinDynamicDesktop.sln
build:
verbosity: minimal
after_build:
Expand Down
25 changes: 25 additions & 0 deletions scripts/prebuild_appveyor.ps1
@@ -0,0 +1,25 @@
# Update global assemblyinfo with build number
# https://gist.github.com/FeodorFitsner/82dad08650d72268e48d

$assemblyFile = "$env:APPVEYOR_BUILD_FOLDER\src\Properties\AssemblyInfo.cs"

$regex = new-object System.Text.RegularExpressions.Regex ('(AssemblyVersion(Attribute)?\s*\(\s*\")(.*)(\"\s*\))',
[System.Text.RegularExpressions.RegexOptions]::MultiLine)

$content = [IO.File]::ReadAllText($assemblyFile)

$version = $null
$match = $regex.Match($content)
if($match.Success) {
$version = $match.groups[3].value
}

# new version
$version = "$version.$env:APPVEYOR_BUILD_NUMBER"

# update assembly info
$content = $regex.Replace($content, '${1}' + $version + '${4}')
[IO.File]::WriteAllText($assemblyFile, $content)

# update AppVeyor build
Update-AppveyorBuild -Version $version
2 changes: 1 addition & 1 deletion scripts/publish_choco.py
Expand Up @@ -35,7 +35,7 @@ def write_file(filename, contents):

r = requests.get("https://api.github.com/repos/t1m0thyj/WinDynamicDesktop/releases/latest")
response = r.json()
installer_url = response["assets"][0]["browser_download_url"]
installer_url = next(a for a in response["assets"] if a["name"].endswith("Setup.exe"))["browser_download_url"]
package_version = response["tag_name"][1:]
replacers = {
"installerChecksum": sha256_checksum("../dist/" + os.path.basename(installer_url)),
Expand Down

0 comments on commit 974b83c

Please sign in to comment.