Skip to content

Commit 36d4448

Browse files
authored
Merge pull request #205 from ipinfo/usama/windows-release
Release automation - Winget, Chocolatey
2 parents 12e1ee2 + 51a68cb commit 36d4448

File tree

8 files changed

+198
-1
lines changed

8 files changed

+198
-1
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Publish to Chocolatey
2+
on:
3+
release:
4+
types: [released]
5+
6+
jobs:
7+
check-release:
8+
runs-on: ubuntu-latest
9+
outputs:
10+
valid-cli: ${{ steps.cli-name.outputs.valid }}
11+
cli-vsn: ${{ steps.cli-name.outputs.cli-vsn }}
12+
13+
steps:
14+
- name: Confirm that this is the release of ipinfo cli
15+
id: cli-name
16+
run: |
17+
releaseName="${{ github.event.release.name }}"
18+
19+
if [[ $releaseName =~ ^ipinfo-([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
20+
echo "Release name matches pattern 'ipinfo-x.x.x'"
21+
echo "cli-vsn=${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}" >> "$GITHUB_OUTPUT"
22+
echo "valid=true" >> "$GITHUB_OUTPUT"
23+
else
24+
echo "Invalid release name format: $releaseName"
25+
echo "Release name should be of format ipinfo-x.x.x"
26+
fi
27+
28+
publish:
29+
needs: check-release
30+
if: needs.check-release.outputs.valid-cli == true
31+
runs-on: windows-latest
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v3
35+
36+
- name: Install au module
37+
run: |
38+
choco install au -y
39+
40+
- name: Update package version
41+
run: |
42+
cd chocolatey-packages\ipinfo
43+
.\update.ps1
44+
45+
- name: Test installation
46+
run: |
47+
cd chocolatey-packages\ipinfo
48+
Test-Package
49+
50+
- name: Upload to choco
51+
run: |
52+
cd chocolatey-packages\ipinfo
53+
choco apikey --key ${{ secrets.CHOCO_API_KEY }} --source https://push.chocolatey.org/
54+
choco push ipinfo.${{ needs.check-release.outputs.cli-vsn }}.nupkg --source https://push.chocolatey.org/

.github/workflows/cd_github.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ jobs:
2323
with:
2424
go-version: '1.20'
2525

26+
- name: Get Github App Token
27+
uses: actions/create-github-app-token@v1
28+
id: app-token
29+
with:
30+
app-id: ${{ vars.G_APP_ID }}
31+
private-key: ${{ secrets.G_APP_PRIVATE_KEY }}
32+
2633
- name: Extract CLI Name and Version
2734
run: |
2835
# Get the tag name from the event payload
@@ -54,6 +61,7 @@ jobs:
5461
- name: Release
5562
uses: softprops/action-gh-release@v1
5663
with:
64+
token: ${{ steps.app-token.outputs.token }}
5765
body_path: changes.md
5866
files: |
5967
./build/${{ env.CLI_NAME }}_${{ env.CLI_VERSION }}*.tar.gz

.github/workflows/cd_winget.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Publish to WinGet
2+
on:
3+
release:
4+
types: [released]
5+
6+
jobs:
7+
check-release:
8+
runs-on: ubuntu-latest
9+
outputs:
10+
valid-cli: ${{ steps.cli-name.outputs.valid }}
11+
cli-vsn: ${{ steps.cli-name.outputs.cli-vsn }}
12+
steps:
13+
- name: Confirm that this is the release of ipinfo cli
14+
id: cli-name
15+
run: |
16+
releaseName="${{ github.event.release.name }}"
17+
18+
if [[ $releaseName =~ ^ipinfo-([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
19+
echo "Release name matches pattern 'ipinfo-x.x.x'"
20+
echo "cli-vsn=${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}" >> "$GITHUB_OUTPUT"
21+
echo "valid=true" >> "$GITHUB_OUTPUT"
22+
else
23+
echo "Invalid release name format: $releaseName"
24+
echo "Release name should be of format ipinfo-x.x.x"
25+
fi
26+
27+
publish:
28+
needs: check-release
29+
if: needs.check-release.outputs.valid-cli == true
30+
runs-on: windows-latest
31+
steps:
32+
- name: Get Github App Token
33+
uses: actions/create-github-app-token@v1
34+
id: app-token
35+
with:
36+
app-id: ${{ vars.G_APP_ID }}
37+
private-key: ${{ secrets.G_APP_PRIVATE_KEY }}
38+
owner: ${{ github.repository_owner }}
39+
40+
- uses: vedantmgoyal2009/winget-releaser@v2
41+
with:
42+
identifier: ipinfo.ipinfo
43+
installers-regex: '_windows_\w+\.zip$'
44+
version: ${{ needs.check-release.outputs.cli-vsn }}
45+
token: ${{ steps.app-token.outputs.token }}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ solaris_amd64
138138
windows_386
139139
windows_amd64
140140
windows_arm
141+
windows_arm64
141142
```
142143

143144
After choosing a platform `PLAT` from above, run:
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
3+
<metadata>
4+
<id>ipinfo</id>
5+
<version>1.0.0</version>
6+
<owners>ipinfo</owners>
7+
<title>ipinfo</title>
8+
<authors>IPInfo</authors>
9+
<projectUrl>https://github.com/ipinfo/cli</projectUrl>
10+
<packageSourceUrl>https://github.com/ipinfo/cli/tree/master/chocolatey-packages/ipinfo</packageSourceUrl>
11+
<!--<iconUrl>https://raw.github.com/jbpaux/chocolatey-packages/tree/master/ipinfo/ipinfo.png</iconUrl>-->
12+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
13+
<tags>ipinfo cli</tags>
14+
<summary>Official Command Line Interface for the IPinfo API (IP geolocation and other types of IP data).</summary>
15+
<description><![CDATA[This is the official CLI for the IPinfo.io IP address API, allowing you to:
16+
17+
Look up IP details in bulk or one-by-one.
18+
Look up ASN details.
19+
Summarize the details of up to 1000 IPs at a time.
20+
Open a map of IP locations for any set of IPs.
21+
Filter IPv4/IPv6 addresses from any input.
22+
Print out IP lists for any CIDR or IP range.
23+
And more!
24+
]]></description>
25+
</metadata>
26+
<files>
27+
<file src="tools\**" target="tools" />
28+
</files>
29+
</package>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
$ErrorActionPreference = 'Stop';
2+
3+
$packageName = 'ipinfo'
4+
$toolsDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
5+
6+
$packageArgs = @{
7+
packageName = $packageName
8+
url64 = ''
9+
checksum64 = ''
10+
checksumType64 = ''
11+
url = ''
12+
checksumType = ''
13+
checksum = ''
14+
destination = $toolsDir
15+
}
16+
17+
$targetPath = Join-Path -Path $toolsDir -ChildPath "ipinfo.exe"
18+
if (Test-Path $targetPath) {
19+
Remove-Item $targetPath
20+
}
21+
Install-ChocolateyZipPackage @packageArgs
22+
Get-ChildItem -Path $toolsDir -Filter "ipinfo*.exe" | Rename-Item -NewName "ipinfo.exe"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import-module au
2+
3+
$repo = 'ipinfo/cli'
4+
5+
function global:au_SearchReplace {
6+
@{
7+
".\tools\chocolateyInstall.ps1" = @{
8+
"(?i)(^\s*url64\s*=\s*)('.*')" = "`$1'$($Latest.URL64)'"
9+
"(?i)(^\s*checksum64\s*=\s*)('.*')" = "`$1'$($Latest.Checksum64)'"
10+
"(?i)(^\s*checksumType64\s*=\s*)('.*')" = "`$1'$($Latest.ChecksumType64)'"
11+
"(?i)(^\s*url\s*=\s*)('.*')" = "`$1'$($Latest.URL32)'"
12+
"(?i)(^\s*checksum\s*=\s*)('.*')" = "`$1'$($Latest.Checksum32)'"
13+
"(?i)(^\s*checksumType\s*=\s*)('.*')" = "`$1'$($Latest.ChecksumType32)'"
14+
}
15+
}
16+
}
17+
18+
function global:au_GetLatest {
19+
$releases = Invoke-RestMethod "https://api.github.com/repos/$repo/releases"
20+
if ($null -ne $releases) {
21+
$release = $releases | Where-Object name -like "ipinfo*" | Sort-Object published_at -Descending | Select-Object -First 1
22+
if ($null -ne $release) {
23+
$url64 = ($release.assets | Where-Object name -like "ipinfo*_windows_amd64.zip").browser_download_url
24+
$url32 = ($release.assets | Where-Object name -like "ipinfo*_windows_386.zip").browser_download_url
25+
26+
$version = $release.name.split('-')[1]
27+
28+
@{
29+
URL64 = $url64
30+
URL32 = $url32
31+
Version = $version
32+
}
33+
}
34+
}
35+
}
36+
37+
update -ChecksumFor all

scripts/build-all-platforms.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ for t in \
5050
solaris_amd64 \
5151
windows_386 \
5252
windows_amd64 \
53-
windows_arm ;
53+
windows_arm \
54+
windows_arm64 ;
5455
do
5556
os="${t%_*}"
5657
arch="${t#*_}"

0 commit comments

Comments
 (0)