diff --git a/.gitignore b/.gitignore index 26efd8d..6044bf4 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ Cargo.lock *.pdb .envrc + +*.nupkg diff --git a/ci/pipeline.yml b/ci/pipeline.yml index 9797be1..0f1f540 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -24,6 +24,7 @@ groups: - check-code - release - publish-to-crates + - publish-to-choco - set-dev-version jobs: @@ -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: diff --git a/ci/tasks/publish-to-choco.sh b/ci/tasks/publish-to-choco.sh new file mode 100755 index 0000000..8e0dc83 --- /dev/null +++ b/ci/tasks/publish-to-choco.sh @@ -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>/" 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/ diff --git a/ci/values.yml b/ci/values.yml index 92073ec..f911916 100644 --- a/ci/values.yml +++ b/ci/values.yml @@ -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 diff --git a/dist/choco/galoy-cli.nuspec b/dist/choco/galoy-cli.nuspec new file mode 100644 index 0000000..38828b5 --- /dev/null +++ b/dist/choco/galoy-cli.nuspec @@ -0,0 +1,19 @@ + + + + + + galoy-cli + 0.1.4 + Galoy CLI + Galoy + Galoy + https://github.com/GaloyMoney/galoy-cli/blob/main/LICENSE + https://github.com/GaloyMoney/galoy-cli + https://galoy.io/wp-content/uploads/2021/07/Galoy-Current-Logo-Blue.svg + false + A CLI Client for interacting with Galoy Backend. + Copyright 2023 + CLI galoy + + diff --git a/dist/choco/tools/chocolateyinstall.ps1 b/dist/choco/tools/chocolateyinstall.ps1 new file mode 100644 index 0000000..9098aad --- /dev/null +++ b/dist/choco/tools/chocolateyinstall.ps1 @@ -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' diff --git a/dist/choco/tools/chocolateyuninstall.ps1 b/dist/choco/tools/chocolateyuninstall.ps1 new file mode 100644 index 0000000..785a8ef --- /dev/null +++ b/dist/choco/tools/chocolateyuninstall.ps1 @@ -0,0 +1,4 @@ +$packageName = 'galoy-cli' +$installDir = "${env:ChocolateyInstall}\bin" + +Remove-Item "$installDir\$packageName.exe" -Force -ErrorAction SilentlyContinue