Skip to content

Commit 3ff4759

Browse files
Merge pull request #39 from Pix4D/annotated-tags
build: ensure that all release tags are annotated tags
2 parents c8e1449 + 7365146 commit 3ff4759

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
matrix:
99
go-version: [1.17.x]
1010
os: [ubuntu-latest]
11-
task-version: [v3.7.0]
11+
task-version: [v3.10.0]
1212
runs-on: ${{ matrix.os }}
1313
steps:
1414
- name: Install Go ${{ matrix.go-version }}
@@ -28,3 +28,4 @@ jobs:
2828
- run: task install:deps
2929
- run: task lint
3030
- run: task test
31+
- run: task build

Taskfile.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,43 @@ tasks:
4444
build:
4545
desc: Build the terravalet executable.
4646
cmds:
47+
- task: check-tags
4748
- go build -o bin/terravalet -v -ldflags="{{.LDFLAGS}}" .
4849
vars: &build-vars
4950
FULL_VERSION:
5051
sh: git describe --long --dirty --always
5152
LDFLAGS: -w -s -X main.fullVersion={{.FULL_VERSION}}
5253

54+
check-tags:
55+
# A lightweight tags is listed as "commit" in the output of "git for-each-ref 'refs/tags".
56+
# If we find at least one, we fail the build.
57+
# To replace a lightweight tag with an annotated:
58+
# 1. Checkout the lightweight tag
59+
# git checkout <tag>
60+
# 2. Look up the date and committer
61+
# git log
62+
# 3. Replace the lightweight tag with an annotated one, with the same date and author
63+
# GIT_COMMITTER_DATE="2021-01-31 00:00" \
64+
# git tag --force --annotate <tag> -m 'Release <tag>'
65+
# 4. If the lightweight tag has also been pushed to the remote, it can become a mess
66+
# quickly, because it will force everybody to be informed and re-fetch the modified
67+
# tags.
68+
# 4.1 Force push the rewritten tag
69+
# git push --force origin <tag>
70+
# 4.2 Inform everybody who cloned the repo to perform the following:
71+
# git tag -d <tag>
72+
# git fetch origin tag <tag>
73+
# 5. Go back to the HEAD of the branch
74+
# git checkout master
75+
desc: Check if the repo contains lightweight git tags beginning with "v".
76+
cmds:
77+
- if test -n "$WRONG_TAGS"; then echo $HEADER; echo "$WRONG_TAGS"; echo $MSG; exit 1; fi
78+
env:
79+
WRONG_TAGS:
80+
sh: "(git for-each-ref 'refs/tags/v*' | fgrep commit) || exit 0"
81+
HEADER: "Error: this repo contains the following lightweight git tags beginning with v (so meant to be release tags):"
82+
MSG: Release tags should be annotated. Read the Taskfile for how to fix.
83+
5384
#
5485
# usage: env RELEASE_TAG=v0.1.0 gopass task release
5586
#
@@ -69,7 +100,7 @@ tasks:
69100
# before building the executables, so that we can embed this information
70101
# in the binaries.
71102
# To recover: delete local tag: git tag --delete tagname
72-
- git tag -a {{.RELEASE_TAG}} -m ''
103+
- git tag --annotate {{.RELEASE_TAG}} -m 'Release {{.RELEASE_TAG}}'
73104
- task: release-linux
74105
- task: release-darwin
75106
# - task: system-test

0 commit comments

Comments
 (0)