diff --git a/.github/choco/dapr.nuspec b/.github/choco/dapr.nuspec new file mode 100644 index 000000000..86f7585a2 --- /dev/null +++ b/.github/choco/dapr.nuspec @@ -0,0 +1,30 @@ + + + + dapr + dapr_cli_version + https://github.com/dapr/cli/tree/master/.github/scripts/chocolatey + mikeee, dapr + Dapr CLI (Install) + The Dapr Authors + https://dapr.io/ + https://cdn.jsdelivr.net/gh/dapr/website/static/images/dapr.svg + Copyright 2024 The Dapr Authors + https://github.com/dapr/cli/blob/master/LICENSE + false + https://github.com/dapr/cli + https://docs.dapr.io/reference/cli/cli-overview/ + https://github.com/dapr/cli/issues + dapr distributed application runtime cli kubernetes + The Dapr CLI is the main tool for running Dapr-related tasks + + 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. + + https://github.com/dapr/cli/releases + + + + + diff --git a/.github/choco/tools/chocolateyInstall.ps1 b/.github/choco/tools/chocolateyInstall.ps1 new file mode 100644 index 000000000..a86e43d59 --- /dev/null +++ b/.github/choco/tools/chocolateyInstall.ps1 @@ -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 diff --git a/.github/workflows/dapr_cli.yaml b/.github/workflows/dapr_cli.yaml index a27c13ba6..76423efcc 100644 --- a/.github/workflows/dapr_cli.yaml +++ b/.github/workflows/dapr_cli.yaml @@ -166,6 +166,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 @@ -196,6 +198,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 @@ -217,3 +222,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 }} diff --git a/.github/workflows/release_chocolatey.yml b/.github/workflows/release_chocolatey.yml new file mode 100644 index 000000000..0910c2419 --- /dev/null +++ b/.github/workflows/release_chocolatey.yml @@ -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/choco/ + 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 + + # 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