Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,8 @@ You're encouraged to contribute to this library. See [CONTRIBUTING](CONTRIBUTING
Copyright (c) 2009-2018 Evan Sagge and Contributors.

MIT License. See [LICENSE](LICENSE) for details.

## Pushing new version to Github Packages

1. Load your personal access token in environment as `GITHUB_GLOOKO_BUNDLE_PASSWORD`
2. Run `docker compose run gem_publish`
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Should be used for development only (as this project is only a library)
version: '3.7'
services:
gem_publish:
build:
context: ./
dockerfile: ./docker/gem/Dockerfile
volumes:
- .:/app:cached
environment:
- GEMSPEC_FILE=mongoid-rspec.gemspec
- GITHUB_GLOOKO_BUNDLE_PASSWORD=$GITHUB_GLOOKO_BUNDLE_PASSWORD

volumes:
bundle:
20 changes: 20 additions & 0 deletions docker/gem/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ruby:2.7.6-bullseye

# rails/gem dependencies and development stuff
RUN set -ex \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
less \
vim \
&& rm -rf /var/lib/apt/lists/*

RUN echo 'Etc/GMT-13' > /etc/timezone \
&& rm /etc/localtime \
&& dpkg-reconfigure -f noninteractive tzdata

ENV APP_PATH /app
RUN mkdir -p $APP_PATH
WORKDIR $APP_PATH
COPY . .

CMD ["./docker/gem/scripts/publish.sh"]
23 changes: 23 additions & 0 deletions docker/gem/scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh

set -u
set -e
set -x

GEM_TO_RELEASE=/tmp/release.gem
GEMRC_FILE=$HOME/.gem/credentials

mkdir -p "`dirname "${GEMRC_FILE}"`"
mkdir -p "`dirname "${GEM_TO_RELEASE}"`"

set +e && rm ${GEM_TO_RELEASE} 2> /dev/null && set -e

cat >> "${GEMRC_FILE}" << EOF
---
:github: Bearer ${GITHUB_GLOOKO_BUNDLE_PASSWORD}
EOF

chmod 0600 $GEMRC_FILE

gem build ${GEMSPEC_FILE} --output=${GEM_TO_RELEASE}
gem push --key github --host https://rubygems.pkg.github.com/glooko --verbose ${GEM_TO_RELEASE}
7 changes: 7 additions & 0 deletions mongoid-rspec.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ Gem::Specification.new do |s|
s.description = 'RSpec matches for Mongoid models, including association and validation matchers.'
s.license = 'MIT'

if s.respond_to?(:metadata)
s.metadata["allowed_push_host"] = "https://rubygems.pkg.github.com/glooko"
else
raise "RubyGems 2.0 or newer is required to protect against " \
"public gem pushes."
end

s.required_ruby_version = '>= 2.2'
s.required_rubygems_version = '>= 1.3.6'
s.rubyforge_project = 'mongoid-rspec'
Expand Down