capistrano-semver-git-tags 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +7 -0
- data/README.md +40 -0
- data/lib/capistrano/semver-tag.rake +64 -0
- metadata +60 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b00c7dece9c253012e955002da882943175483fa
|
4
|
+
data.tar.gz: bce1079541f1bb2dcdfc1872acbbfb6b245f72ed
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: de5f7f25afab24a4b6442583ef153d7edb38357c1c5970e91d5c537808d98cac3524c38a615fbfa5b6c87f2e4945613a43f6a9af5bd2deb650c9546c8c05c925
|
7
|
+
data.tar.gz: a760287592e8f8ae82e5a50680e1d3c482f8a97e3ccec8a4b2986fe0cbdf6cf5f59e0d7d143e6e95edd61883817172a64c6d63b469f8b863a6bf7ca44e2c2d45
|
data/LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2018 AbdulRazzak Alkel
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
## Capistrano Semantic Version Git Tags
|
2
|
+
|
3
|
+
A Capistrano plugin for adding a semantic version Git tag at each deployment, automatically.
|
4
|
+
|
5
|
+
### Usage
|
6
|
+
|
7
|
+
capistrano-semver-git-tags is available on [rubygems.org](https://rubygems.org/gems/capistrano-semver-git-tags).
|
8
|
+
In keeping with the pattern used by Capistrano itself and other plugins, add it
|
9
|
+
to the `development` group of your Gemfile with `require: false`:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
# Gemfile
|
13
|
+
group :development do
|
14
|
+
gem 'capistrano-semver-git-tags', require: false
|
15
|
+
end
|
16
|
+
```
|
17
|
+
|
18
|
+
Then require `capistrano/semver-tag` in your Capfile
|
19
|
+
|
20
|
+
```
|
21
|
+
# Capfile
|
22
|
+
require 'capistrano/semver-tag'
|
23
|
+
```
|
24
|
+
|
25
|
+
This will allow you to use one of three tasks:
|
26
|
+
|
27
|
+
For bug fixes
|
28
|
+
```shell
|
29
|
+
bundle exec cap production deploy:patch
|
30
|
+
```
|
31
|
+
|
32
|
+
For new features
|
33
|
+
```shell
|
34
|
+
bundle exec cap production deploy:minor
|
35
|
+
```
|
36
|
+
|
37
|
+
For major changes that break backward compatibility
|
38
|
+
```shell
|
39
|
+
bundle exec cap production deploy:major
|
40
|
+
```
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
|
3
|
+
Capistrano::Configuration.instance.load do
|
4
|
+
|
5
|
+
namespace :deploy do
|
6
|
+
before :cleanup, :git_hooks do
|
7
|
+
invoke 'git:tags:push_deploy_tag' unless fetch(:semantic_version).nil?
|
8
|
+
end
|
9
|
+
|
10
|
+
task :major do
|
11
|
+
set :semantic_version, :major
|
12
|
+
invoke :deploy
|
13
|
+
end
|
14
|
+
|
15
|
+
task :minor do
|
16
|
+
set :semantic_version, :minor
|
17
|
+
invoke :deploy
|
18
|
+
end
|
19
|
+
|
20
|
+
task :patch do
|
21
|
+
set :semantic_version, :patch
|
22
|
+
invoke :deploy
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
namespace :git do
|
27
|
+
|
28
|
+
namespace :tags do
|
29
|
+
|
30
|
+
desc "Place release tag into Git and push it to server."
|
31
|
+
task :push_deploy_tag do
|
32
|
+
puts `git fetch --tags`
|
33
|
+
last_commit_tag = `git describe --exact-match --tags HEAD`.chomp
|
34
|
+
if last_commit_tag.empty?
|
35
|
+
old_tag = `git tag --sort version:refname | tail -n1`.chomp
|
36
|
+
if old_tag.nil? || old_tag.empty?
|
37
|
+
puts 'Deploy tag fail. Mostly your git version is old'
|
38
|
+
exit
|
39
|
+
end
|
40
|
+
major, minor, patch = old_tag.split('.')
|
41
|
+
case fetch(:semantic_version)
|
42
|
+
when :major
|
43
|
+
major = major.to_i + 1
|
44
|
+
minor = 0
|
45
|
+
patch = 0
|
46
|
+
when :minor
|
47
|
+
minor = minor.to_i + 1
|
48
|
+
patch = 0
|
49
|
+
when :patch
|
50
|
+
patch = patch.to_i + 1
|
51
|
+
end
|
52
|
+
new_tag = "#{major}.#{minor}.#{patch}"
|
53
|
+
user = `git config --get user.name`.chomp
|
54
|
+
email = `git config --get user.email`.chomp
|
55
|
+
puts `git tag #{new_tag} -m "Deployed by #{user} <#{email}>"`
|
56
|
+
puts `git push --tags origin`
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-semver-git-tags
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- AbdulRazzak Alkel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capistrano
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.0
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
- abdulrazaqalkl@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- LICENSE
|
35
|
+
- README.md
|
36
|
+
- lib/capistrano/semver-tag.rake
|
37
|
+
homepage: https://github.com/Abdulrazak-Alkl/capistrano-semver-git-tags
|
38
|
+
licenses: []
|
39
|
+
metadata: {}
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 2.5.2.1
|
57
|
+
signing_key:
|
58
|
+
specification_version: 4
|
59
|
+
summary: Tag your deployed commit to git with semantic versioning
|
60
|
+
test_files: []
|