Skip to content

Commit

Permalink
feat: chocolatey package (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
sandipndev committed Aug 3, 2023
1 parent 7970585 commit 330afe0
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ Cargo.lock
*.pdb

.envrc

*.nupkg
22 changes: 22 additions & 0 deletions ci/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ groups:
- check-code
- release
- publish-to-crates
- publish-to-choco
- set-dev-version

jobs:
Expand Down Expand Up @@ -186,6 +187,27 @@ jobs:
run:
path: pipeline-tasks/ci/tasks/publish-to-crates.sh

- name: publish-to-choco
plan:
- in_parallel:
- { get: repo, passed: [release], trigger: true }
- get: pipeline-tasks
- get: version
- task: publish-to-choco
config:
image_resource:
type: registry-image
source: { repository: chocolatey/choco, tag: latest }
platform: linux
inputs:
- name: version
- name: pipeline-tasks
- name: repo
params:
CHOCO_API_TOKEN: #@ data.values.choco_api_token
run:
path: pipeline-tasks/ci/tasks/publish-to-choco.sh

- name: set-dev-version
plan:
- in_parallel:
Expand Down
15 changes: 15 additions & 0 deletions ci/tasks/publish-to-choco.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -eu

export VERSION=$(cat version/version)
export CHECKSUM=$(curl -L https://github.com/GaloyMoney/galoy-cli/releases/download/${VERSION}/sha256sums.txt | grep galoy-cli-x86_64-pc-windows-gnu | cut -d' ' -f1)

pushd repo/dist/choco

sed -i "7s/<version>.*<\/version>/<version>${VERSION}<\/version>/" galoy-cli.nuspec
sed -i "3s/\$version=.*/\$version='${VERSION}'/" tools/chocolateyinstall.ps1
sed -i "4s/\$checksum=.*/\$checksum='${CHECKSUM}'/" tools/chocolateyinstall.ps1

choco apikey --key ${CHOCO_API_KEY} --source https://push.chocolatey.org/
choco push galoy-cli.${VERSION}.nupkg --source https://push.chocolatey.org/
2 changes: 2 additions & 0 deletions ci/values.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ staging_ssh_pub_key: ((staging-ssh.ssh_public_key))
git_version_branch: version
gh_org: GaloyMoney
gh_repository: galoy-cli

crates_api_token: ((crates.token))
choco_api_token: ((chocolatey.token))

slack_channel: galoy-cli-github
slack_username: concourse
Expand Down
19 changes: 19 additions & 0 deletions dist/choco/galoy-cli.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Read this before creating packages: https://docs.chocolatey.org/en-us/create/create-packages -->
<!-- It is especially important to read the above link to understand additional requirements when publishing packages to the community feed aka dot org (https://community.chocolatey.org/packages). -->
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>galoy-cli</id>
<version>0.1.4</version>
<title>Galoy CLI</title>
<authors>Galoy</authors>
<owners>Galoy</owners>
<licenseUrl>https://github.com/GaloyMoney/galoy-cli/blob/main/LICENSE</licenseUrl>
<projectUrl>https://github.com/GaloyMoney/galoy-cli</projectUrl>
<iconUrl>https://galoy.io/wp-content/uploads/2021/07/Galoy-Current-Logo-Blue.svg</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A CLI Client for interacting with Galoy Backend.</description>
<copyright>Copyright 2023</copyright>
<tags>CLI galoy</tags>
</metadata>
</package>
29 changes: 29 additions & 0 deletions dist/choco/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
$ErrorActionPreference = 'Stop'

$version='0.1.4'
$checksum = '73771aa07ff0170e4ca06e4df0d76605a8ea5517e3ac077526bc5df6e3ebb336'

$url = "https://github.com/GaloyMoney/galoy-cli/releases/download/$version/galoy-cli-x86_64-pc-windows-gnu-$version.tar.gz"

$packageName = 'galoy-cli'
$installDir = "${env:ChocolateyInstall}\lib\$packageName"
$binDir = "${env:ChocolateyInstall}\bin"

$packageArgs = @{
packageName = $packageName
fileFullPath = "$installDir\$packageName.tar.gz"
url = $url
checksum = $checksum
checksumType = 'sha256'
}

Get-ChocolateyWebFile @packageArgs

# Unpack the .tar.gz file
Get-ChocolateyUnzip -FileFullPath "$installDir\$packageName.tar.gz" -Destination $installDir
Get-ChocolateyUnzip -FileFullPath "$installDir\$packageName.tar" -Destination $installDir

# Move the executable to the bin directory
Move-Item -Path "$installDir\galoy-cli-x86_64-pc-windows-gnu-$version\$packageName.exe" -Destination "$binDir\$packageName.exe"

Install-ChocolateyPath -PathToInstall $binDir -PathType 'Machine'
4 changes: 4 additions & 0 deletions dist/choco/tools/chocolateyuninstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$packageName = 'galoy-cli'
$installDir = "${env:ChocolateyInstall}\bin"

Remove-Item "$installDir\$packageName.exe" -Force -ErrorAction SilentlyContinue

0 comments on commit 330afe0

Please sign in to comment.