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 +5 -5
- data/CHANGELOG.md +7 -0
- data/README.md +13 -13
- data/bin/samus +0 -0
- data/commands/build/archive-git-full +1 -1
- data/commands/build/archive-tgz +1 -1
- data/commands/build/archive-zip +1 -1
- data/commands/build/changelog-parse +1 -1
- data/commands/build/fs-copy +1 -1
- data/commands/build/fs-mkdir +1 -1
- data/commands/build/fs-rmrf +0 -0
- data/commands/build/fs-sedfiles +1 -1
- data/commands/build/gem-build +2 -2
- data/commands/build/git-archive +1 -1
- data/commands/build/git-clone +3 -3
- data/commands/build/git-commit +2 -2
- data/commands/build/git-merge +6 -6
- data/commands/build/make-task +1 -1
- data/commands/build/npm-pack +1 -1
- data/commands/build/npm-task +1 -1
- data/commands/build/npm-test +0 -0
- data/commands/build/rake-task +1 -1
- data/commands/build/samus-build +4 -4
- data/commands/build/support/generate-commit-message.rb +3 -3
- data/commands/publish/cf-invalidate +4 -4
- data/commands/publish/gem-push +1 -1
- data/commands/publish/git-push +3 -3
- data/commands/publish/github-release +5 -5
- data/commands/publish/npm-publish +1 -1
- data/commands/publish/s3-put +3 -3
- data/commands/publish/samus-publish +0 -0
- data/lib/samus.rb +4 -0
- data/lib/samus/builder.rb +17 -11
- data/lib/samus/command.rb +18 -3
- data/lib/samus/credentials.rb +4 -0
- data/lib/samus/publisher.rb +1 -1
- data/lib/samus/version.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dfd222e26ed2614c6604f9323ee6351725fa5b06
|
4
|
+
data.tar.gz: 6c06fedbabcc7ea4579c15028f9ac5efdb19f61e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1c024b9d0673fea1b125c8d709fceb0ee4a36b2e4086472894fcc18e6179803d53c591635f7de61a775e05f3e0bb88546d3847a6bc43ceea13a500d8f124f6c
|
7
|
+
data.tar.gz: 865798d531d3bab1c5315ffc0456ce21fc7e1db35a22b220b674167abf4dc89886f4d61330305346568338670882fe01654f5ff2c271f2b19addc6c5b232e590
|
data/CHANGELOG.md
CHANGED
@@ -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 $
|
224
|
+
rake $_TASK
|
225
225
|
```
|
226
226
|
|
227
|
-
The `$
|
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
|
-
|
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
|
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
|
-
|
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
|
-
|
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
|
-
|
276
|
+
- The first line of the help file is used as the summary in the `show-cmd`
|
277
277
|
listing.
|
278
|
-
|
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
|
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 `$
|
304
|
-
`$
|
305
|
-
metadata as well, which would be included as `$
|
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
|
data/commands/build/archive-tgz
CHANGED
data/commands/build/archive-zip
CHANGED
data/commands/build/fs-copy
CHANGED
data/commands/build/fs-mkdir
CHANGED
data/commands/build/fs-rmrf
CHANGED
File without changes
|
data/commands/build/fs-sedfiles
CHANGED
@@ -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['
|
5
|
+
contents = contents.gsub(Regexp.new(ENV['_SEARCH']), ENV['_REPLACE'])
|
6
6
|
File.open(file, 'w') {|f| f.write(contents) }
|
7
7
|
end
|
data/commands/build/gem-build
CHANGED
data/commands/build/git-archive
CHANGED
data/commands/build/git-clone
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/bin/sh
|
2
2
|
|
3
3
|
set -e
|
4
|
-
git clone -q --branch ${
|
5
|
-
${
|
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 ${
|
8
|
+
cp ${_REPOSITORY-.}/.git/config $__BUILD_DIR/$1/.git/config
|
data/commands/build/git-commit
CHANGED
data/commands/build/git-merge
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/bin/sh
|
2
2
|
|
3
3
|
set -e
|
4
|
-
git fetch ${
|
5
|
-
git checkout -q $
|
6
|
-
echo branch $
|
7
|
-
git rebase ${
|
8
|
-
git merge $
|
9
|
-
git checkout -q $
|
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
|
data/commands/build/make-task
CHANGED
data/commands/build/npm-pack
CHANGED
data/commands/build/npm-task
CHANGED
data/commands/build/npm-test
CHANGED
File without changes
|
data/commands/build/rake-task
CHANGED
data/commands/build/samus-build
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/bin/sh
|
2
2
|
|
3
3
|
set -e
|
4
|
-
bakfile=${
|
5
|
-
mv $
|
6
|
-
trap "mv $bakfile $
|
7
|
-
samus build -o $
|
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
|
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["
|
12
|
+
message = ENV["_MESSAGE"]
|
13
13
|
if message.nil? || message.strip.empty?
|
14
|
-
message = "Tag release v#{ENV["
|
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=$
|
4
|
-
export AWS_SECRET_ACCESS_KEY=$
|
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 $
|
13
|
-
--distribution-id $
|
12
|
+
--region $_REGION \
|
13
|
+
--distribution-id $_DISTRIBUTION \
|
14
14
|
--invalidation-batch "{\"Paths\":{\"Quantity\":$qty,\"Items\":$items},\"CallerReference\":\"$ref\"}"
|
data/commands/publish/gem-push
CHANGED
data/commands/publish/git-push
CHANGED
@@ -14,11 +14,11 @@ esac
|
|
14
14
|
|
15
15
|
cd $dir
|
16
16
|
echo "-----BEGIN RSA PRIVATE KEY-----" > .sshkey
|
17
|
-
echo "$
|
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 $
|
22
|
-
ssh-agent sh -c "ssh-add .sshkey; git push $r $
|
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["
|
40
|
-
repository = ENV["
|
39
|
+
key = ENV["__CREDS_SECRET"]
|
40
|
+
repository = ENV["_REPOSITORY"]
|
41
41
|
tag = ENV["_tag"]
|
42
|
-
changelog = ENV["
|
43
|
-
title = ENV["
|
44
|
-
out_file = ENV["
|
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
|
data/commands/publish/s3-put
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/bin/sh
|
2
2
|
|
3
|
-
export AWS_ACCESS_KEY_ID=$
|
4
|
-
export AWS_SECRET_ACCESS_KEY=$
|
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 $
|
12
|
+
aws s3 cp $recursive --acl public-read --region $_REGION $f s3://$_BUCKET/$_PREFIX$_KEY
|
13
13
|
done
|
File without changes
|
data/lib/samus.rb
CHANGED
data/lib/samus/builder.rb
CHANGED
@@ -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>
|
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
|
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
|
-
'
|
41
|
-
'
|
42
|
-
'
|
43
|
-
'
|
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
|
61
|
-
system "git branch -qD #{build_branch} 2
|
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
|
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}
|
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
|
data/lib/samus/command.rb
CHANGED
@@ -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(
|
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))
|
data/lib/samus/credentials.rb
CHANGED
@@ -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
|
|
data/lib/samus/publisher.rb
CHANGED
data/lib/samus/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Samus
|
2
|
-
VERSION = '
|
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:
|
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-
|
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.
|
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.
|