mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
ci: publsh Chocolatey package (#8921)
This commit is contained in:
@@ -329,6 +329,7 @@ jobs:
|
||||
name: Publish to winget-pkgs
|
||||
runs-on: windows-latest
|
||||
needs: release
|
||||
if: ${{ !inputs.dry_run }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
@@ -364,12 +365,6 @@ jobs:
|
||||
echo "Installer URL: ${installer_url}"
|
||||
echo "Package version: ${version}"
|
||||
|
||||
# Bail if dry-run.
|
||||
if ($env:CODER_DRY_RUN -match "t") {
|
||||
echo "Skipping submission due to dry-run."
|
||||
exit 0
|
||||
}
|
||||
|
||||
# The URL "|X64" suffix forces the architecture as it cannot be
|
||||
# sniffed properly from the URL. wingetcreate checks both the URL and
|
||||
# binary magic bytes for the architecture and they need to both match,
|
||||
@@ -393,7 +388,6 @@ jobs:
|
||||
WINGET_GH_TOKEN: ${{ secrets.CDRCI_GITHUB_TOKEN }}
|
||||
|
||||
- name: Comment on PR
|
||||
if: ${{ !inputs.dry_run }}
|
||||
run: |
|
||||
# wait 30 seconds
|
||||
Start-Sleep -Seconds 30.0
|
||||
@@ -409,3 +403,63 @@ jobs:
|
||||
# For gh CLI. We need a real token since we're commenting on a PR in a
|
||||
# different repo.
|
||||
GH_TOKEN: ${{ secrets.CDRCI_GITHUB_TOKEN }}
|
||||
|
||||
publish-chocolatey:
|
||||
name: Publish to Chocolatey
|
||||
runs-on: windows-latest
|
||||
needs: release
|
||||
if: ${{ !inputs.dry_run }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# Same reason as for release.
|
||||
- name: Fetch git tags
|
||||
run: git fetch --tags --force
|
||||
|
||||
# From https://chocolatey.org
|
||||
- name: Install Chocolatey
|
||||
run: |
|
||||
Set-ExecutionPolicy Bypass -Scope Process -Force
|
||||
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
|
||||
|
||||
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
|
||||
|
||||
- name: Build chocolatey package
|
||||
run: |
|
||||
cd scripts/chocolatey
|
||||
|
||||
# The package version is the same as the tag minus the leading "v".
|
||||
# The version in this output already has the leading "v" removed but
|
||||
# we do it again to be safe.
|
||||
$version = "${{ needs.release.outputs.version }}".Trim('v')
|
||||
|
||||
$release_assets = gh release view --repo coder/coder "v${version}" --json assets | `
|
||||
ConvertFrom-Json
|
||||
|
||||
# Get the URL for the Windows ZIP from the release assets.
|
||||
$zip_url = $release_assets.assets | `
|
||||
Where-Object name -Match ".*_windows_amd64.zip$" | `
|
||||
Select -ExpandProperty url
|
||||
|
||||
echo "ZIP URL: ${zip_url}"
|
||||
echo "Package version: ${version}"
|
||||
|
||||
echo "Downloading ZIP..."
|
||||
Invoke-WebRequest $zip_url -OutFile assets.zip
|
||||
|
||||
echo "Extracting ZIP..."
|
||||
Expand-Archive assets.zip -DestinationPath assets/
|
||||
|
||||
# No need to specify nuspec if there's only one in the directory.
|
||||
choco pack --version=$version binary_path=assets/coder.exe
|
||||
|
||||
choco apikey --api-key $env:CHOCO_API_KEY --source https://push.chocolatey.org/
|
||||
|
||||
# No need to specify nupkg if there's only one in the directory.
|
||||
choco push --source https://push.chocolatey.org/
|
||||
|
||||
env:
|
||||
CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }}
|
||||
|
||||
Reference in New Issue
Block a user