Skip to content

Commit

Permalink
Add GitHub workflow for Choco release
Browse files Browse the repository at this point in the history
  • Loading branch information
t1m0thyj committed Jun 18, 2023
1 parent 6b31715 commit 020f6f8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/release-choco.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Publish to Chocolatey
on:
release:
types: [released]
workflow_dispatch:
inputs:
release_tag:
required: true
description: Tag of release you want to publish
type: string
jobs:
publish:
runs-on: windows-latest # choco can only be run on windows
steps:
- run: python scripts/publish_choco.py ${{ inputs.release_tag || github.event.release.tag_name }}
env:
CHOCO_APIKEY: ${{ secrets.CHOCO_APIKEY }}
7 changes: 4 additions & 3 deletions scripts/publish_choco.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ def write_file(filename, contents):
with open(filename, 'w', encoding="utf-8") as fileobj:
fileobj.write(contents)

r = requests.get("https://api.github.com/repos/t1m0thyj/WinDynamicDesktop/releases/latest")
release_tag = sys.argv[1] if len(sys.argv) > 1 else "latest"
r = requests.get(f"https://api.github.com/repos/t1m0thyj/WinDynamicDesktop/releases/{release_tag}")
response = r.json()
installer_url = next(a for a in response["assets"] if a["name"].endswith("x86_Setup.exe"))["browser_download_url"]
installer_url64 = next(a for a in response["assets"] if a["name"].endswith("x64_Setup.exe"))["browser_download_url"]
package_version = sys.argv[1] if len(sys.argv) > 1 else response["tag_name"][1:]
package_version = response["tag_name"].removeprefix("v")
replacers = {
"installerChecksum": installer_checksum(response["tag_name"], os.path.basename(installer_url)),
"installerUrl": installer_url,
Expand All @@ -60,6 +61,6 @@ def write_file(filename, contents):
write_file(script_filename, old_script)

nupkg_filename = f"windynamicdesktop.{package_version}.nupkg"
if input(f"Push {nupkg_filename}? (y/N) ").lower() == "y":
if os.getenv("CI") or input(f"Push {nupkg_filename}? (y/N) ").lower() == "y":
subprocess.run(["choco", "push", os.path.join(tempfile.gettempdir(), nupkg_filename), "-s", chocolatey_repo, "-k",
os.getenv("CHOCO_APIKEY")])
2 changes: 1 addition & 1 deletion src/WinDynamicDesktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageId>WinDynamicDesktop</PackageId>
<Product>WinDynamicDesktop</Product>
<Copyright>Copyright © 2023 Timothy Johnson</Copyright>
<Version>5.2.1</Version>
<Version>5.3.0</Version>
<ApplicationIcon>resources\WinDynamicDesktop.ico</ApplicationIcon>
<UseWindowsForms>true</UseWindowsForms>
<UseWPF>true</UseWPF>
Expand Down
2 changes: 1 addition & 1 deletion uwp/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10" IgnorableNamespaces="uap uap3 mp rescap desktop">
<Identity Name="38719TimothyJohnson.WinDynamicDesktop" Publisher="CN=3C822DA5-D64C-40A9-A84A-5502C3EDD8CD" Version="5.2.1.0" />
<Identity Name="38719TimothyJohnson.WinDynamicDesktop" Publisher="CN=3C822DA5-D64C-40A9-A84A-5502C3EDD8CD" Version="5.3.0.0" />
<Properties>
<DisplayName>WinDynamicDesktop</DisplayName>
<PublisherDisplayName>Timothy Johnson</PublisherDisplayName>
Expand Down

0 comments on commit 020f6f8

Please sign in to comment.