Skip to content

Commit

Permalink
fix: Goreleaser fixes (#591)
Browse files Browse the repository at this point in the history
* goreleaser fixes

* just use .Binary name template for archive step

* update archive name after rebase, use temp dir for untarred plugins
  • Loading branch information
BinaryFissionGames authored Mar 2, 2022
1 parent 49d1d31 commit 9cec988
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 29 deletions.
19 changes: 14 additions & 5 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
before:
hooks:
- mkdir -p ./tmp
- curl -fL https://github.com/observiq/stanza-plugins/releases/latest/download/stanza-plugins.tar.gz -o ./tmp/stanza-plugins.tar.gz
- curl -fL https://github.com/observiq/stanza-plugins/releases/latest/download/stanza-plugins.zip -o ./tmp/stanza-plugins.zip
- curl -fL https://github.com/observiq/stanza-plugins/releases/latest/download/version.json -o ./tmp/version.json
- tar -xf ./tmp/stanza-plugins.tar.gz -C ./tmp

builds:
- id: stanza
binary: stanza
Expand All @@ -20,14 +28,13 @@ builds:
- -X github.com/observiq/stanza/version.GitTag={{ .Tag }}
- -X github.com/observiq/stanza/version.GitCommit={{ .FullCommit }}
no_unique_dist_dir: false
hooks:
post: ./build/post.sh

archives:
- builds:
- stanza
# skip archiving as tar.gz / zip
format: binary
name_template: "stanza_{{ .Os }}_{{ .Arch }}"

nfpms:
- package_name: stanza
Expand All @@ -39,7 +46,7 @@ nfpms:
- rpm
- deb
contents:
- src: artifacts/plugins
- src: tmp/plugins
dst: /opt/observiq/stanza/plugins
- src: build/package/config.yaml
dst: /opt/observiq/stanza/config.yaml
Expand All @@ -58,8 +65,10 @@ release:
owner: observIQ
name: stanza
extra_files:
- glob: scripts/*install*
- glob: stanza*.msi
- glob: scripts/*install*
- glob: stanza*.msi
- glob: ./tmp/stanza-plugins.*
- glob: ./tmp/version.json

changelog:
skip: false
Expand Down
22 changes: 0 additions & 22 deletions build/post.sh

This file was deleted.

61 changes: 59 additions & 2 deletions scripts/windows-install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -288,18 +288,75 @@ new-module -name LogAgentInstall -scriptblock {
Show-ColorText 'Configuring download urls...'
Add-Indent
if ( !$script:version ) {
$script:agent_download_url = "$DOWNLOAD_BASE/latest/download/stanza_windows_amd64"
$script:agent_download_url = "$DOWNLOAD_BASE/latest/download/stanza_windows_amd64.exe"
$script:plugins_download_url = "$DOWNLOAD_BASE/latest/download/stanza-plugins.zip"
}
else {
$script:agent_download_url = "$DOWNLOAD_BASE/download/$script:version/stanza_windows_amd64"

if (Get-BinaryShouldHaveSuffix -version $script:version) {
$script:agent_download_url = "$DOWNLOAD_BASE/download/$script:version/stanza_windows_amd64.exe"
} else {
$script:agent_download_url = "$DOWNLOAD_BASE/download/$script:version/stanza_windows_amd64"
}

$script:plugins_download_url = "$DOWNLOAD_BASE/download/$script:version/stanza-plugins.zip"
}
Show-ColorText "Using agent download url: " '' "$script:agent_download_url" DarkCyan
Show-ColorText "Using plugins download url: " '' "$script:plugins_download_url" DarkCyan
Remove-Indent
}

# Determines whether the binary should have the .exe suffix or not.
# It should have the prefix if the version specified is after v1.6.0; v1.6.0 and before should not have this prefix.
function Get-BinaryShouldHaveSuffix {
param (
[string]$version
)
if ($version -match "^v(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)") {
$major = [int]$matches['major']
$minor = [int]$matches['minor']
$patch = [int]$matches['patch']

if ($major -gt 1) {
# version is 2+.x.x
Write-Output $true
return
}

if ($major -lt 1) {
# version is 0.x.x
Write-Output $false
return
}

if ($minor -gt 6) {
# version is 1.7+.x
Write-Output $true
return
}

if ($minor -lt 6) {
# version is 1.5-.x
Write-Output $false
return
}

if ($patch -gt 0) {
# version is 1.6.1+
Write-Output $true
return
}

# version is 1.6.0, which is the last release with no suffix for windows binaries
Write-Output $false
return
}

# Version doesn't match the semantic version convention; We'll assume that we should have the suffix.
Write-Output $true
return
}

# This will set the home directory of the agent based on
# the install directory provided.
function Set-HomeDir {
Expand Down

0 comments on commit 9cec988

Please sign in to comment.