Verified Commit 6eb77daf authored by Michael Angelo Rivera's avatar Michael Angelo Rivera Committed by GitLab
Browse files

feat(proto): add gkg-proto Ruby gem build pipeline

parent 6f96e539
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -32,6 +32,9 @@ e2e/tilt/.secrets
helm-dev/charts/
helm-dev/tmpcharts*/

# Proto gem build output
_build/

# Git worktrees
.worktrees/

+47 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ stages:
  - security
  - test
  - build
  - publish
  - deploy
  - release

@@ -446,6 +447,52 @@ deploy-sandbox:
    name: sandbox
    url: https://console.cloud.google.com/kubernetes/workload?project=${GKE_PROJECT}

# Publish Stage - Proto Gem

build-proto-gem:
  needs: []
  image: ruby:3.3
  tags:
    - saas-linux-small-amd64
  stage: publish
  before_script: []
  script:
    - BUNDLE_GEMFILE=tools/protogem/Gemfile bundle install --quiet
    - |
      if [ -n "$CI_COMMIT_TAG" ]; then
        ruby tools/protogem/build-proto-gem --version "${CI_COMMIT_TAG#v}"
      else
        ruby tools/protogem/build-proto-gem
      fi
  rules:
    - if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+/
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
      changes:
        - crates/gkg-server/proto/**/*
        - tools/protogem/**/*
    - when: manual
      allow_failure: true
  artifacts:
    paths:
      - _build/gitlab-gkg-proto-*.gem
    expire_in: 30 days

publish-proto-gem:
  needs:
    - build-proto-gem
  image: ruby:3.3
  tags:
    - saas-linux-small-amd64
  stage: publish
  before_script: []
  script:
    - gem push "_build/gitlab-gkg-proto-${CI_COMMIT_TAG#v}.gem"
  rules:
    - if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org/orbit" && $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+/'
  environment:
    name: rubygems
    url: https://rubygems.org/gems/gitlab-gkg-proto

# Release Stage

semantic-release:
+12 −0
Original line number Diff line number Diff line
@@ -94,6 +94,18 @@ echo "Ruby proto files generated in crates/gkg-server/proto/ruby/"
'''
description = "Generate Ruby protobuf files for Rails client"

[tasks."proto:build-gem"]
run = '''
BUNDLE_GEMFILE=tools/protogem/Gemfile bundle install --quiet
ruby tools/protogem/build-proto-gem
'''
description = "Build gitlab-gkg-proto Ruby gem from proto definitions"

[tasks."proto:publish-gem"]
depends = ["proto:build-gem"]
run = 'gem push _build/gitlab-gkg-proto-*.gem'
description = "Publish gitlab-gkg-proto gem to RubyGems.org"

[tasks."server:start"]
run = 'GKG_JWT_SECRET=${GKG_JWT_SECRET:-$(cat ~/gitlab/gdk/gitlab/.gitlab_shell_secret 2>/dev/null || echo "development-secret-at-least-32-bytes")} cargo run -p gkg-server'
description = "Start the GKG server (webserver mode)"

tools/protogem/Gemfile

0 → 100644
+3 −0
Original line number Diff line number Diff line
source 'https://rubygems.org'

gem 'grpc-tools', '~> 1.71.0'
+13 −0
Original line number Diff line number Diff line
GEM
  remote: https://rubygems.org/
  specs:
    grpc-tools (1.71.0)

PLATFORMS
  ruby

DEPENDENCIES
  grpc-tools (~> 1.71.0)

BUNDLED WITH
   2.5.23
Loading