diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..e9293605 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: + - package-ecosystem: "bundler" + directory: "/" + schedule: + interval: "weekly" + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml new file mode 100644 index 00000000..2e145347 --- /dev/null +++ b/.github/workflows/publish-docker.yml @@ -0,0 +1,35 @@ +name: Publish to Docker +on: + push: + branches: [ master ] + tags: [ 'v*' ] + pull_request: + branches: [ master ] + +env: + DOCKER_TAG_IMAGE: "ghcr.io/github/pages-gem" + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Get Docker Metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.DOCKER_TAG_IMAGE }} + + - name: Build Docker Image + run: | + docker build -t ${{ steps.meta.outputs.tags }} -f Dockerfile . + + - name: Push to Container Registry + if: github.event_name != 'pull_request' + run: | + echo ${{ secrets.GITHUB_TOKEN }} | docker login -u ${{ github.actor }} https://ghcr.io --password-stdin + docker push ${{ steps.meta.outputs.tags }} + diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index e5609c8c..f1948348 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -7,11 +7,10 @@ jobs: strategy: matrix: ruby: - - 2.5 - 2.6 - 2.7 steps: - - uses: actions/checkout@master + - uses: actions/checkout@v3 - name: script/cibuild-docker run: script/cibuild-docker env: diff --git a/.gitignore b/.gitignore index 1427e559..1b85dd91 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ .sass-cache CNAME test-site/ +vendor/ +tmp/ \ No newline at end of file diff --git a/.ruby-version b/.ruby-version index 860487ca..2c9b4ef4 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.1 +2.7.3 diff --git a/Dockerfile b/Dockerfile index 5fe323f8..6b84ef29 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG RUBY_VERSION=2.7.1 +ARG RUBY_VERSION=2.7.3 FROM ruby:$RUBY_VERSION RUN apt-get update \ diff --git a/Dockerfile.alpine b/Dockerfile.alpine index b5498820..3c572c2f 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -1,4 +1,4 @@ -FROM ruby:alpine +FROM ruby:2.7.3-alpine RUN apk update && apk add --no-cache \ git diff --git a/Makefile b/Makefile index e1e2b1eb..7a49e56f 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ shell: /bin/bash # Spawn a server. Specify the path to the SITE directory by -# exposing it using `expose SITE="../path-to-jekyll-site"` prior to calling or +# exposing it using `export SITE="../path-to-jekyll-site"` prior to calling or # by prepending it to the make rule e.g.: `SITE=../path-to-site make server` server: test -d "${SITE}" || \ diff --git a/README.md b/README.md index 8ed8130f..4187339b 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ To update to the latest version of Jekyll and associated dependencies, simply ru ## Project Goals -The goal of the GitHub Pages gem is to help GitHub Pages users bootstrap and maintain a Jekyll build environment that most closely matches the GitHub pages build environment. The GitHub Pages gem relies on explicit requirements shared between both users' computers and the build servers to ensure that the result of a user's local build is consistently also the result of the server's build. +The goal of the GitHub Pages gem is to help GitHub Pages users bootstrap and maintain a Jekyll build environment that most closely matches the GitHub Pages build environment. The GitHub Pages gem relies on explicit requirements shared between both users' computers and the build servers to ensure that the result of a user's local build is consistently also the result of the server's build. Additional tools, such as tools that integrate with the GitHub API to make managing GitHub Pages sites easier are not the primary goal, but may be within the project's scope. @@ -113,6 +113,18 @@ See [all releases](https://github.com/github/pages-gem/releases). To release a new version of this gem, run `script/release` from the `master` branch. +This will create and tag the release. + +It will also create prs in the relevant repos and assign them to you. It is your responsibility to + +1. update the version of the gem in those repos +2. deploy those services as needed + +The relevant repos are: +1. [github-pages](https://github.com/github/pages) +2. [jekyll-build-pages](https://github.com/actions/jekyll-build-pages/blob/main/Gemfile) +3. [pages.github.com](https://github.com/github/pages.github.com) + ## License Distributed under the [MIT License](LICENSE). diff --git a/bin/github-pages b/bin/github-pages index 055dfaf1..d91bf9d4 100755 --- a/bin/github-pages +++ b/bin/github-pages @@ -56,4 +56,18 @@ Mercenary.program(:"github-pages") do |p| end end end + + p.command(:build) do |c| + c.syntax "build [options]" + c.description "Builds your Jekyll site" + + c.option 'verbose', '--verbose', 'Verbose logging' + c.option 'source', '--source DIR', 'From where to collect the source files' + c.option 'destination', '--destination DIR', 'To where the compiled files should be written' + c.option 'future', '--future', 'Publishes posts with a future date' + + c.action do |_, options| + Jekyll::Commands::Build.process(options) + end + end end diff --git a/github-pages.gemspec b/github-pages.gemspec index 0e0c5b90..3602f4f8 100644 --- a/github-pages.gemspec +++ b/github-pages.gemspec @@ -25,7 +25,7 @@ Gem::Specification.new do |s| end s.add_dependency("mercenary", "~> 0.3") - s.add_dependency("nokogiri", ">= 1.10.4", "< 2.0") + s.add_dependency("nokogiri", ">= 1.13.6", "< 2.0") s.add_dependency("terminal-table", "~> 1.4") s.add_development_dependency("jekyll_test_plugin_malicious", "~> 0.2") s.add_development_dependency("pry", "~> 0.10") diff --git a/lib/github-pages/configuration.rb b/lib/github-pages/configuration.rb index 3b1932d7..0d7ee434 100644 --- a/lib/github-pages/configuration.rb +++ b/lib/github-pages/configuration.rb @@ -62,13 +62,6 @@ class Configuration }, }.freeze - # These configuration settings have corresponding instance variables on - # Jekyll::Site and need to be set properly when the config is updated. - CONFIGS_WITH_METHODS = %w( - safe lsi highlighter baseurl exclude include future unpublished - show_drafts limit_posts keep_files - ).freeze - class << self def processed?(site) site.instance_variable_get(:@_github_pages_processed) == true @@ -107,6 +100,7 @@ def effective_config(user_config) # Allow theme to be explicitly disabled via "theme: null" config["theme"] = user_config["theme"] if user_config.key?("theme") + migrate_theme_to_remote_theme(config) exclude_cname(config) # Merge overwrites into user config @@ -152,10 +146,15 @@ def restrict_and_config_markdown_processor(config) config["markdown"] = "CommonMarkGhPages" config["commonmark"] = { "extensions" => %w(table strikethrough autolink tagfilter), - "options" => %w(footnotes), + "options" => %w(unsafe footnotes), } end + # If the user has set a 'theme', then see if we can automatically use remote theme instead. + def migrate_theme_to_remote_theme(config) + # This functionality has been rolled back due to complications with jekyll-remote-theme. + end + # If the user's 'exclude' config is the default, also exclude the CNAME def exclude_cname(config) return unless config["exclude"].eql? Jekyll::Configuration::DEFAULTS["exclude"] diff --git a/lib/github-pages/dependencies.rb b/lib/github-pages/dependencies.rb index 63315d34..dba5cc26 100644 --- a/lib/github-pages/dependencies.rb +++ b/lib/github-pages/dependencies.rb @@ -7,18 +7,18 @@ module GitHubPages class Dependencies VERSIONS = { # Jekyll - "jekyll" => "3.9.0", + "jekyll" => "3.9.3", "jekyll-sass-converter" => "1.5.2", # Converters - "kramdown" => "2.3.0", + "kramdown" => "2.3.2", "kramdown-parser-gfm" => "1.1.0", - "jekyll-commonmark-ghpages" => "0.1.6", + "jekyll-commonmark-ghpages" => "0.4.0", # Misc - "liquid" => "4.0.3", - "rouge" => "3.23.0", - "github-pages-health-check" => "1.16.1", + "liquid" => "4.0.4", + "rouge" => "3.26.0", + "github-pages-health-check" => "1.17.9", # Plugins "jekyll-redirect-from" => "0.16.0", @@ -27,10 +27,11 @@ class Dependencies "jekyll-gist" => "1.5.0", "jekyll-paginate" => "1.1.0", "jekyll-coffeescript" => "1.1.1", - "jekyll-seo-tag" => "2.6.1", + "jekyll-seo-tag" => "2.8.0", "jekyll-github-metadata" => "2.13.0", "jekyll-avatar" => "0.7.0", - "jekyll-remote-theme" => "0.4.2", + "jekyll-remote-theme" => "0.4.3", + "jekyll-include-cache" => "0.2.1", # Plugins to match GitHub.com Markdown "jemoji" => "0.12.0", diff --git a/lib/github-pages/plugins.rb b/lib/github-pages/plugins.rb index 78db91af..afabca6f 100644 --- a/lib/github-pages/plugins.rb +++ b/lib/github-pages/plugins.rb @@ -48,21 +48,39 @@ class Plugins # Themes THEMES = { - "jekyll-swiss" => "1.0.0", "minima" => "2.5.1", - "jekyll-theme-primer" => "0.5.4", - "jekyll-theme-architect" => "0.1.1", - "jekyll-theme-cayman" => "0.1.1", - "jekyll-theme-dinky" => "0.1.1", - "jekyll-theme-hacker" => "0.1.2", - "jekyll-theme-leap-day" => "0.1.1", - "jekyll-theme-merlot" => "0.1.1", - "jekyll-theme-midnight" => "0.1.1", - "jekyll-theme-minimal" => "0.1.1", - "jekyll-theme-modernist" => "0.1.1", - "jekyll-theme-slate" => "0.1.1", - "jekyll-theme-tactile" => "0.1.1", - "jekyll-theme-time-machine" => "0.1.1", + "jekyll-swiss" => "1.0.0", + "jekyll-theme-primer" => "0.6.0", + "jekyll-theme-architect" => "0.2.0", + "jekyll-theme-cayman" => "0.2.0", + "jekyll-theme-dinky" => "0.2.0", + "jekyll-theme-hacker" => "0.2.0", + "jekyll-theme-leap-day" => "0.2.0", + "jekyll-theme-merlot" => "0.2.0", + "jekyll-theme-midnight" => "0.2.0", + "jekyll-theme-minimal" => "0.2.0", + "jekyll-theme-modernist" => "0.2.0", + "jekyll-theme-slate" => "0.2.0", + "jekyll-theme-tactile" => "0.2.0", + "jekyll-theme-time-machine" => "0.2.0", }.freeze + + # Themes to convert to remote themes + THEMES_TO_CONVERT_TO_REMOTE_THEMES = { + "jekyll-swiss" => "broccolini/swiss", + "jekyll-theme-primer" => "pages-themes/primer@v0.6.0", + "jekyll-theme-architect" => "pages-themes/architect@v0.2.0", + "jekyll-theme-cayman" => "pages-themes/cayman@v0.2.0", + "jekyll-theme-dinky" => "pages-themes/dinky@v0.2.0", + "jekyll-theme-hacker" => "pages-themes/hacker@v0.2.0", + "jekyll-theme-leap-day" => "pages-themes/leap-day@v0.2.0", + "jekyll-theme-merlot" => "pages-themes/merlot@v0.2.0", + "jekyll-theme-midnight" => "pages-themes/midnight@v0.2.0", + "jekyll-theme-minimal" => "pages-themes/minimal@v0.2.0", + "jekyll-theme-modernist" => "pages-themes/modernist@v0.2.0", + "jekyll-theme-slate" => "pages-themes/slate@v0.2.0", + "jekyll-theme-tactile" => "pages-themes/tactile@v0.2.0", + "jekyll-theme-time-machine" => "pages-themes/time-machine@v0.2.0", + } end end diff --git a/lib/github-pages/version.rb b/lib/github-pages/version.rb index f2efb1b4..a38e8a6b 100644 --- a/lib/github-pages/version.rb +++ b/lib/github-pages/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module GitHubPages - VERSION = 209 + VERSION = 228 end diff --git a/script/cibuild-docker b/script/cibuild-docker index 37909b1b..7a6ca87d 100755 --- a/script/cibuild-docker +++ b/script/cibuild-docker @@ -3,7 +3,7 @@ set -ex # Set the ruby version in the Action definition matrix. -: "${RUBY_VERSION:="2.7.1"}" +: "${RUBY_VERSION:="2.7.3"}" docker build --build-arg "RUBY_VERSION=$RUBY_VERSION" -t github-pages . docker run --rm --workdir /src/gh/pages-gem github-pages script/cibuild diff --git a/script/release b/script/release index a67084b9..09310e6a 100755 --- a/script/release +++ b/script/release @@ -1,8 +1,13 @@ #!/bin/sh + # Tag and push a release. set -e +# check that gh is installed and logged in + +gh auth status -h github.com + # Make sure we're in the project root. cd $(dirname "$0")/.. @@ -39,4 +44,50 @@ git fetch -t origin # Tag it and bag it. gem push github-pages-*.gem && git tag "$tag" && - git push origin master && git push origin "$tag" +git push origin master && git push origin "$tag" + +# create a new release on github +gh release create "$tag" --notes "Automated release for $tag" + + +# create a tmp folder +mkdir -p tmp + +#for each dependent repo, create a new branch an a blank pr. +# first get the sha of main for each repo + +gh_pages_sha=`gh api repos/github/pages/git/refs/heads/master | jq '. | .object.sha'` +jekyll_sha=`gh api repos/actions/jekyll-build-pages/git/refs/heads/main | jq '. | .object.sha'` + +# then create the branches + +gh api repos/github/pages/git/refs -F "sha"="$gh_pages_sha" -F "ref"="refs/heads/pages-gem-release-$tag" +gh api repos/github/pages/git/refs -F "sha"="$jekyll_sha" -F "ref"="refs/heads/pages-gem-release-$tag" + +#then we need the tree object so we can create a commit using the api + +gh_pages_tree=`gh api repos/github/pages/git/commits/$gh_pages_sha | jq '. | .tree.sha'` +jekyll_tree=`gh api repos/github/actions/jekyll-build-pages/commits/$jekyll_sha | jq '. | .tree.sha'` + +# create the input file for the commit. We have to do this because the F flag doesn't support arrays + +echo "{\"tree\": \"$gh_pages_tree\", \"parents\": [\"$gh_pages_sha\"], \"message\": \"automated commit for pr creation\"}" > tmp/h_pages_commit_input.json +echo "{\"tree\": \"$jekyll_tree\", \"parents\": [\"$jekyll_sha\"], \"message\": \"automated commit for pr creation\"}" > tmp/jekyll_commit_input.json + +# create the commit + +new_gh_pages_sha=`gh api repos/github/pages/git/commits --input tmp/gh_pages_commit_input.json | jq '. | .sha'` +new_jekyll_sha=`gh api repos/actions/jekyll-build-pages/git/commits --input tmp/jekyll_commit_input.json | jq '. | .sha'` + +# associate the commit with the branch + +gh api repos/github/pages/git/refs/heads/pages-gem-release-$tag -F "sha"="$new_gh_pages_sha" -F "ref"="refs/heads/pages-gem-release-$tag" -F "force"="true" +gh api repos/actions/jekyll-build-pages/git/refs/heads/pages-gem-release-$tag -F "sha"="$new_jekyll_sha" -F "ref"="refs/heads/pages-gem-release-$tag" -F "force"="true" + +# create pull requests in downstream repos +gh pr create --base "master" --head "pages-gem-release-$tag" --title "Bump pages-gem version to $tag" --assignee "@me" --body "Bump pages-gem version to $tag. You must manually make those changes and commit to this branch" --repo "github/pages" +gh pr create --base "main" --head "pages-gem-release-$tag" --title "Bump pages-gem version to $tag" --assignee "@me" --body "Bump pages-gem version to $tag. You must manually make those changes and commit to this branch" --repo "actions/jekyll-build-pages" + +# clean up the input file for the commit + +rm tmp/* diff --git a/spec/fixtures/_config.yml b/spec/fixtures/_config.yml index 9e3ba69b..52d5492e 100644 --- a/spec/fixtures/_config.yml +++ b/spec/fixtures/_config.yml @@ -11,6 +11,7 @@ gems: - jemoji - jekyll-mentions - jekyll_test_plugin_malicious + - jekyll-include-cache quiet: false paginate: 5 github: diff --git a/spec/fixtures/_config_with_gfm.yml b/spec/fixtures/_config_with_gfm.yml index a8623ae2..7afdc028 100644 --- a/spec/fixtures/_config_with_gfm.yml +++ b/spec/fixtures/_config_with_gfm.yml @@ -12,6 +12,7 @@ gems: - jemoji - jekyll-mentions - jekyll_test_plugin_malicious + - jekyll-include-cache quiet: false paginate: 5 github: diff --git a/spec/fixtures/_config_with_remote_theme.yml b/spec/fixtures/_config_with_remote_theme.yml index ab329853..b924c8a9 100644 --- a/spec/fixtures/_config_with_remote_theme.yml +++ b/spec/fixtures/_config_with_remote_theme.yml @@ -11,6 +11,7 @@ gems: - jemoji - jekyll-mentions - jekyll_test_plugin_malicious + - jekyll-include-cache quiet: false paginate: 5 github: diff --git a/spec/fixtures/_includes/cached.html b/spec/fixtures/_includes/cached.html new file mode 100644 index 00000000..a0d79d61 --- /dev/null +++ b/spec/fixtures/_includes/cached.html @@ -0,0 +1,5 @@ + + +

