Commit 1f34e674 authored by Jacek Lebioda's avatar Jacek Lebioda
Browse files

Merge branch '43-automatically-tag-and-publish-on-version-change' into 'latest'

Resolve "Automatically tag and publish on version change"

Closes #43

See merge request core-services/jekyll-theme-lcsb-default!34
parents 4d1ee0a7 2fb83701
...@@ -36,13 +36,36 @@ pages: ...@@ -36,13 +36,36 @@ pages:
paths: paths:
- public - public
# This will push the gem to ruby-gems when tagged # This will tag the repository when the version-file changes and the theme successfully builds
auto-tag:
stage: deploy
variables:
VERSION_FILE: "lib/jekyll-theme-lcsb-default.rb"
TARGET_BRANCH: latest
script:
# Make sure that it is on latest, otherwise exit
- '[[ "${CI_COMMIT_BRANCH:-1}" == "$TARGET_BRANCH" ]] && echo "On correct branch ($CI_COMMIT_BRANCH)" || exit 0'
# Make sure that the version exists
- VERSION=$(cat $VERSION_FILE | grep -o "\d\.\d\.\d")
- '[[ -z $VERSION ]] && exit -1 || echo "OK, version appears to be correct -> $VERSION"'
# Create the tag
- git tag -a $VERSION
# Publish the tag
- git push origin $VERSION
only:
changes:
- "lib/jekyll-theme-lcsb-default.rb"
# This will push the gem to ruby-gems when the repository has been tagged
release: release:
stage: release stage: release
script: script:
- mkdir -p ~/.gem && echo "$API_KEY_BASE64" | base64 --decode > ~/.gem/credentials && chmod 0600 ~/.gem/credentials - mkdir -p ~/.gem && echo "$API_KEY_BASE64" | base64 --decode > ~/.gem/credentials && chmod 0600 ~/.gem/credentials
- gem build jekyll-theme-lcsb-default.gemspec && gem push jekyll-theme-lcsb-default*.gem - gem build jekyll-theme-lcsb-default.gemspec && gem push jekyll-theme-lcsb-default*.gem
rules: rules:
# Run only on master... # Run only when there is a new tag
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
# frozen_string_literal: true # frozen_string_literal: true
# Load version
require File.expand_path("lib/jekyll-theme-lcsb-default", __dir__)
Gem::Specification.new do |spec| Gem::Specification.new do |spec|
spec.name = "jekyll-theme-lcsb-default" spec.name = "jekyll-theme-lcsb-default"
spec.version = "0.3.16" spec.version = Theme::VERSION
spec.authors = ["Trefex", "jaceklebioda_lux"] spec.authors = ["Trefex", "jaceklebioda_lux"]
spec.email = ["lcsb-sysadmins@uni.lu"] spec.email = ["lcsb-sysadmins@uni.lu"]
...@@ -10,7 +13,7 @@ Gem::Specification.new do |spec| ...@@ -10,7 +13,7 @@ Gem::Specification.new do |spec|
spec.homepage = "https://git-r3lab.uni.lu/core-services/jekyll-theme-lcsb-default" spec.homepage = "https://git-r3lab.uni.lu/core-services/jekyll-theme-lcsb-default"
spec.license = "MIT" spec.license = "MIT"
spec.files = `git ls-files -z`.split("\x0").select { |f| f.match(%r!^(assets|_layouts|_includes|_sass|LICENSE|README)!i) } spec.files = `git ls-files -z`.split("\x0").select { |f| f.match(%r!^(assets|_layouts|lib|_includes|_sass|LICENSE|README)!i) }
spec.add_runtime_dependency "jekyll", "~> 4.0" spec.add_runtime_dependency "jekyll", "~> 4.0"
spec.add_runtime_dependency "jekyll-seo-tag", "~> 2.5" spec.add_runtime_dependency "jekyll-seo-tag", "~> 2.5"
......
# frozen_string_literal: true
# Note: remember to keep it in the format of NUMBER.NUMBER.NUMBER (where NUMBER is [0-9]+) - otherwise gitlab-ci could fail to detect the version
module Theme
VERSION = "0.3.17"
end
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment