Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use version from MANIFEST_URL #274

Merged
merged 12 commits into from
Jun 26, 2024
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
11 changes: 8 additions & 3 deletions .buildkite/scripts/dra-publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +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:]')
export VERSION

if [ "$DRA_WORKFLOW" == "staging" ]; then
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')
fi

# Retrieve version value
VERSION=$(curl -s --retry 5 --retry-delay 10 "$MANIFEST_URL" | jq -r '.version')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$VERSION is used above, before it's defined

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Fixed in af501a4

export VERSION
if [[ -z $VERSION ]]; then
echo "+++ Required version property from ${MANIFEST_URL} was empty: [$VERSION]. Exiting."
exit 1
fi

# Publish DRA artifacts
function run_release_manager() {
echo "+++ Publishing $BUILDKITE_BRANCH ${DRA_WORKFLOW} DRA artifacts..."
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).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Directory.Build.props should have a place-holder version like 0.0.0 to avoid confusion ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Directory.Build.props should have a place-holder version like 0.0.0 to avoid confusion ?

Not sure I follow, in this PR we are completely removing the file Directory.Build.props as it doesn't seem to be needed anywhere. Additionally all references to manual tasks in the README file.

Do you think we still need to keep the file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're all good, my bad. I was looking for a change that removes the property not the entire file, I didn't realise it only holds this one value.


### 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