Skip to content

Commit 57ba967

Browse files
committed
added confirmation
1 parent b3c311b commit 57ba967

File tree

8 files changed

+68
-9
lines changed

8 files changed

+68
-9
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.0.3 (2008-06-26)
2+
* Added MK_DIR variable linked to .mk-lib dir
3+
* Fixed path to mk-lib into new Makefile
4+
* Added `confirm` target. See Makefile sample
5+
16
## 1.0.2 (2008-06-08)
27
* Added showing release notes while upgrading
38
* Added Makefile.minimal.mk with basic commands

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ make mk-upgrade
4343

4444
### VARIABLES
4545
* **ROOT_DIR** - full path to dir with *Makefile*
46+
* **MK_DIR** - fill path to *.mk-lib* dir
4647
* **DOCKER_COMPOSE** - docker-compose executable command
4748
* **DOCKER_COMPOSE_FILE** - docker-compose.yml file
4849

@@ -67,7 +68,7 @@ restart: ## Restart all or c=<name> containers
6768
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) stop $(c)
6869
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) up $(c) -d
6970

70-
clean: ## Clean all data
71+
clean: confirm ## Clean all data
7172
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) down
7273
```
7374
You may see samples [here](https://github.com/krom/docker-compose-makefile/tree/master/samples)

samples/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# REQUIRED SECTION
22
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
3-
include $(ROOT_DIR)/.makefile-lib/common.mk
3+
include $(ROOT_DIR)/.mk-lib/common.mk
44
# END OF REQUIRED SECTION
55

66
.PHONY: help dependencies up start stop restart status ps clean
@@ -25,5 +25,5 @@ status: ## Show status of containers
2525

2626
ps: status ## Alias of status
2727

28-
clean: ## Clean all data
28+
clean: confirm ## Clean all data
2929
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) down

samples/Makefile.minimal.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# REQUIRED SECTION
22
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
3-
include $(ROOT_DIR)/.makefile-lib/common.mk
3+
include $(ROOT_DIR)/.mk-lib/common.mk
44
# END OF REQUIRED SECTION
55

66
.PHONY: help dependencies up start stop restart status ps clean
@@ -25,5 +25,5 @@ status: ## Show status of containers
2525

2626
ps: status ## Alias of status
2727

28-
clean: ## Clean all data
28+
clean: confirm ## Clean all data
2929
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) down

scripts/build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ echo "MK_VERSION := $TRAVIS_TAG" > $OUT/version.mk
1818

1919
# Compressing release to *.zip and *.tgz
2020
tar -czf release.tgz -C release .
21-
cd release/; zip -r ../release.zip .; cd ..
21+
cd release/; zip -r ../release.zip .; cd ..
22+
ruby scripts/github_release.rb -c CHANGELOG.md -s $api_key -r krom/docker-compose-makefile -t $TRAVIS_TAG

scripts/github_release.rb

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'optparse'
4+
require 'octokit'
5+
6+
options = {}
7+
OptionParser.new do |opt|
8+
opt.on('-s', '--secret SECRET', 'GitHub access token') { |o| options[:secret] = o }
9+
opt.on('-r', '--repo-slug REPO_SLUG', 'Repo slug. i.e.: apple/swift') { |o| options[:repo_slug] = o }
10+
opt.on('-c', '--changelog-file CHANGELOG_FILE', 'Changelog path') { |o| options[:changelog_file] = o }
11+
opt.on('-t', '--tag TAG', 'Tag name') { |o| options[:tag_name] = o }
12+
end.parse!
13+
14+
raise OptionParser::MissingArgument if options[:secret].nil?
15+
raise OptionParser::MissingArgument if options[:repo_slug].nil?
16+
raise OptionParser::MissingArgument if options[:changelog_file].nil?
17+
raise OptionParser::MissingArgument if options[:tag_name].nil?
18+
19+
client = Octokit::Client.new(:access_token => options[:secret])
20+
user = client.user
21+
user.login
22+
23+
unless client.scopes.include? 'public_repo' or client.scopes.include? 'repo'
24+
raise Error, "Insufficient permissions. Make sure your token contains the repo or public_repo scope."
25+
end
26+
27+
puts "Logged in as #{user.name}"
28+
puts "Deploying to repo: #{options[:repo_slug]}"
29+
30+
tag_matched = false
31+
release_url = nil
32+
releases = client.releases(options[:repo_slug])
33+
body = File.open(options[:changelog_file], "rb").read[/##.*?$(.*?)##/m, 1].strip
34+
35+
releases.each do |release|
36+
if release.tag_name == options[:tag_name]
37+
release_url = release.rels[:self].href
38+
tag_matched = true
39+
end
40+
end
41+
42+
# if tag has been pushed directly to git, create a github release
43+
if tag_matched == false
44+
client.create_release(options[:repo_slug], options[:tag_name], { :name => options[:tag_name], :body => body })
45+
else
46+
client.update_release(release_url, { :name => options[:tag_name], :body => body })
47+
end

src/common.mk

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
include $(ROOT_DIR)/.mk-lib/variables.mk
2-
-include $(ROOT_DIR)/.mk-lib/version.mk
1+
MK_DIR := $(ROOT_DIR)/.mk-lib
2+
include $(MK_DIR)/variables.mk
3+
-include $(MK_DIR)/version.mk
34
-include $(ROOT_DIR)/.make.env
45
-include .make.env
56

@@ -11,8 +12,11 @@ DOCKER_COMPOSE_FILE := $(f)
1112
help: ##@other Show this help.
1213
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)
1314

15+
confirm:
16+
@( read -p "$(RED)Are you sure? [y/N]$(RESET): " sure && case "$$sure" in [yY]) true;; *) false;; esac )
17+
1418
mk-upgrade: ##@other Check for updates of mk-lib
15-
@MK_VERSION=$(MK_VERSION) MK_REPO=$(MK_REPO) $(ROOT_DIR)/.mk-lib/self-upgrade.sh
19+
@MK_VERSION=$(MK_VERSION) MK_REPO=$(MK_REPO) $(MK_DIR)/self-upgrade.sh
1620

1721
mk-version: ##@other Show current version of mk-lib
1822
@echo $(MK_VERSION)

src/variables.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
GREEN := $(shell tput -Txterm setaf 2)
33
WHITE := $(shell tput -Txterm setaf 7)
44
YELLOW := $(shell tput -Txterm setaf 3)
5+
RED := $(shell tput -Txterm setaf 1)
56
RESET := $(shell tput -Txterm sgr0)
67

78
# Add the following 'help' target to your Makefile

0 commit comments

Comments
 (0)