Skip to content

Commit 4bd86e9

Browse files
committed
build: install Go during build
1 parent 430d67a commit 4bd86e9

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

.github/workflows/install-go.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: install-go-test
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
install-go:
12+
runs-on: windows-latest
13+
steps:
14+
- uses: actions/checkout@v6
15+
- name: Install Go
16+
run: install-go.sh
17+
shell: bash

build.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,28 @@ echo Packing...
1515
rm -rf nupkg
1616
dotnet pack -nologo -v quiet Google.Cloud.EntityFrameworkCore.Spanner -o $PWD/nupkg
1717

18+
# Download and install Go
19+
GO_VERSION="1.26.0"
20+
MSI_FILE="go${GO_VERSION}.windows-amd64.msi"
21+
DOWNLOAD_URL="https://go.dev/dl/${MSI_FILE}"
22+
23+
echo "Downloading Go ${GO_VERSION}..."
24+
curl -L -o "$MSI_FILE" "$DOWNLOAD_URL"
25+
26+
echo "Installing Go silently"
27+
# /i = install, /quiet = no UI, /norestart = don't reboot the machine
28+
msiexec.exe //i "$MSI_FILE" //quiet //norestart
29+
30+
echo "Cleaning up installer file..."
31+
rm "$MSI_FILE"
32+
echo "Installation finished."
33+
34+
echo "Updating PATH for the current script session..."
35+
# Use standard Bash export, converting the C:\ path to a Git Bash /c/ path
36+
export PATH=$PATH:/c/Program\ Files/Go/bin
37+
# Verify that Go is installed and works
38+
go version
39+
1840
echo Building spanner-ado-net...
1941
pushd spanner-ado-net/spanner-ado-net
2042

install-go.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Download and install Go
6+
GO_VERSION="1.26.0"
7+
MSI_FILE="go${GO_VERSION}.windows-amd64.msi"
8+
DOWNLOAD_URL="https://go.dev/dl/${MSI_FILE}"
9+
10+
echo "Downloading Go ${GO_VERSION}..."
11+
curl -L -o "$MSI_FILE" "$DOWNLOAD_URL"
12+
13+
echo "Installing Go silently"
14+
# /i = install, /quiet = no UI, /norestart = don't reboot the machine
15+
msiexec.exe //i "$MSI_FILE" //quiet //norestart
16+
17+
echo "Cleaning up installer file..."
18+
rm "$MSI_FILE"
19+
echo "Installation finished."
20+
21+
echo "Updating PATH for the current script session..."
22+
# Use standard Bash export, converting the C:\ path to a Git Bash /c/ path
23+
export PATH=$PATH:/c/Program\ Files/Go/bin
24+
# Verify that Go is installed and works
25+
go version

0 commit comments

Comments
 (0)