mirror of
https://github.com/Gouryella/drip.git
synced 2026-02-27 06:42:05 +00:00
ci(release): Optimizes the way Git commit information is retrieved in the build workflow.
The previous method of obtaining commit hashes via `git rev-parse` has been changed to directly using the `github.sha` variable provided by GitHub Actions, and the first 10 characters are truncated as the short version commit hash. Unnecessary `fetch-depth` configuration has also been removed.
This commit is contained in:
7
.github/workflows/release.yml
vendored
7
.github/workflows/release.yml
vendored
@@ -16,8 +16,6 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
@@ -31,9 +29,10 @@ jobs:
|
||||
- name: Build for all platforms
|
||||
run: |
|
||||
VERSION=${{ steps.version.outputs.VERSION }}
|
||||
COMMIT=$(git rev-parse --short=10 HEAD)
|
||||
COMMIT=${{ github.sha }}
|
||||
COMMIT_SHORT=${COMMIT:0:10}
|
||||
BUILD_TIME=$(date -u '+%Y-%m-%d_%H:%M:%S')
|
||||
LDFLAGS="-s -w -X main.Version=${VERSION} -X main.GitCommit=${COMMIT} -X main.BuildTime=${BUILD_TIME}"
|
||||
LDFLAGS="-s -w -X main.Version=${VERSION} -X main.GitCommit=${COMMIT_SHORT} -X main.BuildTime=${BUILD_TIME}"
|
||||
|
||||
# Linux amd64
|
||||
GOOS=linux GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o drip-${VERSION}-linux-amd64 ./cmd/drip
|
||||
|
||||
Reference in New Issue
Block a user