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

Automate script versioning #2984

Merged
merged 6 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
shell: powershell
run: |
$log_path = "C:\ProgramData\OpenTelemetry .NET AutoInstrumentation\logs\*"
Import-Module "${PWD}/OpenTelemetry.DotNet.Auto.psm1"
Import-Module "${PWD}/bin/installation-scripts/OpenTelemetry.DotNet.Auto.psm1"
pjanotti marked this conversation as resolved.
Show resolved Hide resolved
[System.Environment]::SetEnvironmentVariable("OTEL_DOTNET_AUTO_INSTALL_DIR", "${PWD}/bin/tracer-home", [System.EnvironmentVariableTarget]::Machine)
Register-OpenTelemetryForCurrentSession -OTelServiceName "MyServiceDisplayName"
./test/test-applications/integrations/bin/TestApplication.Smoke/Release/net7.0/TestApplication.Smoke.exe
Expand All @@ -84,6 +84,12 @@ jobs:
with:
name: bin-${{ matrix.machine }}
path: bin/tracer-home
- name: Upload installation scripts
uses: actions/[email protected]
if: always()
with:
name: installation-scripts-${{ matrix.machine }}
path: bin/installation-scripts
- name: Regenerate LibraryVersions.g.cs
# Regenerate the library versions file to surface any version changes made to the packages being tested.
run: ./build.cmd GenerateLibraryVersionFiles
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
cd testapp
dotnet new console
dotnet publish -f net7.0 -c Release
$module_url = "https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/OpenTelemetry.DotNet.Auto.psm1"
$module_url = "https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/OpenTelemetry.DotNet.Auto.psm1"
$dl_path = Join-Path $env:temp "OpenTelemetry.DotNet.Auto.psm1"
$log_path = "C:\ProgramData\OpenTelemetry .NET AutoInstrumentation\logs\*"
Invoke-WebRequest -Uri $module_url -OutFile $dl_path
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
cd testapp
dotnet new console
dotnet publish -f net7.0 -c Release
curl -sSfL https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/otel-dotnet-auto-install.sh -O
curl -sSfL https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/otel-dotnet-auto-install.sh -O
sh ./otel-dotnet-auto-install.sh
test "$(ls -A "$HOME/.otel-dotnet-auto")"
curl -sSfL https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/instrument.sh -O
Expand All @@ -96,7 +96,7 @@ jobs:
cd testapp
dotnet new console
dotnet publish -f net7.0 -c Release
curl -sSfL https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/otel-dotnet-auto-install.sh -O
curl -sSfL https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/otel-dotnet-auto-install.sh -O
sh ./otel-dotnet-auto-install.sh
test "$(ls -A "$HOME/.otel-dotnet-auto")"
curl -sSfL https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/instrument.sh -O
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
- run: cd bin-windows-2022 ; zip -qq -r ../opentelemetry-dotnet-instrumentation-windows.zip . * ; cd ..
- run: cd bin-macos-11 ; zip -qq -r ../opentelemetry-dotnet-instrumentation-macos.zip . * ; cd ..
- run: cd bin-nuget-packages ; zip -qq -r ../opentelemetry-dotnet-instrumentation-nuget-packages.zip . * ; cd ..
- run: cp installation-scripts-windows-2022/otel-dotnet-auto-install.sh ./otel-dotnet-auto-install.sh
- run: cp installation-scripts-windows-2022/OpenTelemetry.DotNet.Auto.psm1 ./OpenTelemetry.DotNet.Auto.psm1
- name: Create Release
run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --draft ./*.zip ./otel-dotnet-auto-install.sh ./OpenTelemetry.DotNet.Auto.psm1
env:
Expand Down
23 changes: 23 additions & 0 deletions build/Build.InstallationScripts.Steps.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Nuke.Common;
using Nuke.Common.IO;

partial class Build
{
AbsolutePath InstallationScriptsDirectory => OutputDirectory / "installation-scripts";

Target BuildInstallationScripts => _ => _
.After(Clean)
.After(CreateRequiredDirectories)
.Executes(() =>
{
var scriptTemplates = RootDirectory / "script-templates";
var templateFiles = scriptTemplates.GetFiles();
foreach (var templateFile in templateFiles)
{
var scriptFile = InstallationScriptsDirectory / templateFile.Name.Replace(".template", "");
FileSystemTasks.CopyFile(templateFile, scriptFile);
scriptFile.UpdateText(x =>
x.Replace("{{VERSION}}", VersionHelper.GetVersion()));
}
});
}
3 changes: 2 additions & 1 deletion build/Build.Steps.Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ partial class Build
Target PublishIisTestApplications => _ => _
.Unlisted()
.After(CompileManagedTests)
.After(BuildInstallationScripts)
.OnlyWhenStatic(() => IsWin && (Containers == ContainersWindows || Containers == ContainersWindowsOnly))
.Executes(() =>
{
Expand All @@ -135,7 +136,7 @@ partial class Build
void BuildDockerImage(Project project)
{
const string moduleName = "OpenTelemetry.DotNet.Auto.psm1";
var sourceModulePath = Solution.Directory / moduleName;
var sourceModulePath = InstallationScriptsDirectory / moduleName;
var localBinDirectory = project.Directory / "bin";
var localTracerZip = localBinDirectory / "tracer.zip";

Expand Down
2 changes: 2 additions & 0 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ void DeleteReparsePoints(string path)
.After(Clean)
.After(Restore)
.DependsOn(CreateRequiredDirectories)
.DependsOn(BuildInstallationScripts)
.DependsOn(GenerateNetFxTransientDependencies)
.DependsOn(CompileManagedSrc)
.DependsOn(PublishManagedProfiler)
Expand All @@ -121,6 +122,7 @@ void DeleteReparsePoints(string path)
.Description("Builds the managed unit / integration tests and runs them")
.After(Clean, BuildTracer)
.DependsOn(CreateRequiredDirectories)
.DependsOn(BuildInstallationScripts)
.DependsOn(GenerateLibraryVersionFiles)
.DependsOn(CompileManagedTests)
.DependsOn(CompileMocks)
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ chmod +x $HOME/.otel-dotnet-auto/instrument.sh
OTEL_SERVICE_NAME=myapp OTEL_RESOURCE_ATTRIBUTES=deployment.environment=staging,service.version=1.0.0 ./MyNetApp
```

[otel-dotnet-auto-install.sh](../otel-dotnet-auto-install.sh) script
`otel-dotnet-auto-install.sh` script
uses environment variables as parameters:

| Parameter | Description | Required | Default value |
Expand Down
2 changes: 0 additions & 2 deletions docs/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

1. Update the version in the following files:

- [`OpenTelemetry.DotNet.Auto.psm1`](../OpenTelemetry.DotNet.Auto.psm1)
- [`otel-dotnet-auto-install.sh`](../otel-dotnet-auto-install.sh)
- [`docs/README.md`](./README.md)

1. Update the [CHANGELOG.md](../CHANGELOG.md) with the new release.
Expand Down
6 changes: 3 additions & 3 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ of assemblies loaded as domain-neutral.
different versions of some assemblies also shipped in the `netfx` folder.

If you are having problems in one of the scenarios above run again the
`Install-OpenTelemetryCore` command from the
[PowerShell installation module](../OpenTelemetry.DotNet.Auto.psm1)
to ensure that the required GAC installations are updated.
`Install-OpenTelemetryCore` command from the PowerShell installation module
`OpenTelemetry.DotNet.Auto.psm1` to ensure that the required GAC installations
are updated.

For more information about the GAC usage by the automatic instrumentation,
see [here](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/issues/1906#issuecomment-1376292814).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ function Install-OpenTelemetryCore() {
[string]$LocalPath
)

$version = "v1.0.2"
$version = "v{{VERSION}}"
$installDir = Get-CLIInstallDir-From-InstallDir $InstallDir
$archivePath = $null
$deleteArchive = $true
Expand Down
2 changes: 1 addition & 1 deletion otel-dotnet-auto-install.sh → ...ates/otel-dotnet-auto-install.sh.template
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ esac

test -z "$OTEL_DOTNET_AUTO_HOME" && OTEL_DOTNET_AUTO_HOME="$HOME/.otel-dotnet-auto"
test -z "$TMPDIR" && TMPDIR="$(mktemp -d)"
test -z "$VERSION" && VERSION="v1.0.2"
test -z "$VERSION" && VERSION="v{{VERSION}}"

RELEASES_URL="https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases"
ARCHIVE="opentelemetry-dotnet-instrumentation-$OS_TYPE.zip"
Expand Down
Loading