From a320d296074ff3740418058a9e1356bb25af8de6 Mon Sep 17 00:00:00 2001 From: paologallinaharbur Date: Fri, 2 Oct 2020 12:39:37 +0200 Subject: [PATCH] chore(ci/cd): rearranged folder structure --- .github/workflows/create_release.yml | 19 ++++++++-------- exporters/githubactions/Makefile | 2 +- exporters/githubactions/exporter.yml | 4 +++- exporters/githubactions/win_build.ps1 | 15 ++++++++++++- exporters/ravendb/Makefile | 2 +- exporters/ravendb/win_build.ps1 | 15 ++++++++++++- {exporters => scripts}/common_functions.sh | 5 +++++ {exporters => scripts}/package.mk | 8 +++---- .../githubactions => scripts}/pkg/.DS_Store | Bin .../pkg/versioninfo.json.template | 0 .../nri-386-installer/Product.wxs.template | 21 +++++++++--------- .../nri-386-installer/nri-installer.wixproj | 4 ++-- .../nri-amd64-installer/Product.wxs.template | 21 +++++++++--------- .../nri-amd64-installer/nri-installer.wixproj | 4 ++-- {exporters => scripts}/win_msi_build.ps1 | 11 ++++----- .../windows_set_version.ps1 | 8 +++++-- 16 files changed, 89 insertions(+), 50 deletions(-) rename {exporters => scripts}/common_functions.sh (90%) rename {exporters => scripts}/package.mk (90%) rename {exporters/githubactions => scripts}/pkg/.DS_Store (100%) rename {exporters/githubactions => scripts}/pkg/versioninfo.json.template (100%) rename {exporters/githubactions => scripts}/pkg/windows/nri-386-installer/Product.wxs.template (73%) rename {exporters/githubactions => scripts}/pkg/windows/nri-386-installer/nri-installer.wixproj (88%) rename {exporters/githubactions => scripts}/pkg/windows/nri-amd64-installer/Product.wxs.template (72%) rename {exporters/githubactions => scripts}/pkg/windows/nri-amd64-installer/nri-installer.wixproj (88%) rename {exporters => scripts}/win_msi_build.ps1 (87%) rename {exporters => scripts}/windows_set_version.ps1 (82%) diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index f1891c7..842471e 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -15,8 +15,8 @@ ### | | | +---------------------------+ ### +-----------------------+ | | | _ ### | | BUILD AND PUSHES WINDOWS | | -### +----------------- | PACKAGES TO GITHUB | | -### | | | +### +----------------- | PACKAGES TO GITHUB | | Executed once per +### | | | architecture (32-64) ### | Possibly executed twice | | ### +---------------------------+ | ### |___________________________| @@ -49,7 +49,7 @@ jobs: id: check run : | git fetch -at origin --unshallow - source ./exporters/common_functions.sh + source ./scripts/common_functions.sh getExporterPath loadVariables setStepOutput @@ -102,7 +102,7 @@ jobs: run : | export GOPATH=$(go env GOPATH) export EXPORTER_PATH=${{ needs.create_release.outputs.EXPORTER_PATH }} - source ././exporters/common_functions.sh + source ./scripts/common_functions.sh loadVariables packageLinux setStepOutput @@ -169,14 +169,13 @@ jobs: run: | choco install yq export EXPORTER_PATH=${{ needs.create_release.outputs.EXPORTER_PATH }} - source ././exporters/common_functions.sh + source ./scripts/common_functions.sh loadVariables - setStepOutput + setStepOutput - name : CreateMSI shell: pwsh run: | - .\exporters\${{ steps.load_variables.outputs.NAME }}\win_build.ps1 -arch ${{ matrix.goarch }} -exporterHead ${{ steps.load_variables.outputs.EXPORTER_HEAD }} -exporterName ${{ steps.load_variables.outputs.NAME }} -exporterURL ${{ steps.load_variables.outputs.EXPORTER_REPO_URL }} - .\exporters\win_msi_build.ps1 -arch ${{ matrix.goarch }} -exporterName ${{ steps.load_variables.outputs.NAME }} -version ${{ steps.load_variables.outputs.VERSION }} + .\exporters\${{ steps.load_variables.outputs.NAME }}\win_build.ps1 -arch ${{ matrix.goarch }} -exporterHead ${{ steps.load_variables.outputs.EXPORTER_HEAD }} -exporterName ${{ steps.load_variables.outputs.NAME }} -exporterURL ${{ steps.load_variables.outputs.EXPORTER_REPO_URL }} -version ${{ steps.load_variables.outputs.VERSION }} -exporterGUID ${{ steps.load_variables.outputs.EXPORTER_GUID }} -licenseGUID ${{ steps.load_variables.outputs.LICENSE_GUID }} # -pfx_certificate_base64 "$env:PFX_CERTIFICATE_BASE64" -pfx_passphrase "$env:PFX_PASSPHRASE" - name: Upload Release Asset MSI uses: actions/upload-release-asset@v1 @@ -184,7 +183,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ needs.create_release.outputs.UPLOAD_URL }} - asset_path: ${{ github.workspace }}/src/github.com/newrelic/newrelic-prometheus-exporters-packages/exporters/${{ steps.load_variables.outputs.NAME }}/target/packages/msi/${{ steps.load_variables.outputs.NAME }}-${{ matrix.goarch }}.msi - asset_name: ${{ steps.load_variables.outputs.NAME }}-${{ matrix.goarch }}.msi + asset_path: ${{ github.workspace }}/src/github.com/newrelic/newrelic-prometheus-exporters-packages/exporters/${{ steps.load_variables.outputs.NAME }}/target/packages/msi/${{ steps.load_variables.outputs.NAME }}-${{ matrix.goarch }}.${{ steps.load_variables.outputs.VERSION }}.msi + asset_name: ${{ steps.load_variables.outputs.NAME }}-${{ matrix.goarch }}.${{ steps.load_variables.outputs.VERSION }}.msi asset_content_type: msi package diff --git a/exporters/githubactions/Makefile b/exporters/githubactions/Makefile index 867b870..9a88e25 100644 --- a/exporters/githubactions/Makefile +++ b/exporters/githubactions/Makefile @@ -39,6 +39,6 @@ deps-only: clone-repo $(WORK_DIR) go mod download # Import fragments -include ../package.mk +include ../../scripts/package.mk .PHONY: all build clone-repo clean deps-only \ No newline at end of file diff --git a/exporters/githubactions/exporter.yml b/exporters/githubactions/exporter.yml index 2ce608a..28c0289 100644 --- a/exporters/githubactions/exporter.yml +++ b/exporters/githubactions/exporter.yml @@ -1,8 +1,10 @@ name: githubactions -version: 1.2.0 +version: 1.2.1 exporter_repo_url: https://github.com/Spendesk/github-actions-exporter exporter_tag: v1.2 exporter_commit: ifTagIsSetThisIsNotUsed exporter_changelog: "Changelog for the current version, nothing relly changed, just testing pipeline" package_linux: true package_windows: true +exporter_guid: 7B629E90-530F-4FAA-B7FE-1F1B30A95714 +license_guid: 95E897AC-895A-43BE-A5EF-D72AD58E4ED1 \ No newline at end of file diff --git a/exporters/githubactions/win_build.ps1 b/exporters/githubactions/win_build.ps1 index 548399d..a0237c2 100644 --- a/exporters/githubactions/win_build.ps1 +++ b/exporters/githubactions/win_build.ps1 @@ -8,7 +8,10 @@ param ( [string]$arch="amd64", [string]$exporterName="", [string]$exporterURL="", - [string]$exporterHead="" + [string]$exporterHead="", + [string]$exporterGUID="", + [string]$licenseGUID="", + [string]$version="" ) $env:GOPATH = go env GOPATH @@ -19,6 +22,8 @@ $env:GO111MODULE = "auto" $exporterBinaryName = "$exporterName-exporter.exe" $exporterRepo = [string]"$exporterURL" -replace 'https?://(www.)?' +$projectRootPath = pwd + echo "--- Cloning exporter Repo" Push-Location $env:GOPATH\src @@ -55,3 +60,11 @@ if (-not $?) echo "Failed building exporter" exit -1 } +Copy-Item "$env:GOPATH\src\$exporterRepo\LICENSE" -Destination ".\exporters\$exporterName\target\bin\windows_$arch\$exporterName-LICENSE" -Force +{ + echo "Failed building exporter" + exit -1 +} + +$win_msi_build = Join-Path -Path $projectRootPath -ChildPath "\scripts\win_msi_build.ps1" +& $win_msi_build -arch $arch -exporterName $exporterName -version $version -exporterGUID $exporterGUID -licenseGUID $licenseGUID diff --git a/exporters/ravendb/Makefile b/exporters/ravendb/Makefile index 7587315..af8c462 100644 --- a/exporters/ravendb/Makefile +++ b/exporters/ravendb/Makefile @@ -37,6 +37,6 @@ build: clone-repo $(WORK_DIR) go build -v -o $(BINS_DIR)/$(BINARY_NAME) # Import fragments -include ../package.mk +include ../../scripts/package.mk .PHONY: clone-repo build diff --git a/exporters/ravendb/win_build.ps1 b/exporters/ravendb/win_build.ps1 index f5a84d1..e323e8c 100644 --- a/exporters/ravendb/win_build.ps1 +++ b/exporters/ravendb/win_build.ps1 @@ -8,7 +8,10 @@ param ( [string]$arch="amd64", [string]$exporterName="", [string]$exporterURL="", - [string]$exporterHead="" + [string]$exporterHead="", + [string]$exporterGUID="", + [string]$licenseGUID="", + [string]$version="" ) $env:GOPATH = go env GOPATH @@ -19,6 +22,7 @@ $env:GO111MODULE = "auto" $exporterBinaryName = "$exporterName-exporter.exe" $exporterRepo = [string]"$exporterURL" -replace 'https?://(www.)?' +$projectRootPath = pwd echo "--- Cloning exporter Repo" Push-Location $env:GOPATH\src @@ -55,3 +59,12 @@ if (-not $?) echo "Failed building exporter" exit -1 } + +Copy-Item "$env:GOPATH\src\$exporterRepo\LICENSE" -Destination ".\exporters\$exporterName\target\bin\windows_$arch\$exporterName-LICENSE" -Force +{ + echo "Failed building exporter" + exit -1 +} + +$win_msi_build = Join-Path -Path $projectRootPath -ChildPath "\scripts\win_msi_build.ps1" +& $win_msi_build -arch $arch -exporterName $exporterName -version $version -exporterGUID $exporterGUID -licenseGUID $licenseGUID diff --git a/exporters/common_functions.sh b/scripts/common_functions.sh similarity index 90% rename from exporters/common_functions.sh rename to scripts/common_functions.sh index b3ba712..fd74e8f 100755 --- a/exporters/common_functions.sh +++ b/scripts/common_functions.sh @@ -8,6 +8,8 @@ loadVariables(){ export EXPORTER_TAG=$(yq read $EXPORTER_PATH exporter_tag) export EXPORTER_COMMIT=$(yq read $EXPORTER_PATH exporter_commit) export EXPORTER_CHANGELOG=$(yq read $EXPORTER_PATH exporter_changelog) + export EXPORTER_GUID=$(yq read $EXPORTER_PATH exporter_guid) + export LICENSE_GUID=$(yq read $EXPORTER_PATH license_guid) export PACKAGE_LINUX=$(yq read $EXPORTER_PATH package_linux) export PACKAGE_WINDOWS=$(yq read $EXPORTER_PATH package_windows) @@ -29,6 +31,9 @@ setStepOutput(){ echo "::set-output name=EXPORTER_PATH::${EXPORTER_PATH}" echo "::set-output name=PACKAGE_LINUX::${PACKAGE_LINUX}" echo "::set-output name=PACKAGE_WINDOWS::${PACKAGE_WINDOWS}" + echo "::set-output name=EXPORTER_GUID::${EXPORTER_GUID}" + echo "::set-output name=LICENSE_GUID::${LICENSE_GUID}" + } packageLinux(){ diff --git a/exporters/package.mk b/scripts/package.mk similarity index 90% rename from exporters/package.mk rename to scripts/package.mk index 4a9a6f9..ddab108 100644 --- a/exporters/package.mk +++ b/scripts/package.mk @@ -29,12 +29,12 @@ prep-pkg-env: fi @echo "=== Main === [ prep-pkg-env ]: preparing a clean packaging environment..." @rm -rf $(SOURCE_DIR) - @mkdir -p $(SOURCE_DIR)/usr/local/prometheus-exporters/$(NAME) $(SOURCE_DIR)/etc/newrelic-infra/integrations.d + @mkdir -p $(SOURCE_DIR)/usr/local/prometheus-exporters/bin $(SOURCE_DIR)/etc/newrelic-infra/integrations.d @echo "=== Main === [ prep-pkg-env ]: adding built binaries and configuration and definition files..." - @cp $(BINS_DIR)/* $(SOURCE_DIR)/usr/local/prometheus-exporters/$(NAME) - @chmod 755 $(SOURCE_DIR)/usr/local/prometheus-exporters/$(NAME)/* + @cp $(BINS_DIR)/* $(SOURCE_DIR)/usr/local/prometheus-exporters/bin + @chmod 755 $(SOURCE_DIR)/usr/local/prometheus-exporters/bin/* @echo "=== Main === [ prep-pkg-env ]: adding license..." - @cp LICENSE $(SOURCE_DIR)/usr/local/prometheus-exporters/$(NAME) + @cp LICENSE $(SOURCE_DIR)/usr/local/prometheus-exporters/bin/$(NAME)-LICENSE deb: prep-pkg-env @echo "=== Main === [ deb ]: building DEB package..." diff --git a/exporters/githubactions/pkg/.DS_Store b/scripts/pkg/.DS_Store similarity index 100% rename from exporters/githubactions/pkg/.DS_Store rename to scripts/pkg/.DS_Store diff --git a/exporters/githubactions/pkg/versioninfo.json.template b/scripts/pkg/versioninfo.json.template similarity index 100% rename from exporters/githubactions/pkg/versioninfo.json.template rename to scripts/pkg/versioninfo.json.template diff --git a/exporters/githubactions/pkg/windows/nri-386-installer/Product.wxs.template b/scripts/pkg/windows/nri-386-installer/Product.wxs.template similarity index 73% rename from exporters/githubactions/pkg/windows/nri-386-installer/Product.wxs.template rename to scripts/pkg/windows/nri-386-installer/Product.wxs.template index 6557e7e..7559560 100644 --- a/exporters/githubactions/pkg/windows/nri-386-installer/Product.wxs.template +++ b/scripts/pkg/windows/nri-386-installer/Product.wxs.template @@ -24,19 +24,15 @@ - + - - - - - - + + @@ -51,12 +47,17 @@ - - - + + + + + diff --git a/exporters/githubactions/pkg/windows/nri-386-installer/nri-installer.wixproj b/scripts/pkg/windows/nri-386-installer/nri-installer.wixproj similarity index 88% rename from exporters/githubactions/pkg/windows/nri-386-installer/nri-installer.wixproj rename to scripts/pkg/windows/nri-386-installer/nri-installer.wixproj index d8dc3cb..d1bfb0f 100644 --- a/exporters/githubactions/pkg/windows/nri-386-installer/nri-installer.wixproj +++ b/scripts/pkg/windows/nri-386-installer/nri-installer.wixproj @@ -17,7 +17,7 @@ bin\$(Configuration)\ obj\$(Configuration)\ - Debug;ProjectRootPath=..\..\..\;BinariesPath=..\..\..\target\bin\windows_386\ + Debug;ProjectRootPath=..\..\..\..\;BinariesPath=..\..\..\..\exporters\$(exporterName)\target\bin\windows_386\ True False -arch x86 @@ -25,7 +25,7 @@ bin\$(Configuration)\ obj\$(Configuration)\ - Debug;ProjectRootPath=..\..\..\;BinariesPath=..\..\..\target\bin\windows_386\ + Debug;ProjectRootPath=..\..\..\..\;BinariesPath=..\..\..\..\exporters\$(exporterName)\target\bin\windows_386\ -arch x86 diff --git a/exporters/githubactions/pkg/windows/nri-amd64-installer/Product.wxs.template b/scripts/pkg/windows/nri-amd64-installer/Product.wxs.template similarity index 72% rename from exporters/githubactions/pkg/windows/nri-amd64-installer/Product.wxs.template rename to scripts/pkg/windows/nri-amd64-installer/Product.wxs.template index 30f764f..8b837c0 100755 --- a/exporters/githubactions/pkg/windows/nri-amd64-installer/Product.wxs.template +++ b/scripts/pkg/windows/nri-amd64-installer/Product.wxs.template @@ -24,19 +24,15 @@ - + - - - - - - + + @@ -51,12 +47,17 @@ - - - + + + + + diff --git a/exporters/githubactions/pkg/windows/nri-amd64-installer/nri-installer.wixproj b/scripts/pkg/windows/nri-amd64-installer/nri-installer.wixproj similarity index 88% rename from exporters/githubactions/pkg/windows/nri-amd64-installer/nri-installer.wixproj rename to scripts/pkg/windows/nri-amd64-installer/nri-installer.wixproj index 76fac0b..1228944 100755 --- a/exporters/githubactions/pkg/windows/nri-amd64-installer/nri-installer.wixproj +++ b/scripts/pkg/windows/nri-amd64-installer/nri-installer.wixproj @@ -17,7 +17,7 @@ bin\$(Configuration)\ obj\$(Configuration)\ - Debug;ProjectRootPath=..\..\..\;BinariesPath=..\..\..\target\bin\windows_amd64\ + Debug;ProjectRootPath=..\..\..\..\;BinariesPath=..\..\..\..\exporters\$(exporterName)\target\bin\windows_amd64\ True False -arch x64 @@ -25,7 +25,7 @@ bin\$(Configuration)\ obj\$(Configuration)\ - Debug;ProjectRootPath=..\..\..\;BinariesPath=..\..\..\target\bin\windows_amd64\ + Debug;ProjectRootPath=..\..\..\..\;BinariesPath=..\..\..\..\exporters\$(exporterName)\target\bin\windows_amd64\ -arch x64 diff --git a/exporters/win_msi_build.ps1 b/scripts/win_msi_build.ps1 similarity index 87% rename from exporters/win_msi_build.ps1 rename to scripts/win_msi_build.ps1 index 523c457..581eab6 100644 --- a/exporters/win_msi_build.ps1 +++ b/scripts/win_msi_build.ps1 @@ -9,6 +9,8 @@ param ( [string]$pfx_certificate_base64="none", [string]$pfx_passphrase="none", [string]$exporterName="", + [string]$exporterGUID="", + [string]$licenseGUID="", [string]$version="" ) @@ -37,9 +39,8 @@ if ($wrong.Length -ne 0) { echo "===> Configuring version $version for artifacts in $exporterName" $projectRootPath = pwd -$windows_set_version = Join-Path -Path $projectRootPath -ChildPath "\exporters\windows_set_version.ps1" -echo $windows_set_version -& $windows_set_version -major $v[0] -minor $v[1] -patch $v[2] -exporterName $exporterName +$windows_set_version = Join-Path -Path $projectRootPath -ChildPath "\scripts\windows_set_version.ps1" +& $windows_set_version -major $v[0] -minor $v[1] -patch $v[2] -exporterName $exporterName -exporterGUID $exporterGUID -licenseGUID $licenseGUID echo "===> Checking MSBuild.exe..." $msBuild = (Get-ItemProperty hklm:\software\Microsoft\MSBuild\ToolsVersions\4.0).MSBuildToolsPath @@ -53,7 +54,7 @@ $env:GOOS="windows" $env:GOARCH=$arch echo "===> Building Installer" -Push-Location -Path "exporters\$exporterName\pkg\windows\nri-$arch-installer" +Push-Location -Path "scripts\pkg\windows\nri-$arch-installer" $env:exporterName = $exporterName . $msBuild/MSBuild.exe nri-installer.wixproj @@ -67,6 +68,6 @@ if (-not $?) echo "===> Making versioned installed copy moving it to $projectRootPath\exporters\$exporterName\target\packages\msi\$exporterName-$arch.msi" New-item -type directory -path "$projectRootPath\exporters\$exporterName\target\packages\msi" -Force -cp ".\bin\Release\$exporterName-$arch.msi" "$projectRootPath\exporters\$exporterName\target\packages\msi\$exporterName-$arch.msi" +cp ".\bin\Release\$exporterName-$arch.msi" "$projectRootPath\exporters\$exporterName\target\packages\msi\$exporterName-$arch.$version.msi" Pop-Location \ No newline at end of file diff --git a/exporters/windows_set_version.ps1 b/scripts/windows_set_version.ps1 similarity index 82% rename from exporters/windows_set_version.ps1 rename to scripts/windows_set_version.ps1 index a3bb9d1..7420a8a 100644 --- a/exporters/windows_set_version.ps1 +++ b/scripts/windows_set_version.ps1 @@ -3,6 +3,8 @@ param ( [int]$minor = $(throw "-minor is required"), [int]$patch = $(throw "-patch is required"), [string]$exporterName="", + [string]$exporterGUID="", + [string]$licenseGUID="", [int]$build = 0 ) @@ -30,8 +32,8 @@ $versionInfo = $versionInfo -replace "{IntegrationExe}", $executable $versionInfo = $versionInfo -replace "{Year}", (Get-Date).year Set-Content -Path $versionInfoPath -Value $versionInfo -$wix386Path = Join-Path -Path $projectRootPath -ChildPath "exporters\$exporterName\pkg\windows\nri-386-installer\Product.wxs" -$wixAmd64Path = Join-Path -Path $projectRootPath -ChildPath "exporters\$exporterName\pkg\windows\nri-amd64-installer\Product.wxs" +$wix386Path = Join-Path -Path $projectRootPath -ChildPath "scripts\pkg\windows\nri-386-installer\Product.wxs" +$wixAmd64Path = Join-Path -Path $projectRootPath -ChildPath "scripts\pkg\windows\nri-amd64-installer\Product.wxs" Function ProcessProductFile($productPath) { if ((Test-Path "$productPath.template" -PathType Leaf) -eq $False) { @@ -44,6 +46,8 @@ Function ProcessProductFile($productPath) { $product = $product -replace "{Year}", (Get-Date).year $product = $product -replace "{IntegrationExe}", $executable $product = $product -replace "{IntegrationName}", $exporterName + $product = $product -replace "{exporterBinGUID}", $exporterGUID + $product = $product -replace "{licenseGUID}", $licenseGUID Set-Content -Value $product -Path $productPath }