Skip to content

Commit

Permalink
Move chocolatey scripts to main repository (#550)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Simmer authored Feb 5, 2021
1 parent 350505f commit cb18d15
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 17 deletions.
32 changes: 15 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -294,19 +294,19 @@ jobs:
- run: ./.circleci/brew-deploy.sh
- slack-notify-on-failure

trigger-chocolatey-deploy:
docker:
- image: cimg/base:edge
chocolatey-deploy:
executor: windows/default
working_directory: chocolatey
steps:
- checkout
- run:
name: Trigger Chocolatey repository build
command: |
curl -X POST https://circleci.com/api/v2/project/gh/CircleCI-Public/chocolatey-circleci-cli/pipeline \
--fail --silent \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H "Circle-Token: $CIRCLE_TOKEN" \
--data '{ "parameters": { "deploy-production": true } }'
name: Run update script
command: .\update-version.ps1
- run: choco pack circleci-cli\circleci-cli.nuspec
- run: copy-item circleci-cli.*.nupkg circleci-cli.nupkg
- run:
name: Push to Chocolatey package repository
command: choco push circleci-cli.nupkg --source https://chocolatey.org/ --apikey $env:CHOCO_API_KEY

workflows:
ci:
Expand All @@ -328,6 +328,9 @@ workflows:
- snap:
requires:
- deploy
- chocolatey-deploy:
requires:
- deploy
# Only deploy to homebrew after manual approval.
- run-brew-deploy-gate:
type: approval
Expand All @@ -347,9 +350,4 @@ workflows:
filters:
branches:
only: master
- trigger-chocolatey-deploy:
requires:
- deploy
filters:
branches:
only: master

14 changes: 14 additions & 0 deletions chocolatey/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# CircleCI CLI Chocolatey Package

Automatically builds and deploys the Chocolatey package when the CLI is
released.

Chocolatey page: https://chocolatey.org/packages/circleci-cli

## Installing

```powershell
choco install circleci-cli -y
```

_thanks to @ericjaystevens for the initial work on this!_
32 changes: 32 additions & 0 deletions chocolatey/circleci-cli/circleci-cli.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<!-- == PACKAGE SPECIFIC SECTION == -->
<id>circleci-cli</id>
<version>$VER</version>
<packageSourceUrl>https://github.com/CircleCI-Public/circleci-cli</packageSourceUrl>
<!-- owners is a poor name for maintainers of the package. It sticks around by this name for compatibility reasons. It basically means you. -->
<owners>CircleCI</owners>
<!-- ============================== -->

<!-- == SOFTWARE SPECIFIC SECTION == -->
<!-- This section is about the software itself -->
<title>circleci-cli (Install)</title>
<authors>CircleCI</authors>
<projectUrl>https://circleci.com/docs/2.0/local-cli/</projectUrl>
<iconUrl>https://github.com/CircleCI-Public/circleci-cli/raw/master/chocolatey/icons/circleci-128x.png</iconUrl>
<licenseUrl>https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/master/LICENSE</licenseUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<projectSourceUrl>https://github.com/CircleCI-Public/circleci-cli</projectSourceUrl>
<docsUrl>https://circleci-public.github.io/circleci-cli/</docsUrl>
<tags>ci</tags>
<releaseNotes>https://github.com/CircleCI-Public/circleci-cli/releases</releaseNotes>
<summary>CircleCI command line tool</summary>
<description>
Command line tool for performing tasks related to a CircleCI project. Enables you to run local builds, debug your continuous integration config files, and manage Orbs.
</description>
</metadata>
<files>
<file src="tools\**" target="tools" />
</files>
</package>
14 changes: 14 additions & 0 deletions chocolatey/circleci-cli/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file is generated by `update-version.ps1`, and commited to the repository
# under a version tag.
$ErrorActionPreference = 'Stop';
$toolsDir = Split-Path -parent $MyInvocation.MyCommand.Definition
$url64 = '$DOWNLOAD_URL'

$packageParams = @{
packageName = $env:ChocolateyPackageName
unzipLocation = $toolsDir
url64 = $url64
checksum64 = '$HASH'
checksumType64 = 'sha256'
}
Install-ChocolateyZipPackage @packageParams
Binary file added chocolatey/icons/circleci-128x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions chocolatey/update-version.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
$url = "https://github.com/CircleCI-Public/circleci-cli/releases/latest"

$request = [System.Net.WebRequest]::Create($url)
$request.AllowAutoRedirect=$false
$response=$request.GetResponse()
$versionURL = $response.GetResponseHeader("Location")

$curVersion = ($versionURL | Split-Path -Leaf).Substring(1)

$tmpFile = ".\out.txt"
$checksumURL = "https://github.com/CircleCI-Public/circleci-cli/releases/download/v$curVersion/circleci-cli_$($curVersion)_checksums.txt"
Write-Verbose "getting checksum from $checksumURL to $tmpFile"

(New-Object System.Net.WebClient).DownloadString($checksumURL) >> $tmpFile

### replace hash
$hash = (Get-Content $tmpFile | where {$_ -like "*windows_amd64.zip"}).split(" ")[0]
$installerPath = ".\circleci-cli\tools\chocolateyinstall.ps1"
(Get-Content $installerPath).Replace('$HASH',$hash) | Out-File $installerPath -Force

$downloadURL = "https://github.com/CircleCI-Public/circleci-cli/releases/download/v$curVersion/circleci-cli_$($curVersion)_windows_amd64.zip"
(Get-Content $installerPath).Replace('$DOWNLOAD_URL',$downloadURL) | Out-File $installerPath -Force

$nuspecPath = "./circleci-cli/circleci-cli.nuspec"
(Get-Content $nuspecPath).Replace('$VER',$curVersion) | Out-File $nuspecPath -Force

0 comments on commit cb18d15

Please sign in to comment.