From 175e5ece049654d1c0f1e512e82c102169acc489 Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Fri, 16 Dec 2022 20:47:46 +0100 Subject: [PATCH] fix: setup go correctly in bootstrap --- .github/workflows/build_code.yml | 7 ++++ .../composite/bootstrap-go/action.yml | 34 ++++++++++++++----- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build_code.yml b/.github/workflows/build_code.yml index 9e314908..b2db33da 100644 --- a/.github/workflows/build_code.yml +++ b/.github/workflows/build_code.yml @@ -27,3 +27,10 @@ jobs: version: latest args: build --rm-dist --snapshot --skip-post-hooks --skip-before workdir: src + - name: Archive production artifacts + uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb + with: + name: builds + retention-days: 1 + path: | + src/dist diff --git a/.github/workflows/composite/bootstrap-go/action.yml b/.github/workflows/composite/bootstrap-go/action.yml index 7907c224..f87d2523 100644 --- a/.github/workflows/composite/bootstrap-go/action.yml +++ b/.github/workflows/composite/bootstrap-go/action.yml @@ -7,14 +7,30 @@ branding: runs: using: "composite" steps: - - name: Install Go - uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f - with: - go-version: 1.19.4 - - name: Override Go ♻️ + - name: Install Go 🚀 + env: + VERSION: "1.19.4" shell: pwsh run: | - $goBin = $(Get-Command go).Source - Invoke-WebRequest 'https://github.com/jandedobbeleer/go/releases/download/1.19.4/go' -OutFile "$goBin" - chmod a+x $goBin 2>&1 - go version + # Delete conflicting go versions first + Remove-Item -Path "$env:RUNNER_TOOL_CACHE/go" -Recurse -Force -ErrorAction Ignore + + # Download source + $tempZip = "$env:RUNNER_TEMP/source.zip" + Invoke-WebRequest "https://github.com/jandedobbeleer/go/releases/download/$env:VERSION/go.zip" -OutFile $tempZip + + # Extract to correct location + Expand-Archive $tempZip -DestinationPath $env:RUNNER_TEMP -Force + $sourceFolder = Join-Path $env:RUNNER_TOOL_CACHE "go" + New-Item -ItemType Directory -Path $sourceFolder + Move-Item "$env:RUNNER_TEMP/go/*" $sourceFolder -Force + + # Set correct permissions on go executables + chmod a+x "$sourceFolder/bin/go" 2>&1 + Get-ChildItem "$sourceFolder/pkg/tool/linux_amd64" | ForEach-Object { + chmod a+x $_ 2>&1 + } + + # Add to path + "$sourceFolder/bin" >> $env:GITHUB_PATH + "GOROOT=$sourceFolder" >> $env:GITHUB_ENV