Skip to content

Commit 398f905

Browse files
authored
Merge pull request #915 from mackerelio/remove-rewrite-some-files-on-every-releases
Remove rewrite some files on every releases
2 parents 941dd33 + 2d1c5ba commit 398f905

File tree

6 files changed

+29
-11
lines changed

6 files changed

+29
-11
lines changed

.github/workflows/create-release-pr.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ jobs:
2424
next_version: ${{ github.event.inputs.release_version }}
2525
package_name: mackerel-check-plugins
2626
version_go_file_path: mackerel-check.go
27-
28-
- run: |
29-
CURRENT=${{ steps.start.outputs.currentVersion }}
30-
NEXT=${{ steps.start.outputs.nextVersion }}
31-
mv packaging/mackerel-check-plugins_$CURRENT.orig.tar.gz packaging/mackerel-check-plugins_$NEXT.orig.tar.gz
27+
ignore_update_program_files: "true"
3228

3329
- uses: mackerelio/mackerel-create-release-pull-request-action@main
3430
with:

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ jobs:
5555
with:
5656
go-version: 1.23.x
5757
- uses: actions/checkout@v4
58+
with:
59+
fetch-depth: 0
5860
- run: make clean build rpm deb
5961
- uses: actions/upload-artifact@v4
6062
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
!.travis.yml
77
/build
88
check-*/check-*
9+
packaging/*.deb

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
VERSION = 0.48.0
2-
CURRENT_REVISION = $(shell git rev-parse --short HEAD)
1+
# This VERSION variable indicates the latest tag.
2+
VERSION = $(subst v,,$(shell git describe --abbrev=0 --tags))
33
ifeq ($(OS),Windows_NT)
44
GOPATH_ROOT:=$(shell cygpath ${GOPATH})
55
else
@@ -40,7 +40,7 @@ build:
4040
# We need to force rebuild "mackerel-check" if GOOS or GOARCH are passed.
4141
build/mackerel-check: $(patsubst %,depends_on,$(GOOS)$(GOARCH))
4242
mkdir -p build
43-
CGO_ENABLED=0 go build -ldflags="-s -w -X main.gitcommit=$(CURRENT_REVISION)" \
43+
CGO_ENABLED=0 go build -ldflags="-s -w" \
4444
-o build/mackerel-check
4545

4646
.PHONY: depends_on
@@ -78,14 +78,18 @@ deb: deb-v2-x86 deb-v2-arm
7878

7979
.PHONY: deb-v2-x86
8080
deb-v2-x86:
81+
git clean -f -d ./packaging
8182
make build/mackerel-check GOOS=linux GOARCH=amd64
8283
cp build/mackerel-check packaging/deb-v2/debian/
84+
cp -f packaging/dummy-empty.tar.gz packaging/mackerel-check-plugins_${VERSION}.orig.tar.gz
8385
cd packaging/deb-v2 && debuild --no-tgz-check -rfakeroot -uc -us
8486

8587
.PHONY: deb-v2-arm
8688
deb-v2-arm:
89+
git clean -f -d ./packaging
8790
make build/mackerel-check GOOS=linux GOARCH=arm64
8891
cp build/mackerel-check packaging/deb-v2/debian/
92+
cp -f packaging/dummy-empty.tar.gz packaging/mackerel-check-plugins_${VERSION}.orig.tar.gz
8993
cd packaging/deb-v2 && debuild --no-tgz-check -rfakeroot -uc -us -aarm64
9094

9195
.PHONY: clean

mackerel-check.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"path/filepath"
99
"regexp"
1010
"runtime"
11+
"runtime/debug"
1112
"strings"
1213
)
1314

@@ -60,11 +61,25 @@ func run(args []string) int {
6061
return exitOK
6162
}
6263

63-
const version = "0.48.0"
64-
65-
var gitcommit string
64+
func fromVCS() (version, rev string) {
65+
version = "unknown"
66+
rev = "unknown"
67+
info, ok := debug.ReadBuildInfo()
68+
if !ok {
69+
return
70+
}
71+
version = info.Main.Version
72+
for _, s := range info.Settings {
73+
if s.Key == "vcs.revision" {
74+
rev = s.Value
75+
return
76+
}
77+
}
78+
return
79+
}
6680

6781
func printHelp() {
82+
version, gitcommit := fromVCS()
6883
fmt.Printf(`mackerel-check %s (rev %s) [%s %s %s]
6984
7085
Usage: mackerel-check <plugin> [<args>]
File renamed without changes.

0 commit comments

Comments
 (0)