diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 3cf980383d7ad..29bfb0341c1f5 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -32,11 +32,18 @@ builds: ["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"] env: [CGO_ENABLED=0] goos: [darwin, linux, windows] - goarch: [amd64] + goarch: [amd64, arm, arm64] + goarm: ["7"] + # Only build arm 7 for Linux + ignore: + - goos: windows + goarm: '7' + - goos: darwin + goarm: '7' hooks: # The "trimprefix" appends ".exe" on Windows. post: | - cp {{.Path}} site/out/bin/coder-{{ .Os }}-{{ .Arch }}{{ trimprefix .Name "coder" }} + cp {{.Path}} site/out/bin/coder-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ trimprefix .Name "coder" }} - id: coder-linux dir: cmd/coder @@ -45,7 +52,8 @@ builds: ["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"] env: [CGO_ENABLED=0] goos: [linux] - goarch: [amd64, arm64] + goarch: [amd64, arm, arm64] + goarm: ["7"] - id: coder-windows dir: cmd/coder diff --git a/provisionersdk/agent.go b/provisionersdk/agent.go index baaff0745f431..00f6861ef9136 100644 --- a/provisionersdk/agent.go +++ b/provisionersdk/agent.go @@ -1,42 +1,56 @@ package provisionersdk -import "fmt" +import ( + "fmt" + "strings" +) var ( - // A mapping of operating-system ($GOOS) to architecture ($GOARCH) - // to agent install and run script. ${DOWNLOAD_URL} is replaced - // with strings.ReplaceAll() when being consumed. - agentScripts = map[string]map[string]string{ - // On Windows, VS Code Remote requires a parent process of the - // executing shell to be named "sshd", otherwise it fails. See: - // https://github.com/microsoft/vscode-remote-release/issues/5699 - "windows": { - "amd64": `$ProgressPreference = "SilentlyContinue" -Invoke-WebRequest -Uri ${ACCESS_URL}bin/coder-windows-amd64.exe -OutFile $env:TEMP\sshd.exe + // On Windows, VS Code Remote requires a parent process of the + // executing shell to be named "sshd", otherwise it fails. See: + // https://github.com/microsoft/vscode-remote-release/issues/5699 + windowsScript = `$ProgressPreference = "SilentlyContinue" +Invoke-WebRequest -Uri ${ACCESS_URL}bin/coder-windows-${ARCH}.exe -OutFile $env:TEMP\sshd.exe Set-MpPreference -DisableRealtimeMonitoring $true -ExclusionPath $env:TEMP\sshd.exe $env:CODER_AGENT_AUTH = "${AUTH_TYPE}" $env:CODER_AGENT_URL = "${ACCESS_URL}" -Start-Process -FilePath $env:TEMP\sshd.exe -ArgumentList "agent" -PassThru`, - }, - "linux": { - "amd64": `#!/usr/bin/env sh +Start-Process -FilePath $env:TEMP\sshd.exe -ArgumentList "agent" -PassThru` + + linuxScript = `#!/usr/bin/env sh set -eu pipefail export BINARY_LOCATION=$(mktemp -d -t tmp.coderXXXXX)/coder -curl -fsSL ${ACCESS_URL}bin/coder-linux-amd64 -o $BINARY_LOCATION +curl -fsSL ${ACCESS_URL}bin/coder-linux-${ARCH} -o $BINARY_LOCATION chmod +x $BINARY_LOCATION export CODER_AGENT_AUTH="${AUTH_TYPE}" export CODER_AGENT_URL="${ACCESS_URL}" -exec $BINARY_LOCATION agent`, - }, - "darwin": { - "amd64": `#!/usr/bin/env sh +exec $BINARY_LOCATION agent` + + darwinScript = `#!/usr/bin/env sh set -eu pipefail export BINARY_LOCATION=$(mktemp -d -t tmp.coderXXXXX)/coder -curl -fsSL ${ACCESS_URL}bin/coder-darwin-amd64 -o $BINARY_LOCATION +curl -fsSL ${ACCESS_URL}bin/coder-darwin-${ARCH} -o $BINARY_LOCATION chmod +x $BINARY_LOCATION export CODER_AGENT_AUTH="${AUTH_TYPE}" export CODER_AGENT_URL="${ACCESS_URL}" -exec $BINARY_LOCATION agent`, +exec $BINARY_LOCATION agent` + + // A mapping of operating-system ($GOOS) to architecture ($GOARCH) + // to agent install and run script. ${DOWNLOAD_URL} is replaced + // with strings.ReplaceAll() when being consumed. ${ARCH} is replaced + // with the architecture when being provided. + agentScripts = map[string]map[string]string{ + "windows": { + "amd64": windowsScript, + "arm64": windowsScript, + }, + "linux": { + "amd64": linuxScript, + "arm64": linuxScript, + "armv7": linuxScript, + }, + "darwin": { + "amd64": darwinScript, + "arm64": darwinScript, }, } ) @@ -48,6 +62,7 @@ func AgentScriptEnv() map[string]string { env := map[string]string{} for operatingSystem, scripts := range agentScripts { for architecture, script := range scripts { + script := strings.ReplaceAll(script, "${ARCH}", architecture) env[fmt.Sprintf("CODER_AGENT_SCRIPT_%s_%s", operatingSystem, architecture)] = script } }