Skip to content

Commit b4c6148

Browse files
authored
simplify the gem build/release process (#7)
Since we're not distributing a pre-built binary, we don't need Docker to prepare a build environment. Since we're not doing anything with Java (yet), we can get rid of those commented parts. And we can use the Gem::Package API to verify that a gem is signed.
1 parent e67cd9f commit b4c6148

File tree

5 files changed

+31
-76
lines changed

5 files changed

+31
-76
lines changed

Rakefile

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,34 @@
11
require 'bundler'
22
require 'bundler/gem_tasks'
3-
require 'rake/extensiontask'
3+
require 'rubygems/package'
4+
require 'rubygems/security/policies'
45

6+
def signed_gem?(path_to_gem)
7+
Gem::Package.new(path_to_gem, Gem::Security::HighSecurity).verify
8+
true
9+
rescue Gem::Security::Exception => e
10+
false
11+
end
12+
13+
desc 'Compiles the libmongocrypt library'
514
task :compile do
6-
chdir "ext/libmongocrypt" do
7-
ruby "extconf.rb"
15+
chdir 'ext/libmongocrypt' do
16+
ruby 'extconf.rb'
17+
end
18+
end
19+
20+
desc 'Verifies that all built gems in pkg/ are valid'
21+
task :verify do
22+
gems = Dir['pkg/*.gem']
23+
if gems.empty?
24+
puts 'There are no gems in pkg/ to verify'
25+
else
26+
gems.each do |gem|
27+
if signed_gem?(gem)
28+
puts "#{gem} is signed"
29+
else
30+
abort "#{gem} is not signed"
31+
end
32+
end
833
end
934
end

release.sh

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,14 @@ VERSION=`ruby -Ilib -r$VERSION_REQUIRE -e "puts $VERSION_CONSTANT_NAME"`
1717
echo "Releasing $NAME $VERSION"
1818
echo
1919

20-
for variant in mri; do
21-
docker build -f release/$variant/Dockerfile -t $RELEASE_NAME-$variant .
22-
23-
docker kill $RELEASE_NAME-$variant || true
24-
docker container rm $RELEASE_NAME-$variant || true
25-
26-
docker run -d --name $RELEASE_NAME-$variant -it $RELEASE_NAME-$variant
27-
28-
docker exec $RELEASE_NAME-$variant /app/release/$variant/build.sh
29-
30-
if test $variant = jruby; then
31-
docker cp $RELEASE_NAME-$variant:/app/pkg/$NAME-$VERSION-java.gem .
32-
else
33-
docker cp $RELEASE_NAME-$variant:/app/pkg/$NAME-$VERSION.gem .
34-
fi
35-
36-
docker kill $RELEASE_NAME-$variant
37-
done
20+
./release/mri/build.sh
21+
cp pkg/$NAME-$VERSION.gem .
3822

3923
echo
4024
echo Built: $NAME-$VERSION.gem
41-
#echo Built: $NAME-$VERSION-java.gem
4225
echo
4326

4427
git tag -a v$VERSION -m "Tagging release: $VERSION"
4528
git push origin v$VERSION
4629

4730
gem push $NAME-$VERSION.gem
48-
#gem push $NAME-$VERSION-java.gem

release/mri/Dockerfile

Lines changed: 0 additions & 10 deletions
This file was deleted.

release/mri/build.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ rm -f *.lock
66
rm -f *.gem pkg/*.gem
77
# Uses bundler gem tasks, outputs the built gem file to pkg subdir.
88
bundle install
9-
bundle exec rake build
10-
/app/release/verify-signature.sh pkg/*.gem
9+
bundle exec rake build verify

release/verify-signature.sh

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)