Hi from the cache {{ include.name }}!!!

+ + diff --git a/spec/fixtures/jekyll-include-cache.html b/spec/fixtures/jekyll-include-cache.html new file mode 100644 index 00000000..40fa9b8b --- /dev/null +++ b/spec/fixtures/jekyll-include-cache.html @@ -0,0 +1,4 @@ +--- +--- + +{% include_cached cached.html name="Test User" %} diff --git a/spec/fixtures/jekyll-seo-tag.html b/spec/fixtures/jekyll-seo-tag.html index 1e026768..bc379bf7 100644 --- a/spec/fixtures/jekyll-seo-tag.html +++ b/spec/fixtures/jekyll-seo-tag.html @@ -1,5 +1,6 @@ --- title: Jekyll SEO Tag +locale: et_EE --- {% seo %} diff --git a/spec/github-pages/configuration_spec.rb b/spec/github-pages/configuration_spec.rb index c13e2dc7..f9ced55a 100644 --- a/spec/github-pages/configuration_spec.rb +++ b/spec/github-pages/configuration_spec.rb @@ -83,7 +83,7 @@ expect(effective_config["markdown"]).to eql("CommonMarkGhPages") expect(effective_config["commonmark"]).to eql( "extensions" => %w(table strikethrough autolink tagfilter), - "options" => %w(footnotes) + "options" => %w(unsafe footnotes) ) end end @@ -110,9 +110,12 @@ end context "with a user-specified theme" do - let(:site) do - config = configuration.merge("theme" => "jekyll-theme-merlot") - Jekyll::Site.new(config) + let(:configuration) do + described_class.effective_config( + Jekyll.configuration( + test_config.merge("theme" => "jekyll-theme-merlot") + ) + ) end it "respects the theme" do diff --git a/spec/github-pages/integration_spec.rb b/spec/github-pages/integration_spec.rb index 339277bd..35740df2 100644 --- a/spec/github-pages/integration_spec.rb +++ b/spec/github-pages/integration_spec.rb @@ -187,8 +187,12 @@ def rm_destination end context "jekyll-seo-tag" do - it "outputs the tag" do - expect(contents).to match("Jekyll SEO Tag") + it "outputs title tag" do + expect(contents).to include("<title>Jekyll SEO Tag | pages-gem") + end + + it "outputs OpenGraph locale meta tag" do + expect(contents).to include("") end end @@ -269,6 +273,12 @@ def rm_destination expect(contents).to match('aria-label="hi"') end end + + context "jekyll-include-cache" do + it "works" do + expect(contents).to match('

Hi from the cache Test User!!!

') + end + end end context "fixture site with remote theme config" do