shipitron 1.3.0 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c5423fc9dbd202488e45ab382ad2bc37de889d909179b6e65a33d362ad9d20c
4
- data.tar.gz: ea5bea8068a0d5d2ac0787c5590d53c3bf5a7f88ba6d646474d760b21dd4b707
3
+ metadata.gz: c1f02ed921fdb5107cebc789f0554daac22d275024e50b94f6059d0ab6d996c1
4
+ data.tar.gz: 65e5fbca1de1090e34178d44244a5e30938b7de80fe17f0ea7b3df9510e54f9a
5
5
  SHA512:
6
- metadata.gz: 9983df8f5f01ea66a28e4bf7499bfed81bf49bc0127895669d003176861ad6db04b48a8c351215cd17ab927b1eb4b9087f203075206e2967be01429c8cd15d21
7
- data.tar.gz: b5f1be2174a00e52ec0fb5df6ee04a64ac83ed73f09e6651fcf5655cb9a0c85f1746cbf30bf6bd8388f97668aac129bd1ef32980e79c44ffd645f656fe9213e5
6
+ metadata.gz: 14d5f5e245ab946538ab1aee9b5d88d88fafb7d4baa61c3634d165d42acfcf5a83e0231cc9299f37d37d38da9a96be0dfc04ba77b42499fc36bdcc5acf69980c
7
+ data.tar.gz: ace846368647ec022343af65af9978f2647aa7113de1795900a18091754e34e26657bd4d4d4be10e60f4bef81baffa886917c79537f834377182eadabb4a704e
@@ -2,3 +2,4 @@
2
2
  /pkg/
3
3
  Gemfile.lock
4
4
  /tmp/
5
+ /spec/fixtures/test_repo
@@ -0,0 +1 @@
1
+ spec/fixtures/test_repo.tgz filter=lfs diff=lfs merge=lfs -text
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  Gemfile.lock
4
4
  /tmp/
5
5
  /cache/
6
+ /spec/fixtures/test_repo
data/Dockerfile CHANGED
@@ -15,17 +15,19 @@ RUN addgroup -S shipitron && \
15
15
 
16
16
  RUN apk add --no-cache \
17
17
  ca-certificates \
18
- openssl \
18
+ openssl-dev \
19
19
  tini \
20
20
  su-exec \
21
21
  build-base \
22
22
  git \
23
+ git-lfs \
23
24
  openssh-client \
24
25
  perl \
25
26
  bash \
26
27
  curl \
27
28
  wget \
28
- jq
29
+ jq \
30
+ cmake
29
31
 
30
32
  ENV ECR_CREDENTIAL_HELPER_VERSION 0.4.0
31
33
  RUN cd /usr/local/bin && \
@@ -20,9 +20,31 @@ RUN apk add --no-cache \
20
20
  wget \
21
21
  jq
22
22
 
23
+ ENV ECR_CREDENTIAL_HELPER_VERSION 0.4.0
24
+ RUN cd /usr/local/bin && \
25
+ wget https://amazon-ecr-credential-helper-releases.s3.us-east-2.amazonaws.com/${ECR_CREDENTIAL_HELPER_VERSION}/linux-amd64/docker-credential-ecr-login && \
26
+ chmod +x docker-credential-ecr-login
27
+
28
+ ENV BUILDKIT_VERSION v0.7.2
29
+ RUN cd /usr/local/bin && \
30
+ wget -nv https://github.com/moby/buildkit/releases/download/${BUILDKIT_VERSION}/buildkit-${BUILDKIT_VERSION}.linux-amd64.tar.gz && \
31
+ tar --strip-components=1 -zxvf buildkit-${BUILDKIT_VERSION}.linux-amd64.tar.gz bin/buildctl && \
32
+ chmod +x buildctl && \
33
+ rm -f buildkit-${BUILDKIT_VERSION}.linux-amd64.tar.gz
34
+
35
+ USER shipitron
36
+ ENV BUILDX_VERSION v0.4.2
37
+ RUN cd /home/shipitron && \
38
+ wget -nv https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/buildx-${BUILDX_VERSION}.linux-amd64 && \
39
+ mkdir -p ~/.docker/cli-plugins && \
40
+ mv buildx-${BUILDX_VERSION}.linux-amd64 ~/.docker/cli-plugins/docker-buildx && \
41
+ chmod a+x ~/.docker/cli-plugins/docker-buildx
42
+
43
+ USER root
44
+
23
45
  WORKDIR /app
