Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

(MAINT) Release prep 0.5.0 #256

Merged
merged 5 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/installation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Installation Tests

on:
pull_request:
branches: [ main ]

jobs:
install_test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
env:
PCT_INSTALL_DEBUG: true
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get Latest Tag (Windows)
id: latest_tag
if: runner.os == 'Windows'
run: |
$TagVersion = git tag --list |
Where-Object { $_ -match '^\d+\.\d+\.\d+$' } |
Sort-Object -Descending |
Select-Object -First 1
echo "::set-output name=tag::0.4.0 d18bd02"
- name: Install PCT (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
. .\tools\install.ps1; Install-Pct
- name: Validate install (Windows)
if: runner.os == 'Windows'
run: |
$HomeDir = Get-Item ~ | Select-Object -ExpandProperty FullName
$PctPath = "${HomeDir}\.puppetlabs\pct\pct.exe"
$verInfo = & $PctPath --version |
Select-Object -First 1 |
ForEach-Object { $_ -split " " } |
Select-Object -Skip 1 -First 2
if (& $PctPath --version | Out-String -Stream | Select-String -Pattern '${{ steps.latest_tag.outputs.tag }}') {
exit 0
} else {
exit 1
}
- name: Install PCT (Unix)
if: runner.os != 'Windows'
run: ./tools/install.sh
- name: Validate install (Unix)
if: runner.os != 'Windows'
run: $HOME/.puppetlabs/pct/pct --version | grep "pct $(git tag | tail -n 1)"
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ builds:
mod_timestamp: '{{ .CommitTimestamp }}'

archives:
- name_template: "{{ .ProjectName }}_{{ .Version }}_{{ tolower .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}"
- name_template: "{{ .ProjectName }}_{{ tolower .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}"
replacements:
darwin: Darwin
linux: Linux
Expand Down
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* [Installing template packages](#installing-template-packages)
* [Request a feature](#request-a-feature)
* [Reporting Problems](#reporting-problems)
* [Installing Telemetry Free Version](#installing-telemetry-free-version)

## Overview

Expand All @@ -50,7 +51,7 @@ curl -L https://pup.pt/pdkgo/install.sh | sh
### Windows Systems

```ps
iex "&{ $(irm https://pup.pt/pdkgo/install.ps1) }"
iex "&{ $(irm https://pup.pt/pdkgo/install.ps1); Install-Pct }"
```

This will install the latest release of PCT to `~/.puppetlabs/pct`.
Expand All @@ -59,6 +60,9 @@ This will install the latest release of PCT to `~/.puppetlabs/pct`.

> :warning: If you do not use the install script and are extracting the archive yourself, be sure to use the fully qualified path to `~/.puppetlabs/pct` on *nix or `$HOME/.puppetlabs/pct` on Windows when you set your `PATH` environment variable.

A version of the product, with telemetry functionality disabled, is available too.
See [here](#installing-telemetry-free-version) for instructions on how to install it.

## Setting up Tab Completion

After installation, we'd highly recommend setting up tab completion for your shell to ensure the best possible experience.
Expand Down Expand Up @@ -445,3 +449,32 @@ to file an issue on our GitHub repository: https://github.com/puppetlabs/pdkgo/i

Make sure to fill in the information that is requested in the issue template as it
will help us investigate the problem more quickly.

## Installing Telemetry Free Version

As of `0.5.0`, we have been gathering telemetry data to provide insights in to how our products are being used.

The following data is collected:

- Version of application in use
- OS / platform of the device
- What commands have been invoked (including command args)
- Any errors that occurred when running the application

We understand that there will be some users who prefer to have no telemetry data sent.
For those users, we offer a version of PCT with the telemetry functionality disabled.

To install:
### Unix Systems

```bash
curl -L https://pup.pt/pdkgo/install.sh | sh -s -- --no-telemetry
```

### Windows Systems

```ps
iex "&{ $(irm https://pup.pt/pdkgo/install.ps1); Install-Pct -NoTelemetry }"
```

This will install the latest release of PCT, without telemetry functionality, to `~/.puppetlabs/pct`.
84 changes: 48 additions & 36 deletions tools/install.ps1
Original file line number Diff line number Diff line change
@@ -1,49 +1,61 @@
[CmdletBinding()]
param (
)
function Install-Pct {
[CmdletBinding()]
param (
[switch]$NoTelemetry
)

Set-StrictMode -Version 3.0
$ErrorActionPreference = "Stop"
Set-StrictMode -Version 3.0
$ErrorActionPreference = "Stop"

$org = 'puppetlabs'
$repo = 'pdkgo'
$org = 'puppetlabs'
$repo = 'pdkgo'

$app = 'pct'
$app = 'pct'

$arch = "x86_64"
$os = 'windows'
$ext = '.zip'
$appPkgName = 'pct'
if ($NoTelemetry) {
$appPkgName = 'notel_pct'
}

$ver = (Invoke-RestMethod "https://api.github.com/repos/${org}/${repo}/releases")[0].tag_name
$file = "${app}_${ver}_${os}_${arch}${ext}"
$downloadURL = "https://github.com/${org}/${repo}/releases/download/$ver/$file"
$arch = "x86_64"
$os = 'windows'
$ext = '.zip'

$Destination = "~/.puppetlabs/pct"
$Destination = $PSCmdlet.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Destination)
$file = "${appPkgName}_${os}_${arch}${ext}"
$downloadURL = "https://github.com/${org}/${repo}/releases/latest/download/$file"

$tempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName())
$null = New-Item -ItemType Directory -Path $tempDir -Force -ErrorAction SilentlyContinue
$packagePath = Join-Path -Path $tempDir -ChildPath $file
$Destination = "~/.puppetlabs/pct"
$Destination = $PSCmdlet.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Destination)

if (!$PSVersionTable.ContainsKey('PSEdition') -or $PSVersionTable.PSEdition -eq "Desktop") {
$oldProgressPreference = $ProgressPreference
$ProgressPreference = "SilentlyContinue"
}
$tempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName())
$null = New-Item -ItemType Directory -Path $tempDir -Force -ErrorAction SilentlyContinue
$packagePath = Join-Path -Path $tempDir -ChildPath $file

try {
Write-Host "Downloading and extracting ${app} ${ver} to ${Destination}"
Invoke-WebRequest -Uri $downloadURL -OutFile $packagePath
}
finally {
if (!$PSVersionTable.ContainsKey('PSEdition') -or $PSVersionTable.PSEdition -eq "Desktop") {
$ProgressPreference = $oldProgressPreference
$oldProgressPreference = $ProgressPreference
$ProgressPreference = "SilentlyContinue"
}
}

if (Test-Path -Path $Destination) {
Remove-Item -Path $Destination -Force -Recurse
}
Expand-Archive -Path $packagePath -DestinationPath $Destination
try {
if ($NoTelemetry) {
Write-Host "Downloading and extracting ${app} (TELEMETRY DISABLED VERSION) to ${Destination}"
}
else {
Write-Host "Downloading and extracting ${app} to ${Destination}"
}
Invoke-WebRequest -Uri $downloadURL -OutFile $packagePath
}
finally {
if (!$PSVersionTable.ContainsKey('PSEdition') -or $PSVersionTable.PSEdition -eq "Desktop") {
$ProgressPreference = $oldProgressPreference
}
}

Write-Host 'Remember to add the pct app to your path:'
Write-Host "`$env:Path += `"`$env:PATH;${Destination}`""
if (Test-Path -Path $Destination) {
Remove-Item -Path $Destination -Force -Recurse
}
Expand-Archive -Path $packagePath -DestinationPath $Destination

Write-Host 'Remember to add the pct app to your path:'
Write-Host "`$env:Path += `"`$env:PATH;${Destination}`""
}
104 changes: 87 additions & 17 deletions tools/install.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,99 @@
#!/bin/sh
set -eu
set -e

org="puppetlabs"
repo="pdkgo"
ARCH="x86_64"
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
EXT=".tar.gz"

app="pct"
ORG="puppetlabs"
REPO="pdkgo"
APP="pct"
APP_PKG_NAME="pct"

arch="x86_64"
os="$(uname -s | tr '[:upper:]' '[:lower:]')"
ext=".tar.gz"
NO_TEL=${1:-false}

releases="$(curl -s -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${org}/${repo}/releases")"
if [ ${NO_TEL} = "--no-telemetry" ]; then
APP_PKG_NAME="notel_pct"
fi

ver="$(echo "$releases" | grep -oE -m 1 '"tag_name": "(([0-9]+\.)+[0-9]+(-pre+)?)"' | cut -d '"' -f 4 | head -1)"
RELEASES=""
FILE=""
VER=""
CHECKSUM=""

file="${app}_${ver}_${os}_${arch}${ext}"
logDebug() {
if [ ! -z $PCT_INSTALL_DEBUG ]; then
echo $1
fi
}

downloadURL="https://github.com/${org}/${repo}/releases/download/${ver}/${file}"
getChecksums() {
for i in {1..5}; do
FILE="${APP_PKG_NAME}_${OS}_${ARCH}${EXT}"
checksumURL="https://github.com/${ORG}/${REPO}/releases/latest/download/checksums.txt"
resp=$(curl -Ls "${checksumURL}" -o /tmp/pct_checksums.txt --write-out "%{http_code}")
respCode=$(echo ${resp} | tail -n 1)
logDebug "GET ${checksumURL} | Resp: ${resp}"
if [ ${respCode} -ne 200 ]; then
echo "Fetching checksums.txt failed on attempt ${i}, retrying..."
sleep 5
else
CHECKSUM=$(grep ${FILE} /tmp/pct_checksums.txt | cut -d ' ' -f 1)
return 0
fi
done
echo "Fetching checksums.txt failed after max retry attempts"
exit 1
}

destination="${HOME}/.puppetlabs/pct"
downloadLatestRelease() {
destination="${HOME}/.puppetlabs/pct"

[ -d "${destination}" ] || mkdir -p "${destination}"
[ -d ${destination} ] || mkdir -p ${destination} ]

echo "Downloading and extracting ${app} ${ver} to ${destination}"
curl -L -s "${downloadURL}" -o - | tar xz -C "${destination}"
if [ "${noTel}" = "--no-telemetry" ]; then
echo "Downloading and extracting ${APP_PKG_NAME} (TELEMETRY DISABLED VERSION) to ${destination}"
else
echo "Downloading and extracting ${APP_PKG_NAME} to ${destination}"
fi

echo 'Remember to add the pct app to your path:'
echo 'export PATH=$PATH:'${destination}
downloadURL="https://github.com/${ORG}/${REPO}/releases/latest/download/${FILE}"

for i in {1..5}; do
resp=$(curl -Ls ${downloadURL} -o /tmp/${FILE} --write-out "%{http_code}")
respCode=$(echo ${resp} | tail -n 1)
logDebug "GET ${downloadURL} | Resp: ${resp}"
if [ ${respCode} -ne 200 ]; then
echo "Fetching PCT package failed on attempt ${i}, retrying..."
sleep 5
else
downloadChecksumRaw=$(shasum -a 256 /tmp/${FILE} || sha256sum /tmp/${FILE})
downloadChecksum=$(echo ${downloadChecksumRaw} | cut -d ' ' -f 1)
logDebug "Checksum calc for ${FILE}:"
logDebug " - Expect checksum: ${CHECKSUM}"
logDebug " - Actual checksum: ${downloadChecksum}"
if [ ${downloadChecksum} = ${CHECKSUM} ]; then
logDebug "Extracting /tmp/${FILE} to ${destination}"
tar -zxf "/tmp/${FILE}" -C ${destination}
tarStatus=$(echo $?)
logDebug "Removing /tmp/${FILE}"
rm "/tmp/${FILE}"
if [ ${tarStatus} -eq 0 ]; then
echo "Remember to add the pct app to your path:"
echo 'export PATH=$PATH:'${destination}
exit 0
else
echo "Untar unsuccessful (status code: $?)"
exit 1
fi
else
echo "Checksum verification failed for ${FILE}"
exit 1
fi
return 0
fi
done
}

getChecksums
downloadLatestRelease