Skip to content

Commit

Permalink
Build: Switch to standard rubygems.org
Browse files Browse the repository at this point in the history
The RubyGems registry offered by GitHub Packages is not public,
it requires installers to specify authentication tokens even for
"public" packages, which is imho unreasonably difficult for something
this trivial.

Switch to the public registry instead.
  • Loading branch information
Krinkle committed Sep 6, 2021
1 parent e81c9ab commit 98e4c10
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/gem.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,19 @@ on:
jobs:
gem-push:
runs-on: ubuntu-latest
permissions:
# https://docs.github.com/en/actions/reference/authentication-in-a-workflow
packages: write
steps:
- uses: actions/checkout@v2
- name: Publish Gem package
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GEM_HOST_API_KEY: "${{ secrets.RUBYGEMS_API_PUSH }}"
# Inspired by https://github.com/bodyshopbidsdotcom/gh-action-publish-gem-on-tag/blob/1.0.1/entrypoint.sh
# Docs: https://guides.rubygems.org/command-reference/#gem-push
run: |
GIT_VERSION=$(echo "$GITHUB_REF" | cut -d'/' -f 3-)
SPEC_VERSION=$(ruby -e 'require "rubygems"; gemspec = Dir.entries(".").find { |file| file =~ /.*\.gemspec/ }; spec = Gem::Specification::load(gemspec); puts spec.version')
if [[ "$GIT_VERSION" != "v${SPEC_VERSION}" ]]; then
echo "Ignoring, git tag version differs from gem spec version."
exit 2;
fi
mkdir -p ~/.gem
echo ":github: Bearer ${GITHUB_TOKEN}" > ~/.gem/credentials
chmod 600 ~/.gem/credentials
gem build *.gemspec
gem push --key github --host "https://rubygems.pkg.github.com/${{ github.repository_owner }}" *.gem
gem push *.gem

0 comments on commit 98e4c10

Please sign in to comment.