From 9a1631c01506b12e0103c141e45c77ee6f6aa1a1 Mon Sep 17 00:00:00 2001 From: abu usama Date: Sun, 21 Jan 2024 15:37:16 +0500 Subject: [PATCH 01/11] add winget release workflow --- .github/workflows/cd_winget.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/cd_winget.yaml diff --git a/.github/workflows/cd_winget.yaml b/.github/workflows/cd_winget.yaml new file mode 100644 index 0000000..5793e49 --- /dev/null +++ b/.github/workflows/cd_winget.yaml @@ -0,0 +1,21 @@ +name: Publish to WinGet +on: + release: + types: [released] +jobs: + publish: + runs-on: windows-latest + steps: + - name: Get version + id: get-version + run: | + # Finding the version from release name + $VERSION="${{ github.event.release.name }}" -match '\d+\.\d+\.\d+' + "version=$VERSION" >> $env:GITHUB_OUTPUT + shell: pwsh + - uses: vedantmgoyal2009/winget-releaser@v2 + with: + identifier: ipinfo.ipinfo + installers-regex: '_windows_\w+\.zip$' + version: ${{ steps.get-version.outputs.version }} + token: ${{ secrets.WINGET_TOKEN }} From 30c0ad6a5370a7faec5280bb9450556d613c8d49 Mon Sep 17 00:00:00 2001 From: abu usama Date: Sun, 21 Jan 2024 16:22:34 +0500 Subject: [PATCH 02/11] add windows arm64 to release --- README.md | 1 + scripts/build-all-platforms.sh | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1354d0a..1506aa0 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,7 @@ solaris_amd64 windows_386 windows_amd64 windows_arm +windows_arm64 ``` After choosing a platform `PLAT` from above, run: diff --git a/scripts/build-all-platforms.sh b/scripts/build-all-platforms.sh index 3af9d22..5d380fc 100755 --- a/scripts/build-all-platforms.sh +++ b/scripts/build-all-platforms.sh @@ -48,7 +48,8 @@ for t in \ solaris_amd64 \ windows_386 \ windows_amd64 \ - windows_arm ; + windows_arm \ + windows_arm64 ; do os="${t%_*}" arch="${t#*_}" From 25e963385dd15b7981e43b358a00dc08b9e7cae3 Mon Sep 17 00:00:00 2001 From: abu usama Date: Thu, 8 Feb 2024 03:51:37 +0500 Subject: [PATCH 03/11] fix github and winget release --- .github/workflows/cd_github.yaml | 8 ++++++ .github/workflows/cd_winget.yaml | 43 +++++++++++++++++++++++++------- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cd_github.yaml b/.github/workflows/cd_github.yaml index 34e1678..b7bea53 100644 --- a/.github/workflows/cd_github.yaml +++ b/.github/workflows/cd_github.yaml @@ -23,6 +23,13 @@ jobs: with: go-version: '1.20' + - name: Get Github App Token + uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.GITHUB_APP_ID }} + private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }} + - name: Extract CLI Name and Version run: | # Get the tag name from the event payload @@ -54,6 +61,7 @@ jobs: - name: Release uses: softprops/action-gh-release@v1 with: + token: ${{ steps.app-token.outputs.token }} body_path: changes.md files: | ./build/${{ env.CLI_NAME }}_${{ env.CLI_VERSION }}*.tar.gz diff --git a/.github/workflows/cd_winget.yaml b/.github/workflows/cd_winget.yaml index 5793e49..deb7683 100644 --- a/.github/workflows/cd_winget.yaml +++ b/.github/workflows/cd_winget.yaml @@ -2,20 +2,45 @@ name: Publish to WinGet on: release: types: [released] + jobs: + check-release: + runs-on: ubuntu-latest + outputs: + valid-cli: ${{ steps.cli-name.outputs.valid }} + cli-vsn: ${{ steps.cli-name.outputs.cli-vsn }} + steps: + - name: Confirm that this is the release of ipinfo cli + id: cli-name + run: | + releaseName="${{ github.event.release.name }}" + + if [[ $releaseName =~ ^ipinfo-([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then + echo "Release name matches pattern 'ipinfo-x.x.x'" + echo "cli-vsn=${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}" >> "$GITHUB_OUTPUT" + echo "valid=true" >> "$GITHUB_OUTPUT" + else + echo "Invalid release name format: $releaseName" + echo "Release name should be of format ipinfo-x.x.x" + exit 1 + fi + publish: + needs: check-release + if: needs.check-release.outputs.valid-cli == true runs-on: windows-latest steps: - - name: Get version - id: get-version - run: | - # Finding the version from release name - $VERSION="${{ github.event.release.name }}" -match '\d+\.\d+\.\d+' - "version=$VERSION" >> $env:GITHUB_OUTPUT - shell: pwsh + - name: Get Github App Token + uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.GITHUB_APP_ID }} + private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + - uses: vedantmgoyal2009/winget-releaser@v2 with: identifier: ipinfo.ipinfo installers-regex: '_windows_\w+\.zip$' - version: ${{ steps.get-version.outputs.version }} - token: ${{ secrets.WINGET_TOKEN }} + version: ${{ needs.check-release.outputs.cli-vsn }} + token: ${{ steps.app-token.outputs.token }} From 0291065f89bb79ad99821443d1d930c579af2a73 Mon Sep 17 00:00:00 2001 From: abu usama Date: Thu, 8 Feb 2024 03:52:32 +0500 Subject: [PATCH 04/11] added files required for choco release --- chocolatey-packages/ipinfo/ipinfo.nuspec | 29 +++++++++++++++ .../ipinfo/tools/chocolateyinstall.ps1 | 22 +++++++++++ chocolatey-packages/ipinfo/update.ps1 | 37 +++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 chocolatey-packages/ipinfo/ipinfo.nuspec create mode 100644 chocolatey-packages/ipinfo/tools/chocolateyinstall.ps1 create mode 100644 chocolatey-packages/ipinfo/update.ps1 diff --git a/chocolatey-packages/ipinfo/ipinfo.nuspec b/chocolatey-packages/ipinfo/ipinfo.nuspec new file mode 100644 index 0000000..de02224 --- /dev/null +++ b/chocolatey-packages/ipinfo/ipinfo.nuspec @@ -0,0 +1,29 @@ + + + + ipinfo + 3.3.0 + ipinfo + ipinfo + IPInfo + https://github.com/ipinfo/cli + https://github.com/ipinfo/cli/tree/master/chocolatey-packages/ipinfo + + false + ipinfo cli + Official Command Line Interface for the IPinfo API (IP geolocation and other types of IP data). + + + + + + diff --git a/chocolatey-packages/ipinfo/tools/chocolateyinstall.ps1 b/chocolatey-packages/ipinfo/tools/chocolateyinstall.ps1 new file mode 100644 index 0000000..621af65 --- /dev/null +++ b/chocolatey-packages/ipinfo/tools/chocolateyinstall.ps1 @@ -0,0 +1,22 @@ +$ErrorActionPreference = 'Stop'; + +$packageName = 'ipinfo' +$toolsDir = Split-Path -Parent $MyInvocation.MyCommand.Definition + +$packageArgs = @{ + packageName = $packageName + url64 = 'https://github.com/ipinfo/cli/releases/download/ipinfo-3.3.0/ipinfo_3.3.0_windows_amd64.zip' + checksum64 = '2ab00f6a289d308b9ac04be9153aa566e93acff3da8a62dd283022a0cb6ee34d' + checksumType64 = 'sha256' + url = 'https://github.com/ipinfo/cli/releases/download/ipinfo-3.3.0/ipinfo_3.3.0_windows_386.zip' + checksumType = 'sha256' + checksum = 'ddc0d4f17ca972cfc4bc76fc4775f67514e67bc654db4c9695993600a905525b' + destination = $toolsDir +} + +$targetPath = Join-Path -Path $toolsDir -ChildPath "ipinfo.exe" +if (Test-Path $targetPath) { + Remove-Item $targetPath +} +Install-ChocolateyZipPackage @packageArgs +Get-ChildItem -Path $toolsDir -Filter "ipinfo*.exe" | Rename-Item -NewName "ipinfo.exe" diff --git a/chocolatey-packages/ipinfo/update.ps1 b/chocolatey-packages/ipinfo/update.ps1 new file mode 100644 index 0000000..f8dccd8 --- /dev/null +++ b/chocolatey-packages/ipinfo/update.ps1 @@ -0,0 +1,37 @@ +import-module au + +$repo = 'ipinfo/cli' + +function global:au_SearchReplace { + @{ + ".\tools\chocolateyInstall.ps1" = @{ + "(?i)(^\s*url64\s*=\s*)('.*')" = "`$1'$($Latest.URL64)'" + "(?i)(^\s*checksum64\s*=\s*)('.*')" = "`$1'$($Latest.Checksum64)'" + "(?i)(^\s*checksumType64\s*=\s*)('.*')" = "`$1'$($Latest.ChecksumType64)'" + "(?i)(^\s*url\s*=\s*)('.*')" = "`$1'$($Latest.URL32)'" + "(?i)(^\s*checksum\s*=\s*)('.*')" = "`$1'$($Latest.Checksum32)'" + "(?i)(^\s*checksumType\s*=\s*)('.*')" = "`$1'$($Latest.ChecksumType32)'" + } + } +} + +function global:au_GetLatest { + $releases = Invoke-RestMethod "https://api.github.com/repos/$repo/releases" + if ($null -ne $releases) { + $release = $releases | Where-Object name -like "ipinfo*" | Sort-Object published_at -Descending | Select-Object -First 1 + if ($null -ne $release) { + $url64 = ($release.assets | Where-Object name -like "ipinfo*_windows_amd64.zip").browser_download_url + $url32 = ($release.assets | Where-Object name -like "ipinfo*_windows_386.zip").browser_download_url + + $version = $release.name.split('-')[1] + + @{ + URL64 = $url64 + URL32 = $url32 + Version = $version + } + } + } +} + +update -ChecksumFor all From 965fc3b4aed15ac4043d6c0df4db1d23ad2321df Mon Sep 17 00:00:00 2001 From: abu usama Date: Thu, 8 Feb 2024 03:53:19 +0500 Subject: [PATCH 05/11] added choco release workflow --- .github/workflows/cd_chocolatey.yaml | 45 ++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/cd_chocolatey.yaml diff --git a/.github/workflows/cd_chocolatey.yaml b/.github/workflows/cd_chocolatey.yaml new file mode 100644 index 0000000..557c848 --- /dev/null +++ b/.github/workflows/cd_chocolatey.yaml @@ -0,0 +1,45 @@ +name: Publish to Chocolatey +on: + release: + types: [released] + +jobs: + check-release: + runs-on: ubuntu-latest + outputs: + valid-cli: ${{ steps.cli-name.outputs.valid }} + cli-vsn: ${{ steps.cli-name.outputs.cli-vsn }} + + steps: + - name: Confirm that this is the release of ipinfo cli + id: cli-name + run: | + releaseName="${{ github.event.release.name }}" + + if [[ $releaseName =~ ^ipinfo-([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then + echo "Release name matches pattern 'ipinfo-x.x.x'" + echo "cli-vsn=${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}" >> "$GITHUB_OUTPUT" + echo "valid=true" >> "$GITHUB_OUTPUT" + else + echo "Invalid release name format: $releaseName" + echo "Release name should be of format ipinfo-x.x.x" + exit 1 + fi + + publish: + needs: check-release + if: needs.check-release.outputs.valid-cli == true + runs-on: windows-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Update package version + run: | + cd chocolatey-packages\ipinfo + .\update.ps1 + + - name: Upload to choco + run: | + choco apikey --key ${{ secrets.CHOCO_API_KEY }} --source https://push.chocolatey.org/ + choco push ipinfo.${{ needs.check-release.outputs.cli-vsn }}.nupkg --source https://push.chocolatey.org/ From bb6da4c5b2c8305e2c691b68a023acebbc29a6d1 Mon Sep 17 00:00:00 2001 From: abu usama Date: Fri, 9 Feb 2024 16:27:12 +0500 Subject: [PATCH 06/11] added package testing step --- .github/workflows/cd_chocolatey.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cd_chocolatey.yaml b/.github/workflows/cd_chocolatey.yaml index 557c848..6659695 100644 --- a/.github/workflows/cd_chocolatey.yaml +++ b/.github/workflows/cd_chocolatey.yaml @@ -38,8 +38,14 @@ jobs: run: | cd chocolatey-packages\ipinfo .\update.ps1 - + + - name: Test installation + run: | + cd chocolatey-packages\ipinfo + Test-Package + - name: Upload to choco run: | + cd chocolatey-packages\ipinfo choco apikey --key ${{ secrets.CHOCO_API_KEY }} --source https://push.chocolatey.org/ choco push ipinfo.${{ needs.check-release.outputs.cli-vsn }}.nupkg --source https://push.chocolatey.org/ From 7e73748621d15aa3619f57432838e138684bf994 Mon Sep 17 00:00:00 2001 From: abu usama Date: Fri, 9 Feb 2024 16:58:47 +0500 Subject: [PATCH 07/11] continue without failing if cli is not ipinfo --- .github/workflows/cd_chocolatey.yaml | 2 +- .github/workflows/cd_winget.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd_chocolatey.yaml b/.github/workflows/cd_chocolatey.yaml index 6659695..d087b0b 100644 --- a/.github/workflows/cd_chocolatey.yaml +++ b/.github/workflows/cd_chocolatey.yaml @@ -23,7 +23,7 @@ jobs: else echo "Invalid release name format: $releaseName" echo "Release name should be of format ipinfo-x.x.x" - exit 1 + exit 0 fi publish: diff --git a/.github/workflows/cd_winget.yaml b/.github/workflows/cd_winget.yaml index deb7683..5987a2e 100644 --- a/.github/workflows/cd_winget.yaml +++ b/.github/workflows/cd_winget.yaml @@ -22,7 +22,7 @@ jobs: else echo "Invalid release name format: $releaseName" echo "Release name should be of format ipinfo-x.x.x" - exit 1 + exit 0 fi publish: From 184fafb426daf81014a031beab3d5c73e16cecb2 Mon Sep 17 00:00:00 2001 From: abu usama Date: Fri, 9 Feb 2024 17:03:43 +0500 Subject: [PATCH 08/11] rm exit command --- .github/workflows/cd_chocolatey.yaml | 1 - .github/workflows/cd_winget.yaml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/cd_chocolatey.yaml b/.github/workflows/cd_chocolatey.yaml index d087b0b..ae32871 100644 --- a/.github/workflows/cd_chocolatey.yaml +++ b/.github/workflows/cd_chocolatey.yaml @@ -23,7 +23,6 @@ jobs: else echo "Invalid release name format: $releaseName" echo "Release name should be of format ipinfo-x.x.x" - exit 0 fi publish: diff --git a/.github/workflows/cd_winget.yaml b/.github/workflows/cd_winget.yaml index 5987a2e..1d614f0 100644 --- a/.github/workflows/cd_winget.yaml +++ b/.github/workflows/cd_winget.yaml @@ -22,7 +22,6 @@ jobs: else echo "Invalid release name format: $releaseName" echo "Release name should be of format ipinfo-x.x.x" - exit 0 fi publish: From 055cd3bc473288a4f2a20f93b0d6371f18ac7c40 Mon Sep 17 00:00:00 2001 From: abu usama Date: Fri, 9 Feb 2024 17:22:29 +0500 Subject: [PATCH 09/11] changed names that aren't allowed --- .github/workflows/cd_github.yaml | 4 ++-- .github/workflows/cd_winget.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cd_github.yaml b/.github/workflows/cd_github.yaml index b7bea53..7f2709d 100644 --- a/.github/workflows/cd_github.yaml +++ b/.github/workflows/cd_github.yaml @@ -27,8 +27,8 @@ jobs: uses: actions/create-github-app-token@v1 id: app-token with: - app-id: ${{ vars.GITHUB_APP_ID }} - private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }} + app-id: ${{ vars.G_APP_ID }} + private-key: ${{ secrets.G_APP_PRIVATE_KEY }} - name: Extract CLI Name and Version run: | diff --git a/.github/workflows/cd_winget.yaml b/.github/workflows/cd_winget.yaml index 1d614f0..3225fce 100644 --- a/.github/workflows/cd_winget.yaml +++ b/.github/workflows/cd_winget.yaml @@ -33,8 +33,8 @@ jobs: uses: actions/create-github-app-token@v1 id: app-token with: - app-id: ${{ vars.GITHUB_APP_ID }} - private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }} + app-id: ${{ vars.G_APP_ID }} + private-key: ${{ secrets.G_APP_PRIVATE_KEY }} owner: ${{ github.repository_owner }} - uses: vedantmgoyal2009/winget-releaser@v2 From af1af4f3c31dc55d893b47d0c670d94762aec4a2 Mon Sep 17 00:00:00 2001 From: abu-usama Date: Thu, 29 Feb 2024 15:42:38 +0500 Subject: [PATCH 10/11] install the updater module --- .github/workflows/cd_chocolatey.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/cd_chocolatey.yaml b/.github/workflows/cd_chocolatey.yaml index ae32871..8da6f30 100644 --- a/.github/workflows/cd_chocolatey.yaml +++ b/.github/workflows/cd_chocolatey.yaml @@ -33,6 +33,10 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Install au module + run: | + choco install au -y + - name: Update package version run: | cd chocolatey-packages\ipinfo From 51a68cbbf01519b370a3d2364b5158ff93bebee5 Mon Sep 17 00:00:00 2001 From: abu-usama Date: Thu, 29 Feb 2024 15:43:53 +0500 Subject: [PATCH 11/11] use null values as updater template --- chocolatey-packages/ipinfo/ipinfo.nuspec | 2 +- .../ipinfo/tools/chocolateyinstall.ps1 | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/chocolatey-packages/ipinfo/ipinfo.nuspec b/chocolatey-packages/ipinfo/ipinfo.nuspec index de02224..2fe3d1d 100644 --- a/chocolatey-packages/ipinfo/ipinfo.nuspec +++ b/chocolatey-packages/ipinfo/ipinfo.nuspec @@ -2,7 +2,7 @@ ipinfo - 3.3.0 + 1.0.0 ipinfo ipinfo IPInfo diff --git a/chocolatey-packages/ipinfo/tools/chocolateyinstall.ps1 b/chocolatey-packages/ipinfo/tools/chocolateyinstall.ps1 index 621af65..dfb1bd5 100644 --- a/chocolatey-packages/ipinfo/tools/chocolateyinstall.ps1 +++ b/chocolatey-packages/ipinfo/tools/chocolateyinstall.ps1 @@ -5,12 +5,12 @@ $toolsDir = Split-Path -Parent $MyInvocation.MyCommand.Definition $packageArgs = @{ packageName = $packageName - url64 = 'https://github.com/ipinfo/cli/releases/download/ipinfo-3.3.0/ipinfo_3.3.0_windows_amd64.zip' - checksum64 = '2ab00f6a289d308b9ac04be9153aa566e93acff3da8a62dd283022a0cb6ee34d' - checksumType64 = 'sha256' - url = 'https://github.com/ipinfo/cli/releases/download/ipinfo-3.3.0/ipinfo_3.3.0_windows_386.zip' - checksumType = 'sha256' - checksum = 'ddc0d4f17ca972cfc4bc76fc4775f67514e67bc654db4c9695993600a905525b' + url64 = '' + checksum64 = '' + checksumType64 = '' + url = '' + checksumType = '' + checksum = '' destination = $toolsDir }