Skip to content

Commit

Permalink
Move to minver for automatic versioning (#2063)
Browse files Browse the repository at this point in the history
* Reference minver and minver-cli

* Move minver reference to root, version all projects alike

* Update Versioning in build script

* Update cargo_pkg_version and ensure custom AssemblyVersion anchor

* Ensure we call dotnet restore before dotnet-minver

* ensure tools are restored in build.rs

* ensure we dotnet tool restore before general build

* remove unnecessary dotnet tool restore before minver invocation

* remove VersionPrefix as a concept

* ensure pack is delayed

* ensure zip file is removed before repackaging

* prevent building the profiler twice

* remove canary arg to release.sh in jenkinsfile

* Ensure LOCAL license target is back, no need to ignore generated license in git

* Ensure minver does not run on classic csproj sample app

* Add ignored mongodb license

* Propery anchor version checks inside profile

* ensure dotnet context around building docker image

* ensure curl retries

* curl too old for --retry-all-errors

* ensure all targets call bootstrap for tags
  • Loading branch information
Mpdreamz committed May 24, 2023
1 parent ee82daa commit 91628fa
Show file tree
Hide file tree
Showing 25 changed files with 546 additions and 312 deletions.
9 changes: 4 additions & 5 deletions .ci/linux/build_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ ZIP_FILE_BASE_PATH="/build/output/"

readonly NAMESPACE="observability"

DOTNET_AGENT_VERSION=$(grep "VersionPrefix" ${BUILD_PROPS} | sed 's#<.*>\(.*\)<.*>#\1#' | tr -d " ")
if [ -z "${DOTNET_AGENT_VERSION}" ] ; then
echo 'ERROR: DOTNET_AGENT_VERSION could not be calculated.' && exit 1
fi
DOTNET_AGENT_VERSION=$(dotnet minver -t=v -p=canary.0 -v=e)
if [ -z "${DOTNET_AGENT_VERSION}" ] ; then
echo 'ERROR: DOTNET_AGENT_VERSION could not be calculated.' && exit 1
fi

echo 'agent version: ' ${DOTNET_AGENT_VERSION}

AGENT_ZIP_FILE=${ZIP_FILE_BASE_PATH}elastic_apm_profiler_${DOTNET_AGENT_VERSION}-linux-x64.zip

echo 'agent path: ' ${AGENT_ZIP_FILE}


docker build . -t docker.elastic.co/$NAMESPACE/apm-agent-dotnet:$DOTNET_AGENT_VERSION \
--build-arg AGENT_ZIP_FILE=${AGENT_ZIP_FILE}
10 changes: 1 addition & 9 deletions .ci/linux/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,4 @@
#
set -euxo pipefail

VERSION_SUFFIX_ENABLED=${1:-"false"}

# Set the canary flag if required
FLAG=''
if [ "${VERSION_SUFFIX_ENABLED}" = "true" ]; then
FLAG='--canary'
fi

./build.sh pack ${FLAG}
./build.sh pack
16 changes: 14 additions & 2 deletions .github/workflows/bootstrap/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
---
name: Bootstrap Checkout
description: Ensures an action that needs to build has access to git tags
description: Ensures all actions bootstrap the same

inputs:
rust:
description: 'Install rust toolchain ("true" or "false")'
required: false
default: "false"

runs:
using: "composite"
Expand Down Expand Up @@ -30,4 +36,10 @@ runs:

# Setup git config
- uses: elastic/apm-pipeline-library/.github/actions/setup-git@current
- uses: elastic/apm-pipeline-library/.github/actions/setup-git@current

# install common dependencies
- name: Install common dependencies
uses: ./.github/workflows/install-dependencies
with:
rust: '${{ inputs.rust }}'
23 changes: 23 additions & 0 deletions .github/workflows/install-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Install Dependencies
description: Ensures an action has the appropiate non .NET dependencies installed

inputs:
rust:
description: 'Install rust toolchain ("true" or "false")'
required: false
default: "false"

runs:
using: "composite"
steps:
- name: Rustup
if: "${{ inputs.rust == 'true' }}"
shell: bash
run: rustup default 1.67.1

- name: Cargo make
if: "${{ inputs.rust == 'true' }}"
shell: bash
run: cargo install --force cargo-make

15 changes: 5 additions & 10 deletions .github/workflows/release-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,13 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
3.1.100
5.0.100
6.0.100
7.0.100
- name: Bootstrap Action Workspace
uses: ./.github/workflows/bootstrap
with:
rust: 'true'

- name: Package with canary suffix
run: .ci/linux/release.sh true
run: .ci/linux/release.sh

- name: Prepare feedz.io
uses: hashicorp/vault-action@v2.4.2
Expand Down
13 changes: 4 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,13 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Setup dotnet
uses: actions/setup-dotnet@v3
- name: Bootstrap Action Workspace
uses: ./.github/workflows/bootstrap
with:
dotnet-version: |
3.1.100
5.0.100
6.0.100
7.0.100
rust: 'true'

- name: Package
run: .ci/linux/release.sh false
run: .ci/linux/release.sh

- name: Prepare Nuget
uses: hashicorp/vault-action@v2.4.2
Expand Down
19 changes: 8 additions & 11 deletions .github/workflows/snapshoty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Build
run: .ci/linux/build.sh

- name: Rustup
run: rustup default 1.67.1

- name: Cargo make
run: cargo install --force cargo-make
- name: Bootstrap Action Workspace
uses: ./.github/workflows/bootstrap
with:
rust: 'true'

- name: Package
run: .ci/linux/release.sh true
run: .ci/linux/release.sh

- uses: actions/upload-artifact@v3
with:
Expand All @@ -41,6 +36,8 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Bootstrap Action Workspace
uses: ./.github/workflows/bootstrap

- name: Tools
run: .ci\\windows\\tools.ps1
Expand Down Expand Up @@ -69,7 +66,7 @@ jobs:
steps:

- uses: actions/checkout@v3

- uses: actions/download-artifact@v3
with:
name: snapshoty-linux
Expand Down
54 changes: 16 additions & 38 deletions .github/workflows/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,22 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Rustup
run: rustup default 1.67.1

- name: Cargo make
run: cargo install --force cargo-make

- name: Build
run: ./build.sh

- name: Bootstrap Action Workspace
uses: ./.github/workflows/bootstrap
with:
rust: 'true'

- name: Package
run: .ci/linux/release.sh true

- name: Build profiler
run: ./build.sh profiler-zip
run: .ci/linux/release.sh

test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Bootstrap Action Workspace
uses: ./.github/workflows/bootstrap

- name: Test & coverage
run: .ci/linux/test.sh

Expand All @@ -64,18 +58,12 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Bootstrap Action Workspace
uses: ./.github/workflows/bootstrap

- name: Build agent-zip
run: ./build.sh agent-zip

- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
3.1.100
5.0.100
6.0.100
7.0.100
- name: Startup Hook Tests
run: .ci/linux/test-startuphooks.sh

Expand All @@ -91,21 +79,11 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Rustup
run: rustup default 1.67.1

- name: Cargo make
run: cargo install --force cargo-make

- name: Setup dotnet
uses: actions/setup-dotnet@v3
- name: Bootstrap Action Workspace
uses: ./.github/workflows/bootstrap
with:
dotnet-version: |
3.1.100
5.0.100
6.0.100
7.0.100
rust: 'true'

- name: Build profiler
run: ./build.sh profiler-zip

Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/test-windows-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Bootstrap Action Workspace
uses: ./.github/workflows/bootstrap

- name: Install tools
run: .ci\\windows\\tools.ps1
shell: pwsh
Expand Down Expand Up @@ -68,6 +71,8 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Bootstrap Action Workspace
uses: ./.github/workflows/bootstrap

- name: Install test tools
run: .ci\\windows\\test-tools.ps1
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,6 @@ terraform.tfstate.backup
# Azure credentials file
.credentials.json

# This file is generated on build
src/Elastic.Apm.MongoDb/LICENSE

# Rust files
target/
Cargo.lock
Expand Down
7 changes: 7 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@
<ExposedPublicKeySampleApps>0024000004800000940000000602000000240000525341310004000001000100553bc065771cba5728dd48f670a8f93d119fe6f165a3b65dbff073687a014dd033b9a0019cb7d790c7ffaff9e8b5204eb56364ea7e3da5b681136e3082a2c5ae826018f9d1578536923205ad6e9d7d877dffc22d33099c561f3409874fb286641bac5ec51017baf7817cef7dbf727b05d26e1dccc54de08d786398381b5085b2</ExposedPublicKeySampleApps>
<DelaySign>false</DelaySign>
</PropertyGroup>
<!-- MinVer Configuration -->
<PropertyGroup>
<MinVerTagPrefix>v</MinVerTagPrefix>
<MinVerDefaultPreReleaseIdentifiers>canary.0</MinVerDefaultPreReleaseIdentifiers>
<MinVerMinimumMajorMinor>0.1</MinVerMinimumMajorMinor>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MinVer" Version="4.3.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net462" Version="1.0.3" PrivateAssets="all"/>
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions ElasticApmAgent.sln
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ Global
{6D413E0A-1CB7-4A2D-8E99-DB4F58D3463E}.Release|Any CPU.Build.0 = Release|Any CPU
{CB623206-F69E-4004-8527-D4B971AA981A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CB623206-F69E-4004-8527-D4B971AA981A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB623206-F69E-4004-8527-D4B971AA981A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB623206-F69E-4004-8527-D4B971AA981A}.Release|Any CPU.Build.0 = Release|Any CPU
{5D076C7F-1F8B-4B11-9910-48717D133963}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5D076C7F-1F8B-4B11-9910-48717D133963}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5D076C7F-1F8B-4B11-9910-48717D133963}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
34 changes: 3 additions & 31 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ This guide aims to provide guidance on how to release new versions of the `apm-a

Releasing a new version of the binary implies that there have been changes in the source code which are meant to be released for wider consumption. Before releasing a new version there's some prerequisites that have to be checked.

### Make sure the version is updated
### Versioning

Since the source has changed, we need to update the current committed version to a higher version so that the release is published.
Versioning off the binaries is automated through [minver](https://github.com/adamralph/minver)

The version is currently defined in the [Directory.Build.props](./src/Directory.Build.props) in the [SEMVER](https://semver.org) format: `MAJOR.MINOR.BUG`

Say we want to perform a minor version release (i.e. no breaking changes and only new features and bug fixes are being included); in which case we'll update the _MINOR_ part of the version.

For instance, the bump from version 1.1.2 to 1.2 can be found in this https://github.com/elastic/apm-agent-dotnet/pull/624
The tag dictates the version number. Untagged commits are automatically versioned as prereleases according to their distance to their closest version tag.

### Generating a changelog for the new version

Expand Down Expand Up @@ -86,30 +82,6 @@ In this PR we need to update:
- [`conf.yaml`](https://github.com/elastic/docs/blob/master/conf.yaml): Set the `current` part to the new `<major>.x` and add that to the `branches` and `live` parts. In addition, remove the previous major entry from the `live` key.
- [`shared/versions/stack/*.asciidoc`](https://github.com/elastic/docs/tree/master/shared/versions/stack): This directory defines how links from stack-versioned documentation relate to links from non stack-versioned documentation. For example, in the `8.5` file, the variable `:apm-dotnet-branch:` is set to `1.x`. This means any links in the `8.5` stack docs (like the APM Guide) that point to the APM .NET Agent reference, will point to the `1.x` version of those docs. The number of files you update in this directory depends on version compatibility between stack docs and your APM agent. In general, we update as far back as the new version of the agent is compatible with the stack; this pushes new documentation to the user.

### Prepare the next (pre-release) version

To clearly distinguish pre-release builds and artifacts from the newly released ones,
bump the agent version again by adding the `-alpha` suffix to the following files:

- `/src/Directory.Build.props`:

```xml
...
<InformationalVersion>1.20.0-alpha</InformationalVersion>
<VersionPrefix>1.20.0-alpha</VersionPrefix>
...
```

**Note** that `AssemblyVersion` and `FileVersion` do not add the `-alpha` prefix.

- `/src/elastic_apm_profiler/Cargo.toml`:

```toml
...
version = "1.20.0-alpha"
...
```

## Executing the release script locally

If required then it's possible to run the release script locally, for such, the credentials are needed to push to the NuGet repo.
Expand Down
Loading

0 comments on commit 91628fa

Please sign in to comment.