Auto-trigger CD when CI passes and the gem version is bumped#171
Open
perryqh wants to merge 1 commit into
Open
Auto-trigger CD when CI passes and the gem version is bumped#171perryqh wants to merge 1 commit into
perryqh wants to merge 1 commit into
Conversation
4a7d6f8 to
7934e58
Compare
Previously CD only ran via workflow_dispatch. Wire it to fire automatically after CI succeeds on main, following the rubyatscale shared-config convention (workflow_run trigger, secrets read directly by CD) used by code_teams, packs-specification, rubocop-packs, etc. We can't call shared-config's reusable cd.yml because this gem builds cross-platform native binaries (oxidize-rb matrix) rather than a pure Ruby gem, so CD stays bespoke — but the trigger shape now matches. cd.yml: - Trigger on workflow_run (workflows: [CI], types: [completed], branches: [main]) instead of workflow_call; keep workflow_dispatch. - Add a check-release gate job: reads CodeOwnership::VERSION and queries the RubyGems API, proceeding only when the version is unpublished. This gate is our one deviation from shared-config — it avoids running the expensive cross-compile matrix on every main merge (shared-config doesn't need it because its publish action no-ops cheaply). Manual dispatch bypasses the gate to support dry-run testing / forced runs. - Gate ci-data/build/release on check-release and on the triggering CI run's conclusion == 'success'. - Add a dry_run input to workflow_dispatch that skips the irreversible gem push (logs "would push"), making the full pipeline testable manually without publishing. The Release step is already gated on new_version, so it skips automatically in dry-run. - Add a notify_on_release Slack notification on successful release. ci.yml is left untouched. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
7934e58 to
a94c2dd
Compare
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.
What & why
Today
cd.ymlonly runs viaworkflow_dispatch(manual). This wires it to fire automatically after CI succeeds onmain, when the version inlib/code_ownership/version.rbisn't already on RubyGems.It follows the rubyatscale
shared-configconvention — aworkflow_runtrigger, with CD reading its secrets directly — the same pattern used bycode_teams,packs-specification,rubocop-packs, etc.We can't simply call
shared-config's reusablecd.yml, because this gem builds cross-platform native binaries (theoxidize-rbmatrix) rather than a pure-Ruby gem. So CD stays bespoke — but the trigger shape now matches the ecosystem.Changes (all in
cd.yml;ci.ymluntouched)workflow_run(workflows: [CI],types: [completed],branches: [main]) instead ofworkflow_call; keepworkflow_dispatch.check-releasegate job — readsCodeOwnership::VERSIONand asks the RubyGems API whether it's published (curl -sf), proceeding only when the version is unpublished. This is our one deliberate deviation from shared-config: it avoids running the expensive cross-compile matrix on everymainmerge (shared-config doesn't need it because its publish action no-ops cheaply). Manual dispatch bypasses the gate to support dry-run testing / forced runs. Uses a sparse, shallow checkout (onlyversion.rb).ci-data/build/releaseoncheck-releaseand on the triggering CI run'sconclusion == 'success'.dry_runinput onworkflow_dispatchthat skips the irreversiblegem push(logs "would push"), making the full pipeline testable manually without publishing. The Release step is already gated onnew_version, so it skips automatically in dry-run.notify_on_release— Slack "Released v" on success.Consistency with shared-config
on: workflow_runsecrets.*check-release-- justified by binary build costdiscourse/publish-rubygems-actionoxidize-rbmatrix -- the binary special caseSecrets note: both workflows read
secrets.RUBYGEMS_API_KEY/GITHUB_TOKEN/SLACK_WEBHOOK_URLdirectly.secrets: inheritonly applies when one workflow calls another viauses:-- which this approach doesn't do -- so there's nothing to inherit or declare.Testing (no real publish required)
curl -sfthe RubyGems API:2.1.3succeeds (published),99.99.99fails (unpublished).cd.ymlwithdry_run: true: builds the gem matrix and runs the whole job graph without publishing.main; idempotent (skip-if-exists), withworkflow_dispatchas fallback.Known follow-up (not in this PR)
notify_on_releasefires whenever thereleasejob succeeds, including a manualdry_rundispatch where nothing was actually published (spurious "Released" ping). Gating it on the push step'snew_versionwould require exposing that as a job output -- left for a follow-up.🤖 Generated with Claude Code