Skip to content

Commit

Permalink
Build: Publish theme as package
Browse files Browse the repository at this point in the history
By publishing Amethyst as a package, and using it by name in individual
website repos (instead of by its raw Git repo URL), the dependencies
will be managed automatically, which should make it easier to get
started, and more importantly, easier to update.

(The initial start is equally easy as it involved copying the example
boilerplate, but the steps after that are less obvious).
  • Loading branch information
Krinkle committed Sep 6, 2021
1 parent 2522216 commit e81c9ab
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 29 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/gem.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Gem
on:
push:
tags:
- 'v*.*.*'

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 }}"
# Inspired by https://github.com/bodyshopbidsdotcom/gh-action-publish-gem-on-tag/blob/1.0.1/entrypoint.sh
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
14 changes: 1 addition & 13 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
source "https://rubygems.org"
ruby RUBY_VERSION

gem "jekyll", "~> 4.2.0"
gem "kramdown-parser-gfm", "1.1.0"
gem "jekyll-redirect-from", "~> 0.16.0", group: :jekyll_plugins
gem "jekyll-relative-links", "~> 0.6.1", group: :jekyll_plugins
gem "jekyll-remote-theme", "~> 0.4.3", group: :jekyll_plugins
gemspec

# Blog
gem "jekyll-feed", "~> 0.15.1", group: :jekyll_plugins
gem "jekyll-archives", "~> 2.2.1", group: :jekyll_plugins

# Search
gem "jekyll-algolia", "~> 1.7.0", group: :jekyll_plugins

# Temporary fix until there is a release with https://github.com/jekyll/jekyll/pull/8524/
gem "webrick", "~> 1.7"
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ Requirements:
* [Ruby](https://www.ruby-lang.org/) (tested with Ruby 2.7+)
* [Bundler](https://bundler.io/) (if missing, install with `gem install bundler`)

To install Jekyll and plugins the first time:

```shell
bundle install
```

To update Jekyll and any plugins (e.g. after changing `Gemfile`):
To install or update Jekyll and plugins:

```shell
bundle update
Expand Down
10 changes: 1 addition & 9 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ baseurl: /jekyll-theme-amethyst
permalink: /:year/:month/:day/:title/
lang: en
timezone: UTC
# Disable theme inheritance since this repo contains its own theme top-level theme.
# This isn't needed for plain Jekyll, but because we use github-pages as basis
# we otherwise inherit from the 'primer' theme.
# This is a problem because, Jekyll/Sass/Primer fails to compile by default, yay.
# - https://github.com/jekyll/jekyll/issues/7426
# - https://github.com/jekyll/jekyll/issues/4268
# - https://github.com/sindresorhus/gulp-ruby-sass/issues/232
# – Workaround: https://github.com/github/pages-gem/issues/613
theme: null
# Files that will not be converted or published
exclude:
# Exclude repo docs from site output and search index
Expand All @@ -45,6 +36,7 @@ exclude:
# Amethyst theme options are documented at:
# https://github.com/qunitjs/jekyll-theme-amethyst/blob/main/docs/config.md
#
theme: jekyll-theme-amethyst
amethyst:
edituri_base: https://github.com/qunitjs/jekyll-theme-amethyst/blob/main/
release_base: https://github.com/qunitjs/qunit/releases/tag/
Expand Down
23 changes: 23 additions & 0 deletions amethyst.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Gem::Specification.new do |spec|
spec.name = "jekyll-theme-amethyst"
spec.version = "0.1.1"
spec.summary = "https://github.com/qunitjs/jekyll-theme-amethyst"
spec.authors = ["Timo Tijhof", "Trent Willis"]
spec.files = `git ls-files -z`.split("\x0")

spec.license = "MIT"
spec.homepage = "https://github.com/qunitjs/jekyll-theme-amethyst"

spec.metadata["plugin_type"] = "theme"
spec.require_paths = ["lib"]

spec.add_runtime_dependency "jekyll", ">= 4.2", "< 5.0"
spec.add_runtime_dependency "kramdown-parser-gfm", "~> 1.1.0"
spec.add_runtime_dependency "jekyll-redirect-from", "~> 0.16.0"
spec.add_runtime_dependency "jekyll-relative-links", "~> 0.6.1"
# For blog
spec.add_runtime_dependency "jekyll-feed", "~> 0.15.1"
spec.add_runtime_dependency "jekyll-archives", "~> 2.2.1"
# Temporary fix until there is a release with https://github.com/jekyll/jekyll/pull/8524/
spec.add_runtime_dependency "webrick", "~> 1.7"
end

0 comments on commit e81c9ab

Please sign in to comment.