From b67ab1c118e092139f1344443ddbe6da8048e02a Mon Sep 17 00:00:00 2001 From: Dimitrios Liappis Date: Wed, 26 Jun 2024 17:22:13 +0300 Subject: [PATCH] Use version from MANIFEST_URL (#274) This commit derives the version directly from the MANIFEST_URL env var rather than rely on `StackVersion` defined in `Directory.Build.Props`. Closes https://github.com/elastic/elastic-stack-installers/issues/271 --- .buildkite/scripts/build.ps1 | 18 ++++-------------- .buildkite/scripts/dra-publish.sh | 17 ++++++++++++----- Directory.Build.props | 24 ------------------------ README.md | 18 ------------------ 4 files changed, 16 insertions(+), 61 deletions(-) delete mode 100644 Directory.Build.props diff --git a/.buildkite/scripts/build.ps1 b/.buildkite/scripts/build.ps1 index 7e83fb6..a0d2561 100755 --- a/.buildkite/scripts/build.ps1 +++ b/.buildkite/scripts/build.ps1 @@ -88,20 +88,6 @@ cd .. Copy-Item -Path .\elastic-stack-installers -Destination c:\users\buildkite\esi -Recurse cd c:\users\buildkite\esi -# Read the stack version from build properties -[xml]$xml = Get-Content -Path "Directory.Build.props" -$ns = New-Object Xml.XmlNamespaceManager($xml.NameTable) -$ns.AddNamespace("ns", "http://schemas.microsoft.com/developer/msbuild/2003") -$stack_version = $xml.SelectSingleNode("//ns:PropertyGroup/ns:StackVersion", $ns).InnerText -$workflow = ${env:DRA_WORKFLOW} -if ($workflow -eq "snapshot") { - $version = $stack_version + "-" + $workflow.ToUpper() -} else { - $version = $stack_version -} - -Write-Host "~~~ Building Stack version: $stack_version" - Write-Output "~~~ Installing dotnet-sdk" & "./tools/dotnet-install.ps1" -NoPath -JSonFile global.json -Architecture "x64" -InstallDir c:/dotnet-sdk ${env:PATH} = "c:\dotnet-sdk;" + ${env:PATH} @@ -121,6 +107,10 @@ New-Item bin/in -Type Directory -Force $manifestUrl = ${env:MANIFEST_URL} $response = Invoke-WebRequest -UseBasicParsing -Uri $manifestUrl $json = $response.Content | ConvertFrom-Json +$version = $json.version +$workflow = ${env:DRA_WORKFLOW} + +Write-Host "~~~ Building version: $version" Write-Output "~~~ Downloading $workflow dependencies" diff --git a/.buildkite/scripts/dra-publish.sh b/.buildkite/scripts/dra-publish.sh index 126d9f2..6ae3b61 100644 --- a/.buildkite/scripts/dra-publish.sh +++ b/.buildkite/scripts/dra-publish.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -uo pipefail +set -euo pipefail # Download artifacts from Buildkite "Build stack installers" step @@ -19,14 +19,21 @@ VAULT_ROLE_ID=$(echo $DRA_CREDS | jq -r '.role_id') VAULT_SECRET_ID=$(echo $DRA_CREDS | jq -r '.secret_id') BRANCH="${BUILDKITE_BRANCH}" export VAULT_ADDR VAULT_ROLE_ID VAULT_SECRET_ID + # Retrieve version value -VERSION=$(cat Directory.Build.props | awk -F'[><]' '//{print $3}' | tr -d '[:space:]') +VERSION=$(curl -s --retry 5 --retry-delay 10 "$MANIFEST_URL" | jq -r '.version') +# remove -SNAPSHOT style suffix from VERSION +VERSION=${VERSION%-*} export VERSION +if [[ -z $VERSION ]]; then + echo "+++ Required version property from ${MANIFEST_URL} was empty: [$VERSION]. Exiting." + exit 1 +fi if [ "$DRA_WORKFLOW" == "staging" ]; then - MANIFEST_URL=$(curl https://artifacts-"$DRA_WORKFLOW".elastic.co/beats/latest/"$VERSION".json | jq -r '.manifest_url') + BEATS_MANIFEST_URL=$(curl https://artifacts-"$DRA_WORKFLOW".elastic.co/beats/latest/"$VERSION".json | jq -r '.manifest_url') else - MANIFEST_URL=$(curl https://artifacts-"$DRA_WORKFLOW".elastic.co/beats/latest/"$VERSION"-SNAPSHOT.json | jq -r '.manifest_url') + BEATS_MANIFEST_URL=$(curl https://artifacts-"$DRA_WORKFLOW".elastic.co/beats/latest/"$VERSION"-SNAPSHOT.json | jq -r '.manifest_url') fi # Publish DRA artifacts @@ -50,7 +57,7 @@ function run_release_manager() { --workflow "${DRA_WORKFLOW}" \ --version "${VERSION}" \ --artifact-set main \ - --dependency beats:"${MANIFEST_URL}" \ + --dependency beats:"${BEATS_MANIFEST_URL}" \ $dry_run \ # } diff --git a/Directory.Build.props b/Directory.Build.props deleted file mode 100644 index ec94635..0000000 --- a/Directory.Build.props +++ /dev/null @@ -1,24 +0,0 @@ - - - - 8.15.0 - - - - Elastic - Elastic MSI package build system - (c) $([System.DateTime]::Now.ToString(yyyy)) Elastic - $(StackVersion) - $(StackVersion) - $(StackVersion) - - - <_GitHEADFilename>HEAD - <_GitSHALength>7 - <_GitDir Condition="'$(_GitHEADFilename)' != '' And $(_GitSHALength) > 0 And $(_GitSHALength) < 40 And Exists('$(MSBuildThisFileDirectory).git')">$(MSBuildThisFileDirectory).git - <_GitHEAD Condition="'$(_GitDir)' != '' And Exists('$(_GitDir)\$(_GitHEADFilename)')">$([System.IO.File]::ReadAllText('$(_GitDir)\$(_GitHEADFilename)').Trim()) - <_GitSHA Condition="'$(_GitHEAD)' != '' And '$(_GitHEAD.StartsWith(ref:))' == 'true'">$([System.IO.File]::ReadAllText('$(_GitDir)\$(_GitHEAD.Substring(5))').Substring(0,$(_GitSHALength))) - <_GitSHA Condition="'$(_GitHEAD)' != '' And '$(_GitHEAD.StartsWith(ref:))' == 'false'">$(_GitHEAD.Substring(0,$(_GitSHALength))) - $(InformationalVersion)-$(_GitSHA) - - diff --git a/README.md b/README.md index 3e9f1c3..4c10602 100644 --- a/README.md +++ b/README.md @@ -26,24 +26,6 @@ See [ElastiBuild](https://github.com/elastic/elastic-stack-installers/wiki/Elast **NOTE**: *Building from source should only be done for development purposes. Only the officially distributed and signed Elastic Stack Installers should be used in production. Using unofficial Elastic Stack Installers is not supported.* ---- - -## Bumping version - -### After a patch release - -Update version in `Directory.Build.props` in the branch for the related minor version (ex: https://github.com/elastic/elastic-stack-installers/pull/183). - -### After a minor release - -1. Create a branch for the next minor release from the main branch -2. Update the main branch: - - Bump version in `Directory.Build.props` - - Update `catalog-info.yaml`: - - Add a new daily schedule for the new minor branch - - Remove the daily schedule for the previous minor branch - ex: https://github.com/elastic/elastic-stack-installers/pull/156 and https://github.com/elastic/elastic-stack-installers/pull/172 - --- ## Installing to a custom location The default target folder for the MSI is typically something like `c:\Program Files\Elastic\Beats\\` eg. `c:\Program Files\Elastic\Beats\8.12.0\winlogbeat`.