Skip to content

Commit

Permalink
Use version from MANIFEST_URL (#274)
Browse files Browse the repository at this point in the history
This commit derives the version directly from the MANIFEST_URL env var
rather than rely on `StackVersion` defined in `Directory.Build.Props`.

Closes #271
  • Loading branch information
dliappis authored Jun 26, 2024
1 parent 5a62a6e commit b67ab1c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 61 deletions.
18 changes: 4 additions & 14 deletions .buildkite/scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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"

Expand Down
17 changes: 12 additions & 5 deletions .buildkite/scripts/dra-publish.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -uo pipefail
set -euo pipefail


# Download artifacts from Buildkite "Build stack installers" step
Expand All @@ -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'[><]' '/<StackVersion>/{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
Expand All @@ -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 \
#
}
Expand Down
24 changes: 0 additions & 24 deletions Directory.Build.props

This file was deleted.

18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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\<version>\<beat>` eg. `c:\Program Files\Elastic\Beats\8.12.0\winlogbeat`.
Expand Down

0 comments on commit b67ab1c

Please sign in to comment.