Skip to content

Commit 9684b47

Browse files
committed
Add proper versioning to Makefile
1 parent 97c2960 commit 9684b47

File tree

1 file changed

+34
-13
lines changed

1 file changed

+34
-13
lines changed

Makefile

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,42 @@
1-
VERSION := 0
2-
AUTHOR := ashald
3-
PLUGIN_NAME := docker-volume-loopback
4-
PLUGIN_FULL_NAME := ${AUTHOR}/${PLUGIN_NAME}
5-
ROOTFS_CONTAINER := ${PLUGIN_NAME}-rootfs
6-
ROOTFS_IMAGE := ${AUTHOR}/${ROOTFS_CONTAINER}
1+
VERSION ?= $(shell git describe 2>/dev/null || echo "v0.$(git rev-list --count HEAD)")
2+
AUTHOR := ashald
3+
PLUGIN_NAME := docker-volume-loopback
4+
PLUGIN_FULL_NAME := ${AUTHOR}/${PLUGIN_NAME}
5+
ROOTFS_CONTAINER := ${PLUGIN_NAME}-rootfs
6+
ROOTFS_IMAGE := ${AUTHOR}/${ROOTFS_CONTAINER}
7+
78

89
all: format build
910

11+
1012
format:
1113
go fmt ./...
1214

15+
1316
build:
1417
GOOS=linux GOARCH=amd64 go build -o "$(PLUGIN_NAME)"
1518

19+
20+
clean:
21+
mkdir -p ./plugin/rootfs
22+
rm -rf ./plugin/rootfs
23+
rm -f ./$(ROOTFS_IMAGE)
24+
25+
clean-plugin:
26+
docker plugin rm --force $(PLUGIN_FULL_NAME):$(VERSION) || true
27+
docker plugin rm --force $(PLUGIN_FULL_NAME) || true
28+
29+
1630
rootfs-image:
1731
docker build -t $(ROOTFS_IMAGE) .
1832

1933

2034
rootfs: rootfs-image
2135
docker rm -vf $(ROOTFS_CONTAINER) || true
2236
docker create --name $(ROOTFS_CONTAINER) $(ROOTFS_IMAGE) || true
23-
mkdir -p plugin/rootfs
24-
rm -rf plugin/rootfs/*
25-
docker export $(ROOTFS_CONTAINER) | tar -x -C plugin/rootfs
37+
mkdir -p ./plugin/rootfs
38+
rm -rf ./plugin/rootfs/*
39+
docker export $(ROOTFS_CONTAINER) | tar -x -C ./plugin/rootfs
2640
docker rm -vf $(ROOTFS_CONTAINER)
2741

2842

@@ -33,12 +47,19 @@ plugin: rootfs
3347
docker plugin enable $(PLUGIN_NAME)
3448

3549

36-
plugin-push: rootfs
50+
plugin-push-version: rootfs
51+
docker plugin rm --force $(PLUGIN_FULL_NAME):$(VERSION) || true
52+
docker plugin create $(PLUGIN_FULL_NAME):$(VERSION) ./plugin
53+
docker plugin push $(PLUGIN_FULL_NAME):$(VERSION)
54+
55+
56+
plugin-push-default: rootfs
3757
docker plugin rm --force $(PLUGIN_FULL_NAME) || true
3858
docker plugin create $(PLUGIN_FULL_NAME) ./plugin
39-
docker plugin create $(PLUGIN_FULL_NAME):$(VERSION) ./plugin
4059
docker plugin push $(PLUGIN_FULL_NAME)
41-
docker plugin push $(PLUGIN_FULL_NAME):$(VERSION)
4260

4361

44-
.PHONY: build rootfs-image rootfs plugin plugin-push
62+
plugin-push: plugin-push-version plugin-push-default
63+
64+
65+
.PHONY: clean clean-plugin build rootfs-image rootfs plugin plugin-push plugin-push-version plugin-push-default

0 commit comments

Comments
 (0)