Repository navigation
CI: master 版本號變更時自動發佈 gem 到 RubyGems(Trusted Publishing) - #50
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
內容
新增
.github/workflows/publish.yml:當master上 gemspec 的版本號尚未存在於 rubygems.org 時,透過 RubyGems Trusted Publishing(OIDC)自動發佈 gem。只新增這個 workflow 檔,不改 gem 程式碼與版本號,Rakefile 已有require "bundler/gem_tasks",不需修改。觸發邏輯
push到master、手動workflow_dispatch(publish job 只在refs/heads/master執行)。沒有pull_request觸發。checkjob:用Gem::Specification.load讀出 gem 名稱與版本,查詢 https://rubygems.org/api/v1/versions/super_tools.json ,版本已存在 →should_publish=false,後續全部跳過;不存在 →true。testjob:以 Ruby 3.4.11 +gemfiles/ruby_3.4_rails_8.1.gemfile(與 test.yml 同一組矩陣)跑bundle exec rake t。publishjob:environment: gem-publish,執行rubygems/release-gem(rake release:build、建立並推送vX.Y.Ztag、push gem)。concurrency避免重複發佈。安全性
superlanding/super_tools/publish.yml/gem-publish)。permissions: contents: read;只有 publish job 取得id-token: write與contents: write(推 tag 用)。3d3c42e5aac5ba805825da76410c181273ba90b1(v7.0.1)b1da4809b005e0178fe08a1d57317bffc00b7b4c(v1.332.0)7f9650160c1a4e7989fdc9855807bdbd421d8b6b(v1.4.1)目前 master 的版本是
4.0.2,rubygems.org 最新是4.0.1,合併此 PR 後會立即發佈 4.0.2 並建立v4.0.2tag。發佈流程 checklist
lib/super_tools/version.rb調整版本號(並更新 Gemfile.lock 如有需要)mastergem-publishenvironment 設定了 reviewer,需核准)vX.Y.Ztag 已出現