24
46
 
25
- ENV SHIPITRON_VERSION=1.3.0
47
+ ENV SHIPITRON_VERSION=1.3.1
26
48
 
27
49
  RUN gem install shipitron -v ${SHIPITRON_VERSION} && \
28
50
  mkdir -p /home/shipitron/.ssh && \
data/README.md CHANGED
@@ -85,8 +85,9 @@ To release a new version:
85
85
  - Update the version number in `version.rb` and `Dockerfile.release` and commit the result.
86
86
  - `./build_dev.sh`
87
87
  - `docker run -it --rm -v ~/.gitconfig:/root/.gitconfig -v ~/.gitconfig.user:/root/.gitconfig.user -v ~/.ssh/id_rsa:/root/.ssh/id_rsa -v ~/.gem:/root/.gem -w /shipitron outstand/shipitron:dev rake release`
88
- - `docker build -t outstand/shipitron:VERSION -f Dockerfile.release .`
89
- - `docker push outstand/shipitron:VERSION`
90
- - `docker tag outstand/shipitron:VERSION outstand/shipitron:latest`
88
+ - `VERSION=<version>`
89
+ - `docker build -t outstand/shipitron:$VERSION -f Dockerfile.release .`
90
+ - `docker push outstand/shipitron:$VERSION`
91
+ - `docker tag outstand/shipitron:$VERSION outstand/shipitron:latest`
91
92
  - `docker push outstand/shipitron:latest`
92
93
  - Update ECS task definition with new version
@@ -0,0 +1,57 @@
1
+ require 'shipitron'
2
+ require 'rugged'
3
+
4
+ module Shipitron
5
+ class GitInfo < Hashie::Dash
6
+ property :sha
7
+ property :short_sha
8
+ property :email
9
+ property :name
10
+ property :summary
11
+ property :timestamp
12
+ property :branch
13
+ property :tag
14
+
15
+ def one_liner
16
+ "#{name} (#{short_sha}): #{summary}"
17
+ end
18
+
19
+ def self.from_path(path:)
20
+ repo = Rugged::Repository.new(path)
21
+ commit = repo.last_commit
22
+ self.new(
23
+ sha: commit.oid,
24
+ short_sha: commit.oid[0, 12],
25
+ email: commit.author.dig(:email),
26
+ name: commit.author.dig(:name),
27
+ summary: commit.summary,
28
+ timestamp: commit.epoch_time.to_s,
29
+ branch: branch_name(repo: repo),
30
+ tag: tag_name(repo: repo)
31
+ )
32
+ end
33
+
34
+ def self.branch_name(repo:)
35
+ ref = repo.head
36
+ ref.branch? ? ref.name.sub('refs/heads/', '') : nil
37
+ end
38
+
39
+ def self.tag_name(repo:)
40
+ ref = repo.head
41
+ tags = repo.tags
42
+
43
+ tags.each do |tag|
44
+ target_id =
45
+ if tag.annotated?
46
+ tag.annotation.target_id
47
+ else
48
+ tag.target.oid
49
+ end
50
+
51
+ return tag.name if ref.target_id == target_id
52
+ end
53
+
54
+ nil
55
+ end
56
+ end
57
+ end
@@ -12,7 +12,7 @@ module Shipitron
12
12
 
13
13
  required :application
14
14
  required :docker_image
15
- required :git_sha
15
+ required :git_info
16
16
  required :named_tag
17
17
  required :region
18
18
  optional :registry
@@ -9,7 +9,7 @@ module Shipitron
9
9
 
10
10
  required :application
11
11
  required :docker_image
12
- required :git_sha
12
+ required :git_info
13
13
  required :named_tag
14
14
  optional :build_script, default: 'shipitron/build.sh'
15
15
  optional :registry
@@ -18,7 +18,7 @@ module Shipitron
18
18
  Logger.info 'Building docker image'
19
19
 
20
20
  docker_image.registry = registry if registry != nil
21
- docker_image.tag = git_sha
21
+ docker_image.tag = git_info.short_sha
22
22
 
23
23
  FileUtils.cd("/home/shipitron/#{application}") do
24
24
  unless Pathname.new(build_script).exist?
@@ -43,8 +43,8 @@ module Shipitron
43
43
  context.docker_image
44
44
  end
45
45
 
