Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GW-21578_github_gems #5

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
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 @@ -109,3 +109,8 @@ a.version # => 1
* Nick Muerdter
* Felipe Rodrigues
* Felipe Rodrigues de Almeida

## 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_delorean.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_delorean.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ Gem::Specification.new do |gem|
'embedded documents.'
gem.homepage = ''

if gem.respond_to?(:metadata)
gem.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

gem.files = `git ls-files`.split($/)
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
Expand Down