samus 1.6.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 8a296d7f542703df6cf792c6e304b0836689f2fecf47454225dfe50d60045ced
4
- data.tar.gz: be6e1b20ba87c084858060c2d607b27e5193f55ecd6cfa9287fd3ab22df091a9
2
+ SHA1:
3
+ metadata.gz: dfd222e26ed2614c6604f9323ee6351725fa5b06
4
+ data.tar.gz: 6c06fedbabcc7ea4579c15028f9ac5efdb19f61e
5
5
  SHA512:
6
- metadata.gz: 2f599e0394de30729586d82c8c2557cbe7cc3b7eb3968c013fa18b8e70a6704f0dc8cc841e738c2d61baa6be3b677b6d5740b82b946a0bd5d81fe73c1424292d
7
- data.tar.gz: 44fe1f224fcfe46d72ad27f9da76c7d04b011e4739e5682e254610691626b8169eb72059e7dbebb6d78bd0bc9fcdf7abb99bf19061388338fe757b64961b3386
6
+ metadata.gz: d1c024b9d0673fea1b125c8d709fceb0ee4a36b2e4086472894fcc18e6179803d53c591635f7de61a775e05f3e0bb88546d3847a6bc43ceea13a500d8f124f6c
7
+ data.tar.gz: 865798d531d3bab1c5315ffc0456ce21fc7e1db35a22b220b674167abf4dc89886f4d61330305346568338670882fe01654f5ff2c271f2b19addc6c5b232e590
@@ -1,3 +1,10 @@
1
+ # 2.0.0 - August 9th, 2018
2
+
3
+ - Add support for Windows. This caused a backwards incompatible change where
4
+ environment variables are now UPPERCASED by default. In general this should
5
+ have no effect if you rely only on built-in scripts.
6
+ - Report an error if credentials cannot be parsed.
7
+
1
8
  # 1.6.0 - July 19, 2018
2
9
 
3
10
  - Add support for credentials for git-push. Add a credentials file with
data/README.md CHANGED
@@ -221,10 +221,10 @@ as environment variables with a prefixed underscore. For example, the
221
221
  ```sh
222
222
  #!/bin/sh
223
223
 
224
- rake $_task
224
+ rake $_TASK
225
225
  ```
226
226
 
227
- The `$_task` variable is the "task" argument from the manifest.
227
+ The `$_TASK` variable is the "task" argument from the manifest.
228
228
 
229
229
  Note that commands must be executable (`chmod +x`) and have proper shebang
230
230
  lines or they will not function.
@@ -240,18 +240,18 @@ commands directory depending on whether they are for `samus build` or
240
240
  In addition to exposing arguments as underscored environment variables,
241
241
  Samus also exposes a few special variables with double underscore prefixes:
242
242
 
243
- * `__build_dir` - this variable refers to the temporary directory that the
243
+ - `__build_dir` - this variable refers to the temporary directory that the
244
244
  release package is being built inside of. The files inside of this directory,
245
- and *only* the files inside of this directory, will be built into the release
245
+ and _only_ the files inside of this directory, will be built into the release
246
246
  archive. If you write a build-time command that produces an output file which
247
247
  is part of the release, you should make sure to move it into this directory.
248
- * `__restore_file` - the restore file is a newline delimited file containing
248
+ - `__restore_file` - the restore file is a newline delimited file containing
249
249
  branches and their original ref. All branches listed in this file will be
250
250
  restored to the respective ref at the end of `samus build` regardless of
251
251
  success status. If you make destructive modifications to existing branches
252
252
  in the workspace repository, you should add the original ref for the branch
253
253
  to this file.
254
- * `__creds_*` - provides key, secret, and other values loaded from credentials.
254
+ - `__creds_*` - provides key, secret, and other values loaded from credentials.
255
255
  See Credentials section for more information on how these are set.
256
256
 
257
257
  #### Help Files
@@ -273,9 +273,9 @@ Short description of command.
273
273
 
274
274
  Notes:
