From c4168b5603b282e63d507536ec821a1e60d4a071 Mon Sep 17 00:00:00 2001 From: Dennis Staal Date: Tue, 6 Feb 2024 09:29:19 +0100 Subject: [PATCH 1/5] Test workflow vars --- .github/workflows/go.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 41a959b..5a023a9 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -26,8 +26,8 @@ jobs: - name: Build run: | - echo Build James ${GITHUB_REF#refs/tags/v} - go build -ldflags "-X main.Build=${GITHUB_REF#refs/tags/v}" -v ./... + echo Build James ${{GITHUB_REF#refs/tags/v}} + go build -ldflags "-X main.Build=${{GITHUB_REF#refs/tags/v}}" -v ./... - name: Test run: go test -v ./... From 9ac1929cdc592c5ecf199eaa2214861bcc492fb8 Mon Sep 17 00:00:00 2001 From: Dennis Staal Date: Tue, 6 Feb 2024 09:32:41 +0100 Subject: [PATCH 2/5] Use git describe --- .github/workflows/go.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 5a023a9..d0e9eb6 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -26,8 +26,8 @@ jobs: - name: Build run: | - echo Build James ${{GITHUB_REF#refs/tags/v}} - go build -ldflags "-X main.Build=${{GITHUB_REF#refs/tags/v}}" -v ./... + echo "Build James" git describe --tags + go build -ldflags "-X main.Build=${GITHUB_REF#refs/tags/v}" -v ./... - name: Test run: go test -v ./... From 227f9a50797722193f42908e712bc33baccd51ab Mon Sep 17 00:00:00 2001 From: Dennis Staal Date: Tue, 6 Feb 2024 09:41:13 +0100 Subject: [PATCH 3/5] Use git describe --- .github/workflows/go.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index d0e9eb6..c1a7fff 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -21,13 +21,11 @@ jobs: with: go-version: 1.18 - - name: Checkout code - uses: actions/checkout@v4 - - name: Build run: | - echo "Build James" git describe --tags - go build -ldflags "-X main.Build=${GITHUB_REF#refs/tags/v}" -v ./... + LATEST_TAG=$(git describe --tags) + echo Build James $LATEST_TAG + go build -ldflags "-X main.Build=$(LATEST_TAG)" -v ./... - name: Test run: go test -v ./... From 01a400da245fc4c8368a80a1da9fc31410d19c12 Mon Sep 17 00:00:00 2001 From: Dennis Staal Date: Tue, 6 Feb 2024 09:44:31 +0100 Subject: [PATCH 4/5] Checkout code --- .github/workflows/go.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index c1a7fff..c2b4d9a 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -21,6 +21,11 @@ jobs: with: go-version: 1.18 + - name: Git checkout + uses: actions/checkout@v4 + with: + fetch-depth: '0' + - name: Build run: | LATEST_TAG=$(git describe --tags) From 1991e6de8231d322ca58e1fa69d97c213623bc8b Mon Sep 17 00:00:00 2001 From: Dennis Staal Date: Tue, 6 Feb 2024 09:46:21 +0100 Subject: [PATCH 5/5] Update go build command --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index c2b4d9a..e049075 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -30,7 +30,7 @@ jobs: run: | LATEST_TAG=$(git describe --tags) echo Build James $LATEST_TAG - go build -ldflags "-X main.Build=$(LATEST_TAG)" -v ./... + go build -ldflags "-X main.Build=$LATEST_TAG" -v ./... - name: Test run: go test -v ./...