diff --git a/.github/workflows/gempush.yml b/.github/workflows/gempush.yml index 7db6e26..5f3ff3c 100644 --- a/.github/workflows/gempush.yml +++ b/.github/workflows/gempush.yml @@ -1,12 +1,6 @@ name: Ruby Gem -on: - push: - branches: [ master ] - tags: - - '*' - pull_request: - branches: [ master ] +on: [pull_request, push] jobs: build: @@ -14,98 +8,98 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - name: Fetch all history for all tags and branches - run: | - git fetch --prune --unshallow --tags - echo "REF: ${{ github.ref }}" - - - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v0.9.2 - with: - versionSpec: '5.2.x' - - - name: Execute GitVersion - id: gitversion - uses: gittools/actions/gitversion/execute@v0.9.2 - - - name: Version variables for unstable builds - id: unstable - if: startsWith(github.ref, 'refs/tags/') != true - env: - LABEL: ${{ steps.gitversion.outputs.preReleaseTagWithDash }}.${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }} - run: | - echo "Pre-release: ${LABEL}" - echo "::set-output name=label::${LABEL}" - - - name: Create gem version number - id: gemversion - env: - GEM_VERSION: "${{ steps.gitversion.outputs.majorMinorPatch }}${{ steps.unstable.outputs.label }}" - run: | - echo "Gem version: ${GEM_VERSION}" - echo "::set-output name=version::${GEM_VERSION}" - - - name: Set up Ruby 2.6 - uses: actions/setup-ruby@v1 - with: - ruby-version: 2.6.x - - - name: Cache dependencies - uses: actions/cache@v1 - with: - path: vendor/bundle - key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} - restore-keys: ${{ runner.os }}-gems- - - - name: Bundle install - run: | - gem install bundler - bundle config path vendor/bundle - bundle install --jobs 4 --retry 3 - - - name: Build gem - id: gem - env: - GEM_VERSION: ${{ steps.gemversion.outputs.version }} - run: | - GEM_BUILD_NAME=$(gem build jekyll-material-icon-tag.gemspec | awk '/File/ {print $2}') - echo "Gem filename: '${GEM_BUILD_NAME}'" - echo "::set-output name=name::${GEM_BUILD_NAME}" - - - name: Test gem - run: | - bundle exec rake test - - - name: Upload artifact - uses: actions/upload-artifact@v2-preview - with: - name: ${{ steps.gem.outputs.name }} - path: ${{ steps.gem.outputs.name }} - - - name: Publish to GPR - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - OWNER: SwedbankPay - run: | - mkdir -p $HOME/.gem - touch $HOME/.gem/credentials - chmod 0600 $HOME/.gem/credentials - printf -- "---\n:github: Bearer ${GITHUB_TOKEN}\n" > $HOME/.gem/credentials - set -e - gem push --KEY github \ - --host https://rubygems.pkg.github.com/${OWNER} \ - ${{ steps.gem.outputs.name }} \ - || echo "push failed ($?) probably due to version '${{ steps.gemversion.outputs.version }}' already existing in GPR." - - - name: Publish to RubyGems - if: startsWith(github.ref, 'refs/tags/') # Only publish tagged commits - env: - RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} - run: | - mkdir -p $HOME/.gem - touch $HOME/.gem/credentials - chmod 0600 $HOME/.gem/credentials - printf -- "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}\n" > $HOME/.gem/credentials - gem push ${{ steps.gem.outputs.name }} + - uses: actions/checkout@v2 + + - name: Fetch all history for all tags and branches + run: | + git fetch --prune --unshallow --tags + echo "REF: ${{ github.ref }}" + + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v0.9.2 + with: + versionSpec: "5.2.x" + + - name: Execute GitVersion + id: gitversion + uses: gittools/actions/gitversion/execute@v0.9.2 + + - name: Version variables for unstable builds + id: unstable + if: startsWith(github.ref, 'refs/tags/') != true + env: + LABEL: ${{ steps.gitversion.outputs.preReleaseTagWithDash }}.${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }} + run: | + echo "Pre-release: ${LABEL}" + echo "::set-output name=label::${LABEL}" + + - name: Create gem version number + id: gemversion + env: + GEM_VERSION: "${{ steps.gitversion.outputs.majorMinorPatch }}${{ steps.unstable.outputs.label }}" + run: | + echo "Gem version: ${GEM_VERSION}" + echo "::set-output name=version::${GEM_VERSION}" + + - name: Set up Ruby 2.6 + uses: actions/setup-ruby@v1 + with: + ruby-version: 2.6.x + + - name: Cache dependencies + uses: actions/cache@v1 + with: + path: vendor/bundle + key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: ${{ runner.os }}-gems- + + - name: Bundle install + run: | + gem install bundler + bundle config path vendor/bundle + bundle install --jobs 4 --retry 3 + + - name: Build gem + id: gem + env: + GEM_VERSION: ${{ steps.gemversion.outputs.version }} + run: | + GEM_BUILD_NAME=$(gem build jekyll-material-icon-tag.gemspec | awk '/File/ {print $2}') + echo "Gem filename: '${GEM_BUILD_NAME}'" + echo "::set-output name=name::${GEM_BUILD_NAME}" + + - name: Test gem + run: | + bundle exec rake test + + - name: Upload artifact + uses: actions/upload-artifact@v2-preview + with: + name: ${{ steps.gem.outputs.name }} + path: ${{ steps.gem.outputs.name }} + + - name: Publish to GPR + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + OWNER: SwedbankPay + run: | + mkdir -p $HOME/.gem + touch $HOME/.gem/credentials + chmod 0600 $HOME/.gem/credentials + printf -- "---\n:github: Bearer ${GITHUB_TOKEN}\n" > $HOME/.gem/credentials + set -e + gem push --KEY github \ + --host https://rubygems.pkg.github.com/${OWNER} \ + ${{ steps.gem.outputs.name }} \ + || echo "push failed ($?) probably due to version '${{ steps.gemversion.outputs.version }}' already existing in GPR." + + - name: Publish to RubyGems + if: startsWith(github.ref, 'refs/tags/') # Only publish tagged commits + env: + RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} + run: | + mkdir -p $HOME/.gem + touch $HOME/.gem/credentials + chmod 0600 $HOME/.gem/credentials + printf -- "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}\n" > $HOME/.gem/credentials + gem push ${{ steps.gem.outputs.name }} diff --git a/README.md b/README.md index 0d713a3..f3ecf46 100644 --- a/README.md +++ b/README.md @@ -7,12 +7,15 @@ gem 'jekyll-material-icon-tag' ``` And then execute: + ```shell -$ bundle install +bundle install ``` + Or install it yourself as: + ```shell -$ gem install jekyll-material-icon-tag +gem install jekyll-material-icon-tag ``` ## Usage @@ -25,9 +28,17 @@ To render a Material Design Icon use as follows: {% icon name_of_icon_you_want %} ``` +You can also add style if you want a different material icon style: + +```liquid +{% icon name_of_icon_you_want two-tone %} +{% icon another_icon_perhaps round %} +{% icon the_outlined_one outlined %} +``` + ## Contributing -Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jekyll-material-icon-tag. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/jekyll-material-icon-tag/blob/master/CODE_OF_CONDUCT.md). +Bug reports and pull requests are welcome on GitHub at :build do - file = File.open("_site/index.html") - content = file.read + File.open("_site/index.html") do |file| + content = file.read - if content.include? "{% icon" - raise "Hell" - end + if content.include? "{% icon" + raise "Hell" + end + + unless content.include? "material-icons-two-tone" + raise "Hell of two tones" + end - file.close + unless content.include? "material-icons-two-tone" + raise "Hell of two tones" + end + + file.close + end end task :default => ["build"] diff --git a/lib/jekyll-material-icon-tag.rb b/lib/jekyll-material-icon-tag.rb index 2394403..1878db9 100644 --- a/lib/jekyll-material-icon-tag.rb +++ b/lib/jekyll-material-icon-tag.rb @@ -8,7 +8,18 @@ def initialize(tag_name, text, tokens) end def render(_) - "#{@text.strip}" + iconname, type = parse_parameters @text + + if type.nil? + "#{iconname.strip}" + else + "#{iconname.strip}" + end + end + + def parse_parameters(text) + text.strip! + text.split(/\s+/) end Liquid::Template.register_tag "icon", self diff --git a/test/jekyll-material-icon-tag/index.md b/test/jekyll-material-icon-tag/index.md index 68e3c1b..6096e26 100644 --- a/test/jekyll-material-icon-tag/index.md +++ b/test/jekyll-material-icon-tag/index.md @@ -5,3 +5,5 @@ layout: home # About This page test the {% icon check %} gem. +It also supports different {% icon alarm_on two-tone %} styles +{% icon aspect_ratio round %}.