diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d71a271..2af9a38 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -120,8 +120,7 @@ jobs: env: GO111MODULE: on - name: Build binary - run: |- - go build -o gg.exe -ldflags="-X main.buildCommit=$Env:GITHUB_SHA -X main.buildTime=$((Get-Date).ToUniversalTime() | Get-Date -UFormat '%Y-%m-%dT%TZ')" gg-scm.io/tool/cmd/gg + run: release\build.ps1 -out gg.exe env: GO111MODULE: on - name: Upload binary diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 6e7a7ca..fbcb9c0 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -3,6 +3,19 @@ // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ + { + "label": "Build", + "type": "shell", + "group": { + "kind": "build", + "isDefault": true + }, + "command": "release/build.bash gg", + "windows": { + "command": "release\\build.ps1 -out release\\msi\\gg.exe" + }, + "problemMatcher": ["$go"] + }, { "label": "go test", "type": "shell", diff --git a/release/build.ps1 b/release/build.ps1 new file mode 100644 index 0000000..af93ae9 --- /dev/null +++ b/release/build.ps1 @@ -0,0 +1,22 @@ +# Copyright 2020 The gg Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 + +param($out,$version='') + +$buildTime = (Get-Date).ToUniversalTime() | Get-Date -UFormat '%Y-%m-%dT%TZ' +$env:GOOS = "windows" +$env:GOARCH = "amd64" +go build -o $out -ldflags="-X main.versionInfo=$version -X main.buildCommit=$env:GITHUB_SHA -X main.buildTime=$buildTime" gg-scm.io/tool/cmd/gg