Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement initial chocolatey packaging workflow #1400

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/scripts/chocolatey/dapr.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>dapr</id>
<version>dapr_cli_version</version>
<packageSourceUrl>https://github.com/dapr/cli/tree/master/.github/scripts/chocolatey</packageSourceUrl>
<owners>mikeee, dapr</owners>
<title>Dapr CLI (Install)</title>
<authors>The Dapr Authors</authors>
<projectUrl>https://dapr.io/</projectUrl>
<iconUrl>https://cdn.jsdelivr.net/gh/dapr/website/static/images/dapr.svg</iconUrl>
<copyright>Copyright 2021 The Dapr Authors</copyright>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<copyright>Copyright 2021 The Dapr Authors</copyright>
<copyright>Copyright 2024 The Dapr Authors</copyright>

<licenseUrl>https://github.com/dapr/cli/blob/master/LICENSE</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<projectSourceUrl>https://github.com/dapr/cli</projectSourceUrl>
<docsUrl>https://docs.dapr.io/reference/cli/cli-overview/</docsUrl>
<bugTrackerUrl>https://github.com/dapr/cli/issues</bugTrackerUrl>
<tags>dapr distributed application runtime cli kubernetes</tags>
<summary>The Dapr CLI is the main tool for running Dapr-related tasks</summary>
<description>
The Dapr CLI allows you to setup Dapr on your local dev machine or on a Kubernetes cluster, provides debugging support, and launches and manages Dapr instances.

Dapr is a set of integrated APIs with built-in best practices and patterns to build distributed applications. Dapr increases your developer productivity by 20-40% with out-of-the-box features such as workflow, pub/sub, state management, secret stores, external configuration, bindings, actors, distributed lock, and cryptography. You benefit from the built-in security, reliability, and observability capabilities, so you don't need to write boilerplate code to achieve production-ready applications.
</description>
<releaseNotes>https://github.com/dapr/cli/releases</releaseNotes>
</metadata>
<files>
<file src="tools\**" target="tools" />
</files>
</package>
16 changes: 16 additions & 0 deletions .github/scripts/chocolatey/tools/chocolateyInstall.ps1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also provide scripts to uninstall and upgrade? (I understand this is a first implementation, shooting my ideas).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chocolatey includes an autoinstaller - I've validated this works with the msi installer/uninstaller

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
$root = Join-Path "$(Split-Path -Parent $MyInvocation.MyCommand.Definition)" "install"
$packageArgs = @{
packageName = $env:ChocolateyPackageName
unzipLocation = $root
fileType = 'msi'
url64 = 'dapr_cli_url'
checksum64 = 'dapr_cli_checksum'
checksumType64= 'SHA256'

silentArgs = '/qn /norestart'
validExitCodes= @(0, 1641, 3010)

}

New-Item -ItemType Directory -Force -Path $root | Out-Null
Install-ChocolateyPackage @packageArgs
12 changes: 12 additions & 0 deletions .github/workflows/dapr_cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ jobs:
env:
ARTIFACT_DIR: ./release
runs-on: ubuntu-latest
outputs:
relver: ${{ steps.relver.outputs.relver }}
steps:
- name: download artifacts
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -180,6 +182,9 @@ jobs:
--repo $GITHUB_REPOSITORY \
--prerelease \
${RELEASE_ARTIFACT[*]}
- name: Output the release version to be reusable in this workflow
id: relver
run: echo "relver=$REL_VER" >> "$GITHUB_OUTPUT"
publish-winget:
name: Publish to winget-pkgs
needs: publish
Expand All @@ -201,3 +206,10 @@ jobs:
$PackageIdentifier="Dapr.CLI"
}
.\wingetcreate.exe update "$PackageIdentifier" --submit --urls "$url|x64" --version "${{ env.REL_VERSION }}" --token "${{ secrets.DAPR_BOT_TOKEN }}"
publish-chocolatey:
name: Publish to chocolatey
needs: publish
if: startswith(github.ref, 'refs/tags/v')
uses: dapr/cli/.github/workflows/release_chocolatey.yml@master
with:
daprcli_version: ${{ needs.publish.outputs.relver }}
65 changes: 65 additions & 0 deletions .github/workflows/release_chocolatey.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: release_chocolatey

on:
workflow_call:
inputs:
daprcli_version:
type: string
description: "The Dapr CLI version to package (example: 1.13.0 or 1.13.0-rc1)"
required: true
workflow_dispatch:
inputs:
daprcli_version:
description: "The Dapr CLI version to package (example: 1.13.0 or 1.13.0-rc1)"
required: true

jobs:
publish:
runs-on: windows-latest
env:
DAPR_CLI_VERSION: ${{ github.event.inputs.daprcli_version }}
defaults:
run:
working-directory: .github/scripts/chocolatey/
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4

# Get checksum file
- name: Get checksum file
shell: pwsh
run: Invoke-WebRequest https://github.com/dapr/cli/releases/download/v1.13.0/dapr.msi.sha256 -OutFile dapr.msi.sha256

# Parse SHA256 from file
- name: Parse SHA256 from file and write to $SHA256SUM
shell: pwsh
run: |
$Env:SHA256SUM = (Get-Content dapr.msi.sha256 | foreach{$_.replace(" *dapr.msi", "")} | Set-Content -Path dapr.msi.sha256
echo "SHA256SUM=$env:SHA256SUM" >> $env:GITHUB_ENV

# Update script url
- name: Update install script url
shell: pwsh
run: Get-Content tools/chocolateyInstall.ps1 | foreach{$_.replace("dapr_cli_url", "https://github.com/dapr/cli/releases/download/v$env:DAPR_CLI_VERSION/dapr.msi")} | Set-Content -Path tools/chocolateyInstall.ps1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change the tools directory to .github/choco/tools? This will be consistent with winget.


# Update script hash
- name: Update install script hash
shell: pwsh
run: Get-Content tools/chocolateyInstall.ps1 | foreach{$_.replace("dapr_cli_checksum", "$env:SHA256SUM")} | Set-Content -Path tools/chocolateyInstall.ps1

# Update manifest version
- name: Update manifest version
shell: pwsh
run: Get-Content dapr.nuspec | foreach{$_.replace("dapr_cli_version", "$env:DAPR_CLI_VERSION")} | Set-Content -Path dapr.nuspec

# Use chocolatey to compile the repository into a nupkg
- name: Compile package
shell: pwsh
run: choco pack

# Publish package to the respository 'choco push'
- name: Publish package to the community respository
shell: pwsh
env:
CHOCOLATEY_TOKEN: ${{ secrets.CHOCOLATEY_TOKEN }}
run: choco push -k $env:CHOCOLATEY_TOKEN
Loading