275
275
 
276
- * The first line of the help file is used as the summary in the `show-cmd`
276
+ - The first line of the help file is used as the summary in the `show-cmd`
277
277
  listing.
278
- * Never omit a section. If a command has no files or arguments, use "(none)"
278
+ - Never omit a section. If a command has no files or arguments, use "(none)"
279
279
  as the list item text.
280
280
 
281
281
  ### Credentials
@@ -297,12 +297,12 @@ Key: THE_API_KEY
297
297
  Secret: THE_SECRET
298
298
  ```
299
299
 
300
- Or, alternatively, an *executable* which prints the above format to standard
300
+ Or, alternatively, an _executable_ which prints the above format to standard
301
301
  out.
302
302
 
303
- These values are read in by Samus and get exposed as `$__creds_key` and
304
- `$__creds_secret` respectively in Samus commands. You can provide other
305
- metadata as well, which would be included as `$__creds_name` (for the
303
+ These values are read in by Samus and get exposed as `$__CREDS_KEY` and
304
+ `$__CREDS_SECRET` respectively in Samus commands. You can provide other
305
+ metadata as well, which would be included as `$__CREDS_NAME` (for the
306
306
  line "NAME: value").
307
307
 
308
308
  ## Manifest File Format
@@ -337,7 +337,7 @@ Each action item has a single required property, "action", which is the command
337
337
  to execute for the action (found in `samus show-cmd`). An optional list of
338
338
  files are passed into the command as command line arguments, and the "arguments"
339
339
  property is a map of keys to values passed in as environment variables with a
340
- "\_" prefix (key "foo" is set as environment variable "_foo"). Optional
340
+ "\_" prefix (key "foo" is set as environment variable "\_foo"). Optional
341
341
  credentials are loaded from the credentials directory.
342
342
 
343
343
  ### Build Manifest Format
data/bin/samus CHANGED
File without changes
@@ -2,4 +2,4 @@
2
2
 
3
3
  set -e
4
4
  git gc # might as well GC before archiving .git
5
- tar cfz $__build_dir/$1 .git $(git ls-files)
5
+ tar cfz $__BUILD_DIR/$1 .git $(git ls-files)
@@ -1,3 +1,3 @@
1
1
  #!/bin/sh
2
2
 
3
- tar cfz $__build_dir/$1 $_paths
3
+ tar cfz $__BUILD_DIR/$1 $_PATHS
@@ -1,3 +1,3 @@
1
1
  #!/bin/sh
2
2
 
3
- zip -qr $__build_dir/$1 $_paths
3
+ zip -qr $__BUILD_DIR/$1 $_PATHS
@@ -16,5 +16,5 @@ def parse_changelog(changelog)
16
16
  end
17
17
 
18
18
  file = ARGV[0]
19
- dest = File.join(ENV["__build_dir"], ENV["_destination"] || file)
19
+ dest = File.join(ENV["__BUILD_DIR"], ENV["_DESTINATION"] || file)
20
20
  File.open(dest, "w") {|f| f.puts(parse_changelog(file)) }
@@ -1,3 +1,3 @@
1
1
  #!/bin/sh
2
2
 
3
- cp -r $* $__build_dir/$_destination
3
+ cp -r $* $__BUILD_DIR/$_DESTINATION
@@ -1,3 +1,3 @@
1
1
  #!/bin/sh
2
2
 
3
- mkdir -p $__build_dir/$*
3
+ mkdir -p $__BUILD_DIR/$*
File without changes
@@ -2,6 +2,6 @@
2
2
 
3
3
  ARGV.map {|f| Dir.glob(f) }.flatten.each do |file|
4
4
  contents = File.read(file)
5
- contents = contents.gsub(Regexp.new(ENV['_search']), ENV['_replace'])
5
+ contents = contents.gsub(Regexp.new(ENV['_SEARCH']), ENV['_REPLACE'])
6
6
  File.open(file, 'w') {|f| f.write(contents) }
7
7
  end
@@ -1,5 +1,5 @@
1
1
  #!/bin/sh
2
2
 
3
3
  set -e
4
- gem build $1
5
- mv ${1%.gemspec}-$_version.gem $__build_dir
4
+ ruby -S gem build $1
5
+ mv ${1%.gemspec}-$_VERSION.gem $__BUILD_DIR
@@ -1,3 +1,3 @@
1
1
  #!/bin/sh
2
2
 
3
- git archive --prefix="$_prefix" -o $__build_dir/$1 ${_ref-HEAD}
3
+ git archive --prefix="$_PREFIX" -o $__BUILD_DIR/$1 ${_REF-HEAD}
@@ -1,8 +1,8 @@
1
1
  #!/bin/sh
2
2
 
3
3
  set -e
4
- git clone -q --branch ${_branch-master} \
5
- ${_repository-.} $__build_dir/$1 2>/dev/null
4
+ git clone -q --branch ${_BRANCH-master} \
5
+ ${_REPOSITORY-.} $__BUILD_DIR/$1 2>${__DEVNULL-/dev/null}
6
6
 
7
7
  # preserve all previously configured remotes for publish actions
8
- cp ${_repository-.}/.git/config $__build_dir/$1/.git/config
8
+ cp ${_REPOSITORY-.}/.git/config $__BUILD_DIR/$1/.git/config
@@ -7,5 +7,5 @@ message=$($(dirname $0)/support/generate-commit-message.rb)
7
7
 
8
8
  git add $*
9
9
  git commit -m "$message"
10
- git tag ${_tag-v$_version}
11
- echo tag ${_tag-v$_version} >> $__restore_file
10
+ git tag ${_TAG-v$_VERSION}
11
+ echo tag ${_TAG-v$_VERSION} >> $__RESTORE_FILE
@@ -1,9 +1,9 @@
1
1
  #!/bin/sh
2
2
 
3
3
  set -e
4
- git fetch ${_remote-origin}
5
- git checkout -q $_branch
6
- echo branch $_branch $(git rev-parse HEAD) >> $__restore_file
7
- git rebase ${_remote-origin}/$_branch
8
- git merge $__build_branch -q -m "Merge release branch into $_branch" -s recursive -Xtheirs --ff
9
- git checkout -q $__build_branch
4
+ git fetch ${_REMOTE-origin}
5
+ git checkout -q $_BRANCH
6
+ echo branch $_BRANCH $(git rev-parse HEAD) >> $__RESTORE_FILE
7
+ git rebase ${_REMOTE-origin}/$_BRANCH
8
+ git merge $__BUILD_BRANCH -q -m "Merge release branch into $_BRANCH" -s recursive -Xtheirs --ff
9
+ git checkout -q $__BUILD_BRANCH
@@ -1,3 +1,3 @@
1
1
  #!/bin/sh
2
2
 
3
- make $_task
3
+ make $_TASK
@@ -1,4 +1,4 @@
1
1
  #!/bin/sh
2
2
 
3
3
  set -e
4
- mv `npm pack` $__build_dir/$1
4
+ mv `npm pack` $__BUILD_DIR/$1
@@ -1,3 +1,3 @@
1
1
  #!/bin/sh
2
2
 
3
- npm $_task $*
3
+ npm $_TASK $*
File without changes
@@ -1,3 +1,3 @@
1
1
  #!/bin/sh
2
2
 
3
- rake $_task
3
+ rake $_TASK
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
3
  set -e
4
- bakfile=${__restore_file}.$$.$RANDOM.bak
5
- mv $__restore_file $bakfile
6
- trap "mv $bakfile $__restore_file" 0
7
- samus build -o $__build_dir/$1 $_build_version ${_manifest}
4
+ bakfile=${__RESTORE_FILE}.$$.$RANDOM.bak
5
+ mv $__RESTORE_FILE $bakfile
6
+ trap "mv $bakfile $__RESTORE_FILE" 0
7
+ samus build -o $__BUILD_DIR/$1 $_BUILD_VERSION ${_MANIFEST}
@@ -5,13 +5,13 @@ def word_wrap(text)
5
5
  end
6
6
 
7
7
  def collect_issues
8
- out = `git log $(git describe --tags --abbrev=0)...HEAD -E --grep '#[0-9]+' 2>/dev/null`
8
+ out = `git log $(git describe --tags --abbrev=0)...HEAD -E --grep '#[0-9]+' 2>#{ENV['__DEVNULL']}`
9
9
  issues = out.scan(/((?:\S+\/\S+)?#\d+)/).flatten
10
10
  end
11
11
 
12
- message = ENV["_message"]
12
+ message = ENV["_MESSAGE"]
13
13
  if message.nil? || message.strip.empty?
14
- message = "Tag release v#{ENV["_version"]}"
14
+ message = "Tag release v#{ENV["_VERSION"]}"
15
15
 
16
16
  issues = collect_issues
17
17
  if issues.size > 0
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
- export AWS_ACCESS_KEY_ID=$__creds_key
4
- export AWS_SECRET_ACCESS_KEY=$__creds_secret
3
+ export AWS_ACCESS_KEY_ID=$__CREDS_KEY
4
+ export AWS_SECRET_ACCESS_KEY=$__CREDS_SECRET
5
5
 
6
6
  qty="$#"
7
7
  items=`python -c 'import sys, json; print json.dumps(sys.argv[1:])' $*`
@@ -9,6 +9,6 @@ ref=`date`
9
9
 
10
10
  aws configure set preview.cloudfront true
11
11
  aws cloudfront create-invalidation \
12
- --region $_region \
13
- --distribution-id $_distribution \
12
+ --region $_REGION \
13
+ --distribution-id $_DISTRIBUTION \
14
14
  --invalidation-batch "{\"Paths\":{\"Quantity\":$qty,\"Items\":$items},\"CallerReference\":\"$ref\"}"
@@ -2,6 +2,6 @@
2
2
 
3
3
  curl --fail --silent -X POST \
4
4
  -H "Content-Type: application/octet-stream" \
5
- -H "Authorization: $__creds_secret" \
5
+ -H "Authorization: $__CREDS_SECRET" \
6
6
  --data-binary @$* https://rubygems.org/api/v1/gems
7
7
  echo ""
@@ -14,11 +14,11 @@ esac
14
14
 
15
15
  cd $dir
16
16
  echo "-----BEGIN RSA PRIVATE KEY-----" > .sshkey
17
- echo "$__creds_key" | fold -w 65 >> .sshkey
17
+ echo "$__CREDS_KEY" | fold -w 65 >> .sshkey
18
18
  echo "-----END RSA PRIVATE KEY-----" >> .sshkey
19
19
  chmod 400 .sshkey
20
20
 
21
- for r in $_remotes; do
22
- ssh-agent sh -c "ssh-add .sshkey; git push $r $_refs"
21
+ for r in $_REMOTES; do
22
+ ssh-agent sh -c "ssh-add .sshkey; git push $r $_REFS"
23
23
  done
24
24
  cd $olddir
@@ -36,12 +36,12 @@ def https_request(opts = {})
36
36
  end
37
37
  end
38
38
 
39
- key = ENV["__creds_secret"]
40
- repository = ENV["_repository"]
39
+ key = ENV["__CREDS_SECRET"]
40
+ repository = ENV["_REPOSITORY"]
41
41
  tag = ENV["_tag"]
42
- changelog = ENV["_changelog"]
43
- title = ENV["_title"] || "Release #{tag}"
44
- out_file = ENV["_out_file"]
42
+ changelog = ENV["_CHANGELOG"]
43
+ title = ENV["_TITLE"] || "Release #{tag}"
44
+ out_file = ENV["_OUT_FILE"]
45
45
  assets = ARGV
46
46
 
47
47
  fail "Missing `repository`" unless repository
@@ -1,3 +1,3 @@
1
1
  #!/bin/sh
2
2
 
3
- npm publish --email=$__creds_key --_auth=$__creds_secret ./$*
3
+ npm publish --email=$__CREDS_KEY --_auth=$__CREDS_SECRET ./$*
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
- export AWS_ACCESS_KEY_ID=$__creds_key
4
- export AWS_SECRET_ACCESS_KEY=$__creds_secret
3
+ export AWS_ACCESS_KEY_ID=$__CREDS_KEY
4
+ export AWS_SECRET_ACCESS_KEY=$__CREDS_SECRET
5
5
 
6
6
  set -e
7
7
  for f in $*; do
@@ -9,5 +9,5 @@ for f in $*; do
9
9
  if [ -d $f ]; then
10
10
  recursive="--recursive"
11
11
  fi
12
- aws s3 cp $recursive --acl public-read --region $_region $f s3://$_bucket/$_prefix$_key
12
+ aws s3 cp $recursive --acl public-read --region $_REGION $f s3://$_BUCKET/$_PREFIX$_KEY
13
13
  done
File without changes
@@ -31,6 +31,10 @@ module Samus
31
31
  puts "[E] #{msg}"
32
32
  exit(1)
33
33
  end
34
+
35
+ def windows?
36
+ ::RbConfig::CONFIG['host_os'] =~ /mingw|win32|cygwin/ ? true : false
37
+ end
34
38
  end
35
39
 
36
40
  Samus.load_configuration_directory
@@ -27,20 +27,21 @@ module Samus
27
27
  build_branch = "samus-release/v#{version}"
28
28
  orig_branch = `git symbolic-ref -q --short HEAD`.chomp
29
29
 
30
- if `git diff --shortstat 2> /dev/null | tail -n1` != ''
30
+ if `git diff --shortstat 2> #{devnull} | tail -n1` != ''
31
31
  Samus.error 'Repository is dirty, it is too dangerous to continue.'
32
32
  end
33
33
 
34
- system "git checkout -qb #{build_branch} 2>/dev/null"
34
+ system "git checkout -qb #{build_branch} 2>#{devnull}"
35
35
  remove_restore_file
36
36
 
37
37
  Dir.mktmpdir do |build_dir|
38
38
  actions.map do |action|
39
39
  BuildAction.new(dry_run: dry_run, arguments: {
40
- '_restore_file' => RESTORE_FILE,
41
- '_build_dir' => build_dir,
42
- '_build_branch' => build_branch,
43
- 'version' => version
40
+ '_RESTORE_FILE' => RESTORE_FILE,
41
+ '_BUILD_DIR' => build_dir,
42
+ '_BUILD_BRANCH' => build_branch,
43
+ '_DEVNULL' => devnull,
44
+ 'VERSION' => version
44
45
  }).load(action)
45
46
  end.each do |action|
46
47
  next if action.skip
@@ -57,8 +58,8 @@ module Samus
57
58
  end
58
59
  ensure
59
60
  restore_git_repo
60
- system "git checkout -q #{orig_branch} 2>/dev/null"
61
- system "git branch -qD #{build_branch} 2>/dev/null"
61
+ system "git checkout -q #{orig_branch} 2>#{devnull}"
62
+ system "git branch -qD #{build_branch} 2>#{devnull}"
62
63
  end
63
64
 
64
65
  private
@@ -75,10 +76,11 @@ module Samus
75
76
  file_is_zipped = file =~ /\.(tar\.gz|tgz)$/
76
77
  if zip_release || file_is_zipped
77
78
  file += '.tar.gz' unless file_is_zipped
78
- system "tar cfz #{file} *"
79
+ system "tar cfz #{file.inspect} *"
79
80
  else
80
- system "mkdir -p #{file} && cp -r * #{file}"
81
+ system "mkdir #{file.inspect} && cp -R * #{file.inspect}"
81
82
  end
83
+ Samus.error "Failed to build release package" if $?.to_i != 0
82
84
  puts "[I] Built release package: #{File.basename(file)}"
83
85
  end
84
86
 
@@ -94,7 +96,7 @@ module Samus
94
96
  case type
95
97
  when 'tag'
96
98
  puts "[D] Removing tag #{branch}" if $DEBUG
97
- system "git tag -d #{branch} >/dev/null"
99
+ system "git tag -d #{branch} >#{devnull}"
98
100
  when 'branch'
99
101
  puts "[D] Restoring #{branch} to #{commit}" if $DEBUG
100
102
  system "git checkout -q #{branch}"
@@ -112,5 +114,9 @@ module Samus
112
114
  def version
113
115
  self.class.build_version
114
116
  end
117
+
118
+ def devnull
119
+ Samus.windows? ? 'NUL' : '/dev/null'
120
+ end
115
121
  end
116
122
  end
@@ -67,7 +67,7 @@ module Samus
67
67
  end
68
68
 
69
69
  def run(opts = {})
70
- env = (opts[:arguments] || {}).each_with_object({}) { |(k, v), h| h["_#{k}"] = v; }
70
+ env = (opts[:arguments] || {}).each_with_object({}) { |(k, v), h| h["_#{k.upcase}"] = v; }
71
71
  arguments = opts[:files] || []
72
72
  dry_run = opts[:dry_run] || false
73
73
  allow_fail = opts[:allow_fail] || false
@@ -77,9 +77,9 @@ module Samus
77
77
 
78
78
  return if dry_run
79
79
  exec_in_dir(pwd) do
80
- system(env, @full_path + ' ' + (arguments ? arguments.join(' ') : ''))
80
+ system(env, exe_type + @full_path + ' ' + (arguments ? arguments.join(' ') : ''))
81
81
  end
82
- report_error($CHILD_STATUS, allow_fail)
82
+ report_error($?, allow_fail)
83
83
  end
84
84
 
85
85
  def <=>(other)
@@ -98,6 +98,21 @@ module Samus
98
98
  dir ? Dir.chdir(dir, &block) : yield
99
99
  end
100
100
 
101
+ def exe_type
102
+ return '' unless Samus.windows?
103
+
104
+ if File.readlines(@full_path).first.chomp =~ /^#!(.+)/
105
+ path = $1
106
+ if path == '/bin/sh'
107
+ 'sh '
108
+ elsif path == '/usr/bin/env ruby'
109
+ 'ruby '
110
+ else
111
+ path + ' '
112
+ end
113
+ end
114
+ end
115
+
101
116
  def load_full_path
102
117
  path = self.class.command_paths.find do |ipath|
103
118
  File.exist?(File.join(ipath, stage, name))
@@ -29,6 +29,10 @@ module Samus
29
29
 
30
30
  data.split(/\r?\n/).each do |line|
31
31
  name, value = *line.strip.split(':')
32
+ if value.nil?
33
+ Samus.error "Failed to parse credential from #{@file} (exec bit: #{File.executable?(@file)})"
34
+ end
35
+
32
36
  hsh["_creds_#{name.strip.downcase}"] = value.strip
33
37
  end
34
38
 
@@ -14,7 +14,7 @@ module Samus
14
14
  actions.map do |action|
15
15
  PublishAction.new(
16
16
  dry_run: dry_run,
17
- arguments: { 'version' => manifest['version'] }
17
+ arguments: { 'VERSION' => manifest['version'] }
18
18
  ).load(action)
19
19
  end.each(&:run)
20
20
  end
@@ -1,3 +1,3 @@
1
- module Samus
2
- VERSION = '1.6.3'.freeze
3
- end
1
+ module Samus
2
+ VERSION = '2.0.0'.freeze
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: samus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.3
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loren Segal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-20 00:00:00.000000000 Z
11
+ date: 2018-08-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: lsegal@soen.ca
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 2.7.6
110
+ rubygems_version: 2.6.12
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: Samus helps you release Open Source Software.