Skip to content

Commit

Permalink
chore(ci/cd): rearranged folder structure
Browse files Browse the repository at this point in the history
  • Loading branch information
paologallinaharbur committed Oct 2, 2020
1 parent 99d3d9b commit a320d29
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 50 deletions.
19 changes: 9 additions & 10 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
### | | | +---------------------------+
### +-----------------------+ | | | _
### | | BUILD AND PUSHES WINDOWS | |
### +----------------- | PACKAGES TO GITHUB | |
### | | |
### +----------------- | PACKAGES TO GITHUB | | Executed once per
### | | | architecture (32-64)
### | Possibly executed twice | |
### +---------------------------+ |
### |___________________________|
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -169,22 +169,21 @@ 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
env:
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

2 changes: 1 addition & 1 deletion exporters/githubactions/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion exporters/githubactions/exporter.yml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 14 additions & 1 deletion exporters/githubactions/win_build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion exporters/ravendb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 14 additions & 1 deletion exporters/ravendb/win_build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
5 changes: 5 additions & 0 deletions exporters/common_functions.sh → scripts/common_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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(){
Expand Down
8 changes: 4 additions & 4 deletions exporters/package.mk → scripts/package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,15 @@

<Feature Id="ProductFeature" Title="New Relic Infrastructure Integration, nri-{IntegrationName}" Level="1">
<ComponentRef Id="CMP_V1_CUSTOM_PLUGINS_BIN"/>
<ComponentGroupRef Id="CustomPluginsBinComponent"/>
<ComponentGroupRef Id="PrometheusPluginsBinComponent"/>
</Feature>
</Product>

<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="CompanyFolder" Name="New Relic">
<Directory Id="AgentBinaryFolder" Name="newrelic-infra">
<Directory Id="CustomPluginsFolder" Name="newrelic-integrations">
<Directory Id="CustomPluginsBinFolder" Name="bin"/>
</Directory>
</Directory>
<Directory Id="CompanyFolder" Name="Prometheus-exporters">
<Directory Id="CustomPluginsBinFolder" Name="bin"/>
</Directory>
</Directory>
</Directory>
Expand All @@ -51,12 +47,17 @@
</Fragment>

<Fragment>
<ComponentGroup Id="CustomPluginsBinComponent" Directory="CustomPluginsBinFolder">
<Component Id="CMP_NRI_VSPHERE_EXE" Guid="69c26416-b13a-466c-a656-5d2ffeca561c" Win64="no">
<File Id="FILE_NRI_VSPHERE_EXE"
<ComponentGroup Id="PrometheusPluginsBinComponent" Directory="CustomPluginsBinFolder">
<Component Id="CMP_NRI_EXPORTER_EXE" Guid="{exporterBinGUID}" Win64="no">
<File Id="FILE_NRI_EXPORTER_EXE"
Source="$(var.BinariesPath){IntegrationExe}"
KeyPath="yes"/>
</Component>
<Component Id="CMP_NRI_LICENSE" Guid="{licenseGUID}" Win64="no">
<File Id="FILE_NRI_LICENSE"
Source="$(var.BinariesPath){IntegrationName}-LICENSE"
KeyPath="yes"/>
</Component>
</ComponentGroup>
</Fragment>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug;ProjectRootPath=..\..\..\;BinariesPath=..\..\..\target\bin\windows_386\</DefineConstants>
<DefineConstants>Debug;ProjectRootPath=..\..\..\..\;BinariesPath=..\..\..\..\exporters\$(exporterName)\target\bin\windows_386\</DefineConstants>
<SuppressAllWarnings>True</SuppressAllWarnings>
<Pedantic>False</Pedantic>
<CompilerAdditionalOptions>-arch x86</CompilerAdditionalOptions>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug;ProjectRootPath=..\..\..\;BinariesPath=..\..\..\target\bin\windows_386\</DefineConstants>
<DefineConstants>Debug;ProjectRootPath=..\..\..\..\;BinariesPath=..\..\..\..\exporters\$(exporterName)\target\bin\windows_386\</DefineConstants>
<CompilerAdditionalOptions>-arch x86</CompilerAdditionalOptions>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,15 @@

<Feature Id="ProductFeature" Title="New Relic Infrastructure Integration, nri-{IntegrationName}" Level="1">
<ComponentRef Id="CMP_V1_CUSTOM_PLUGINS_BIN"/>
<ComponentGroupRef Id="CustomPluginsBinComponent"/>
<ComponentGroupRef Id="PrometheusPluginsBinComponent"/>
</Feature>
</Product>

<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="CompanyFolder" Name="New Relic">
<Directory Id="AgentBinaryFolder" Name="newrelic-infra">
<Directory Id="CustomPluginsFolder" Name="newrelic-integrations">
<Directory Id="CustomPluginsBinFolder" Name="bin"/>
</Directory>
</Directory>
<Directory Id="CompanyFolder" Name="Prometheus-exporters">
<Directory Id="CustomPluginsBinFolder" Name="bin"/>
</Directory>
</Directory>
</Directory>
Expand All @@ -51,12 +47,17 @@
</Fragment>

<Fragment>
<ComponentGroup Id="CustomPluginsBinComponent" Directory="CustomPluginsBinFolder">
<Component Id="CMP_NRI_VSPHERE_EXE" Guid="c415381c-887d-4a1d-8846-5a30dfe1f14c" Win64="yes">
<File Id="FILE_NRI_VSPHERE_EXE"
<ComponentGroup Id="PrometheusPluginsBinComponent" Directory="CustomPluginsBinFolder">
<Component Id="CMP_NRI_EXPORTER_EXE" Guid="{exporterBinGUID}" Win64="yes">
<File Id="FILE_NRI_EXPORTER_EXE"
Source="$(var.BinariesPath){IntegrationExe}"
KeyPath="yes"/>
</Component>
<Component Id="CMP_NRI_LICENSE" Guid="{licenseGUID}" Win64="yes">
<File Id="FILE_NRI_LICENSE"
Source="$(var.BinariesPath){IntegrationName}-LICENSE"
KeyPath="yes"/>
</Component>
</ComponentGroup>
</Fragment>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug;ProjectRootPath=..\..\..\;BinariesPath=..\..\..\target\bin\windows_amd64\</DefineConstants>
<DefineConstants>Debug;ProjectRootPath=..\..\..\..\;BinariesPath=..\..\..\..\exporters\$(exporterName)\target\bin\windows_amd64\</DefineConstants>
<SuppressAllWarnings>True</SuppressAllWarnings>
<Pedantic>False</Pedantic>
<CompilerAdditionalOptions>-arch x64</CompilerAdditionalOptions>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug;ProjectRootPath=..\..\..\;BinariesPath=..\..\..\target\bin\windows_amd64\</DefineConstants>
<DefineConstants>Debug;ProjectRootPath=..\..\..\..\;BinariesPath=..\..\..\..\exporters\$(exporterName)\target\bin\windows_amd64\</DefineConstants>
<CompilerAdditionalOptions>-arch x64</CompilerAdditionalOptions>
</PropertyGroup>
<ItemGroup>
Expand Down
11 changes: 6 additions & 5 deletions exporters/win_msi_build.ps1 → scripts/win_msi_build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ param (
[string]$pfx_certificate_base64="none",
[string]$pfx_passphrase="none",
[string]$exporterName="",
[string]$exporterGUID="",
[string]$licenseGUID="",
[string]$version=""
)

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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) {
Expand All @@ -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
}

Expand Down

0 comments on commit a320d29

Please sign in to comment.