46
- def git_sha
47
- context.git_sha
46
+ def git_info
47
+ context.git_info
48
48
  end
49
49
 
50
50
  def named_tag
@@ -1,5 +1,6 @@
1
1
  require 'shipitron'
2
2
  require 'shellwords'
3
+ require 'shipitron/git_info'
3
4
 
4
5
  module Shipitron
5
6
  module Server
@@ -22,10 +23,8 @@ module Shipitron
22
23
  end
23
24
 
24
25
  Logger.info 'Using this git commit:'
25
- FileUtils.cd("/home/shipitron/#{application}") do
26
- context.git_sha = `git rev-parse --short=12 HEAD`.chomp
27
- Logger.info `git --no-pager log --format='%aN (%h): %s' -n 1`.chomp
28
- end
26
+ context.git_info = GitInfo.from_path(path: "/home/shipitron/#{application}")
27
+ Logger.info context.git_info.one_liner
29
28
  end
30
29
 
31
30
  private
@@ -9,6 +9,7 @@ module Shipitron
9
9
 
10
10
  required :region
11
11
  required :clusters
12
+ required :git_info
12
13
  optional :post_builds
13
14
 
14
15
  def call
@@ -26,7 +27,41 @@ module Shipitron
26
27
  container_overrides: [
27
28
  {
28
29
  name: post_build.container_name,
29
- command: post_build.command_ary
30
+ command: post_build.command_ary,
31
+ environment: [
32
+ {
33
+ name: "GIT_SHA",
34
+ value: git_info.sha
35
+ },
36
+ {
37
+ name: "GIT_SHORT_SHA",
38
+ value: git_info.short_sha
39
+ },
40
+ {
41
+ name: "GIT_EMAIL",
42
+ value: git_info.email
43
+ },
44
+ {
45
+ name: "GIT_NAME",
46
+ value: git_info.name
47
+ },
48
+ {
49
+ name: "GIT_MESSAGE",
50
+ value: git_info.summary
51
+ },
52
+ {
53
+ name: "GIT_TIMESTAMP",
54
+ value: git_info.timestamp
55
+ },
56
+ {
57
+ name: "GIT_BRANCH",
58
+ value: git_info.branch
59
+ },
60
+ {
61
+ name: "GIT_TAG",
62
+ value: git_info.tag
63
+ }
64
+ ]
30
65
  }
31
66
  ]
32
67
  },
@@ -75,6 +110,10 @@ module Shipitron
75
110
  def clusters
76
111
  context.clusters
77
112
  end
113
+
114
+ def git_info
115
+ context.git_info
116
+ end
78
117
  end
79
118
  end
80
119
  end
@@ -1,3 +1,3 @@
1
1
  module Shipitron
2
- VERSION = '1.3.0'
2
+ VERSION = '1.3.1'
3
3
  end
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_runtime_dependency 'tty-table', '~> 0.9'
31
31
  spec.add_runtime_dependency 'pastel', '~> 0.7'
32
32
  spec.add_runtime_dependency 'excon', '~> 0.76'
33
+ spec.add_runtime_dependency 'rugged', '~> 1.0'
33
34
 
34
35
  spec.add_development_dependency "bundler", "~> 2.1"
35
36
  spec.add_development_dependency "rake", "~> 13.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shipitron
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Schlesinger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-27 00:00:00.000000000 Z
11
+ date: 2020-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -192,6 +192,20 @@ dependencies:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0.76'
195
+ - !ruby/object:Gem::Dependency
196
+ name: rugged
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '1.0'
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '1.0'
195
209
  - !ruby/object:Gem::Dependency
196
210
  name: bundler
197
211
  requirement: !ruby/object:Gem::Requirement
@@ -285,6 +299,7 @@ extensions: []
285
299
  extra_rdoc_files: []
286
300
  files:
287
301
  - ".dockerignore"
302
+ - ".gitattributes"
288
303
  - ".gitignore"
289
304
  - ".rspec"
290
305
  - Dockerfile
@@ -316,6 +331,7 @@ files:
316
331
  - lib/shipitron/ecs_task_def.rb
317
332
  - lib/shipitron/fetch_bucket.rb
318
333
  - lib/shipitron/find_docker_volume_name.rb
334
+ - lib/shipitron/git_info.rb
319
335
  - lib/shipitron/logger.rb
320
336
  - lib/shipitron/mustache_yaml_parser.rb
321
337
  - lib/shipitron/parse_templates.rb