From 42892b4d621365895f2a812a4258ecd70ed973ea Mon Sep 17 00:00:00 2001 From: Tomas Varneckas <206971+tomasv@users.noreply.github.com> Date: Fri, 5 Apr 2024 14:43:41 +0300 Subject: [PATCH 1/2] Add gem release workflow --- .github/workflows/build_release_pipeline.yaml | 53 +++++++++++++++++++ .github/workflows/ci.yml | 24 --------- 2 files changed, 53 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/build_release_pipeline.yaml delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/build_release_pipeline.yaml b/.github/workflows/build_release_pipeline.yaml new file mode 100644 index 00000000..b39d9c3c --- /dev/null +++ b/.github/workflows/build_release_pipeline.yaml @@ -0,0 +1,53 @@ +name: Build and release ruby gem + +on: + pull_request: + branches: [ 1-0-stable ] + push: + workflow_dispatch: + +jobs: + build-release-pipeline: + runs-on: ubuntu-latest + steps: + - run: | + sudo apt-get update + sudo apt-get -y install memcached libsasl2-dev + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.0' + bundler-cache: true + + - run: bundle exec ruby test/setup.rb + - run: bundle exec rake + - name: Build + id: build + if: success() + run: | + bundle exec rake build + echo "::set-output name=gem_version::v$(bundle exec rake version)" + + - name: Release + if: success() && github.ref == 'refs/heads/1-0-stable' + run: | + mkdir -p $HOME/.gem + touch $HOME/.gem/credentials + chmod 600 $HOME/.gem/credentials + printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials + gem push pkg/vinted-memcached-*.gem -V + env: + GEM_HOST_API_KEY: "${{ secrets.RUBYGEMS_AUTH_TOKEN }}" + + - name: Tag repo with new gem version + if: success() && github.ref == 'refs/heads/1-0-stable' + uses: actions/github-script@v3 + with: + github-token: ${{ github.token }} + script: | + github.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: "refs/tags/${{ steps.build.outputs.gem_version }}", + sha: context.sha + }) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index a31734f6..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: CI -on: [push, pull_request] -jobs: - build: - runs-on: ubuntu-latest - - strategy: - matrix: - ruby: - - '2.5' # earliest supported - - '3.0' # latest release - - steps: - - run: | - sudo apt-get update - sudo apt-get -y install memcached libsasl2-dev - - uses: actions/checkout@v2 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - bundler-cache: true - - run: bundle exec ruby test/setup.rb - - run: bundle exec rake - - run: bundle exec rake install From ef2af1eea1238724e69d198334aef478bfe10499 Mon Sep 17 00:00:00 2001 From: Tomas Varneckas <206971+tomasv@users.noreply.github.com> Date: Fri, 5 Apr 2024 14:47:57 +0300 Subject: [PATCH 2/2] Add version rake task --- Gemfile.lock | 4 ++-- Rakefile | 5 +++++ lib/memcached/version.rb | 3 +++ memcached.gemspec | 6 ++++-- 4 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 lib/memcached/version.rb diff --git a/Gemfile.lock b/Gemfile.lock index 67254cd1..c51d4db5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - memcached (1.9.0) + vinted-memcached (1.8.5) GEM remote: https://rubygems.org/ @@ -38,13 +38,13 @@ DEPENDENCIES activesupport dalli memcache-client - memcached! mocha rake rake-compiler remix-stash (~> 1.1.3) stackprof test-unit + vinted-memcached! BUNDLED WITH 2.1.4 diff --git a/Rakefile b/Rakefile index d312aac4..3de55ea8 100644 --- a/Rakefile +++ b/Rakefile @@ -58,3 +58,8 @@ def run(cmd, reason) puts cmd raise "'#{cmd}' failed" unless system(cmd) end + +task :version do + require 'memcached/version' + puts Memcached::VERSION +end diff --git a/lib/memcached/version.rb b/lib/memcached/version.rb new file mode 100644 index 00000000..6e3d7e36 --- /dev/null +++ b/lib/memcached/version.rb @@ -0,0 +1,3 @@ +class Memcached + VERSION = '1.8.5' +end diff --git a/memcached.gemspec b/memcached.gemspec index ca5b63d4..a0052ae4 100644 --- a/memcached.gemspec +++ b/memcached.gemspec @@ -1,8 +1,10 @@ # -*- encoding: utf-8 -*- +require_relative 'lib/memcached/version' + Gem::Specification.new do |s| - s.name = "memcached" - s.version = "1.9.0" + s.name = "vinted-memcached" + s.version = Memcached::VERSION s.authors = ["Arthur Neves", "Evan Weaver"] s.email = "arthurnn@gmail.com"