From 4c025e672f8bfe0400753b730044b9e4f30b5d83 Mon Sep 17 00:00:00 2001 From: smithclay Date: Tue, 27 Feb 2024 09:26:01 -0800 Subject: [PATCH] update MSI build action --- .github/workflows/release-msi.yml | 69 +++++++++++++++++++++++-------- .github/workflows/release.yml | 10 +++-- .goreleaser.yaml | 16 +++---- collector/windows/wix.json | 3 ++ 4 files changed, 70 insertions(+), 28 deletions(-) diff --git a/.github/workflows/release-msi.yml b/.github/workflows/release-msi.yml index a7bdaad..6926cb7 100644 --- a/.github/workflows/release-msi.yml +++ b/.github/workflows/release-msi.yml @@ -1,37 +1,49 @@ # Based on https://github.com/Bedrock-OSS/regolith/blob/b340a6f4bd208b265c3a0f6bbb59206ab8486545/.github/workflows/release.yml # https://dev.to/abdfnx/how-to-create-a-msi-file-for-go-program-je -name: Release MSI +name: Release Windows MSI on: - workflow_dispatch: + push: + tags: ["v*"] jobs: release-msi: + permissions: + id-token: write + packages: write + contents: write + runs-on: windows-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Setup Go uses: actions/setup-go@v5 with: go-version: '~1.21.5' check-latest: true - - name: Download latest *.zip release - uses: robinraju/release-downloader@v1.9 - with: - latest: true - extract: true - fileName: otelcol-servicenow_*_windows_amd64.zip - # - name: Validate collector release - # run: | - # ls -la - # echo "Validating collector" - # ./collector/otelcol-servicenow.exe validate --config ./config/otelcol-windows-hostmetrics.yaml + + - name: Install Tools + working-directory: collector + run: make install-tools + + - name: Build collector + working-directory: collector + run: make build-windows + + - run: mv .\otelcol-servicenow\otelcol-servicenow .\otelcol-servicenow.exe + working-directory: collector + + - name: Validate collector release + working-directory: collector + run: .\otelcol-servicenow.exe validate --config config\otelcol-windows-hostmetrics.yaml + - run: ls -la shell: bash - + - name: Cache Wix Toolset id: cache-wix uses: actions/cache@v3 @@ -49,14 +61,37 @@ jobs: go install github.com/stirante/go-msi@latest ls -la mkdir collector/windows/go-msi-tmp - cp otelcol-servicenow.exe collector/windows/otelcol-servicenow.exe + cp collector/config/otelcol-windows-hostmetrics.yaml collector/windows/config.yaml + cp collector/otelcol-servicenow.exe collector/windows/otelcol-servicenow.exe cp LICENSE collector/windows/LICENSE.txt shell: bash - name: Build MSI + if: startsWith(github.ref, 'refs/tags/') run: | ls -la cd collector/windows ls -la - go-msi make --msi sn-collector-v0.0.1.msi --version v0.0.1 --src templates --out .\go-msi-tmp - shell: bash \ No newline at end of file + go-msi make --msi sn-collector.msi --version ${{ github.ref_name }} --src templates --out .\go-msi-tmp + shell: bash + + - name: Diagnostics + run: | + pwd + ls -la + shell: bash + + - name: Upload MSI Artifact + uses: actions/upload-artifact@v4 + with: + name: sn-collector.msi + path: collector/windows/sn-collector.msi + # Short lived because this is meant as an action for developers + retention-days: 1 + + - name: Add MSI to Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + collector/windows/sn-collector.msi \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b9c3171..af7453e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,11 +30,13 @@ jobs: go-version: '~1.21.5' check-latest: true + - name: Install tools + working-directory: collector + run: make install-tools + - name: Generate distribution sources - run: | - go install go.opentelemetry.io/collector/cmd/builder@v0.95.0 - cd collector - builder --config otelcol-builder.yaml --skip-compilation + working-directory: collector + run: builder --config otelcol-builder.yaml --skip-compilation - name: Login to GitHub Package Registry uses: docker/login-action@v3 diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 2783d08..472371b 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -6,7 +6,8 @@ builds: goos: - darwin - linux - - windows + # Disabled for Windows as we handle that in in release-msi.yml + # - windows goarch: - amd64 - arm @@ -20,12 +21,13 @@ builds: goarch: arm - goos: darwin goarch: s390x - - goos: windows - goarch: arm - - goos: windows - goarch: arm64 - - goos: windows - goarch: s390x + # Disabled for Windows as we handle that in release-msi.yml + # - goos: windows + # goarch: arm + # - goos: windows + # goarch: arm64 + # - goos: windows + # goarch: s390x dir: ./collector/otelcol-servicenow binary: otelcol-servicenow ldflags: diff --git a/collector/windows/wix.json b/collector/windows/wix.json index e715b6f..7022e0d 100644 --- a/collector/windows/wix.json +++ b/collector/windows/wix.json @@ -9,6 +9,9 @@ { "path": "otelcol-servicenow.exe" }, + { + "path": "config.yaml" + }, { "path": "LICENSE.txt" }