Skip to content

Commit 73bedca

Browse files
feat(CI/CD): support labels in tag name (#36)
1 parent 0a6e015 commit 73bedca

File tree

5 files changed

+11
-34
lines changed

5 files changed

+11
-34
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,12 @@ jobs:
2828
run: |
2929
$ErrorView = 'NormalView'
3030
[Environment]::SetEnvironmentVariable("path", "$env:path;$env:GOPATH\bin", "Machine")
31-
$semanticVersion = "${{ github.event.release.tag_name }}" -replace '[v]',''
32-
.\win_build.ps1 -arch ${{ matrix.goarch }} -version $semanticVersion
31+
.\win_build.ps1 -arch ${{ matrix.goarch }} -version ${{ github.event.release.tag_name }}
3332
- name: Create Tar and Zip
3433
shell: bash
3534
run: |
3635
cp winservices-config.yml.sample ./target/bin/windows_${{ matrix.goarch }}
37-
tar -czvf ${{ github.event.repository.name }}-${{ matrix.goarch }}.tar.gz ./target/bin/windows_${{ matrix.goarch }}/*
38-
7z a ${{ github.event.repository.name }}-${{ matrix.goarch }}.zip ./target/bin/windows_${{ matrix.goarch }}/*
36+
7z a ${{ github.event.repository.name }}-${{ github.event.release.tag_name }}-${{ matrix.goarch }}.zip ./target/bin/windows_${{ matrix.goarch }}/*
3937
- name: Upload Integration binary
4038
uses: actions/upload-release-asset@v1.0.1
4139
env:
@@ -54,21 +52,12 @@ jobs:
5452
asset_path: .\target\bin\windows_${{ matrix.goarch }}\windows_exporter.exe
5553
asset_name: windows-exporter-${{ matrix.goarch }}.exe
5654
asset_content_type: Exporter binary
57-
- name: Upload Tarball
58-
uses: actions/upload-release-asset@v1.0.1
59-
env:
60-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61-
with:
62-
upload_url: ${{ github.event.release.upload_url }}
63-
asset_path: ./${{ github.event.repository.name }}-${{ matrix.goarch }}.tar.gz
64-
asset_name: ${{ github.event.repository.name }}-${{ matrix.goarch }}.tar.gz
65-
asset_content_type: Integration Tarball
6655
- name: Upload Zip
6756
uses: actions/upload-release-asset@v1.0.1
6857
env:
6958
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7059
with:
7160
upload_url: ${{ github.event.release.upload_url }}
72-
asset_path: ./${{ github.event.repository.name }}-${{ matrix.goarch }}.zip
73-
asset_name: ${{ github.event.repository.name }}-${{ matrix.goarch }}.zip
74-
asset_content_type: Integration Tarball
61+
asset_path: ./${{ github.event.repository.name }}-${{ github.event.release.tag_name }}-${{ matrix.goarch }}.zip
62+
asset_name: ${{ github.event.repository.name }}-${{ github.event.release.tag_name }}-${{ matrix.goarch }}.zip
63+
asset_content_type: Integration Zip

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ coverage.xml
22
bin
33
.idea
44
.vscode
5-
*.exe
5+
*.exe
6+
*.msi

src/winservices.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616

1717
"github.com/newrelic/infra-integrations-sdk/integration"
1818
"github.com/newrelic/infra-integrations-sdk/log"
19+
1920
//This import is useful merely to keep track of dependency and generate license automatically
2021
_ "github.com/prometheus-community/windows_exporter/collector"
2122
)
@@ -33,7 +34,7 @@ const (
3334

3435
var (
3536
args argumentList
36-
integrationVersion = "0.0.0" // set by -ldflags on build
37+
integrationVersion = "v0.0.0" // set by -ldflags on build
3738
commitHash = "default" // Commit hash used to build the integration set by -ldflags on build
3839
)
3940

test/json-schema-files/winservices-schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"type": "string"
1515
},
1616
"version": {
17-
"pattern": "^[0-9]+.[0-9]+.[0-9]+$",
17+
"pattern": "^v[0-9]+.[0-9]+.[0-9]+(-beta)?$",
1818
"type": "string"
1919
}
2020
},

win_build.ps1

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ param (
66
# Target architecture: amd64 (default) or 386
77
[ValidateSet("amd64", "386")]
88
[string]$arch="amd64",
9-
[string]$version="0.0.0",
9+
[string]$version="v0.0.0",
1010
# Skip tests
1111
[switch]$skipTests=$false,
1212
[switch]$skipExporterCompile=$false
@@ -32,20 +32,6 @@ $env:GOOS = "windows"
3232
$env:GOARCH = $arch
3333
$env:GO111MODULE = "auto"
3434

35-
# verifying version number format
36-
$v = $version.Split(".")
37-
38-
if ($v.Length -ne 3) {
39-
echo "-version must follow a numeric major.minor.patch semantic versioning schema (received: $version)"
40-
exit -1
41-
}
42-
43-
$wrong = $v | ? { (-Not [System.Int32]::TryParse($_, [ref]0)) -or ( $_.Length -eq 0) -or ([int]$_ -lt 0)} | % { 1 }
44-
if ($wrong.Length -ne 0) {
45-
echo "-version major, minor and patch must be valid positive integers (received: $version)"
46-
exit -1
47-
}
48-
4935
echo "--- Checking dependencies"
5036
# We are running a job in a windows that calls a .ps1 experiencing this issue.
5137
# Basically when using git (and as well when running go get or go mod...) the powershell script fails misinterpreting the output

0 commit comments

Comments
 (0)