From 3c396fd2c51d431b978d6161094f0d17ac46a150 Mon Sep 17 00:00:00 2001 From: Phil Helm Date: Wed, 22 Jul 2026 22:30:52 +0100 Subject: [PATCH 1/2] migrate pipeline from circleci to github actions --- .circleci/config.yml | 183 ------------------ {.circleci => .github}/gpg.private.enc | Bin .github/workflows/main.yaml | 135 +++++++++++++ .github/workflows/pr.yaml | 115 +++++++++++ Gemfile.lock | 85 ++++---- README.md | 8 +- Rakefile | 155 ++++++++++----- config/secrets/ci/ssh.private | Bin 3265 -> 0 bytes config/secrets/ci/ssh.public | Bin 773 -> 0 bytes config/secrets/circle_ci/config.yaml | Bin 120 -> 0 bytes config/secrets/github/config.yaml | Bin 152 -> 0 bytes ruby_fly.gemspec | 3 +- scripts/ci/common/configure-asdf.sh | 18 -- scripts/ci/common/configure-git.sh | 8 - scripts/ci/common/configure-rubygems.sh | 2 - .../ci/common/install-asdf-dependencies.sh | 12 -- scripts/ci/common/install-asdf.sh | 19 -- scripts/ci/common/install-git-crypt.sh | 4 +- scripts/ci/common/install-gpg-key.sh | 19 -- scripts/ci/common/install-slack-deps.sh | 8 - scripts/ci/steps/build.sh | 12 -- scripts/ci/steps/merge-pull-request.sh | 16 -- scripts/ci/steps/prerelease.sh | 17 -- scripts/ci/steps/release.sh | 19 -- scripts/ci/steps/test.sh | 12 -- 25 files changed, 409 insertions(+), 441 deletions(-) delete mode 100644 .circleci/config.yml rename {.circleci => .github}/gpg.private.enc (100%) create mode 100644 .github/workflows/main.yaml create mode 100644 .github/workflows/pr.yaml delete mode 100644 config/secrets/ci/ssh.private delete mode 100644 config/secrets/ci/ssh.public delete mode 100644 config/secrets/circle_ci/config.yaml delete mode 100644 config/secrets/github/config.yaml delete mode 100755 scripts/ci/common/configure-asdf.sh delete mode 100755 scripts/ci/common/configure-git.sh delete mode 100755 scripts/ci/common/install-asdf-dependencies.sh delete mode 100755 scripts/ci/common/install-asdf.sh delete mode 100755 scripts/ci/common/install-gpg-key.sh delete mode 100755 scripts/ci/common/install-slack-deps.sh delete mode 100755 scripts/ci/steps/build.sh delete mode 100755 scripts/ci/steps/merge-pull-request.sh delete mode 100755 scripts/ci/steps/prerelease.sh delete mode 100755 scripts/ci/steps/release.sh delete mode 100755 scripts/ci/steps/test.sh diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 5755b55..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,183 +0,0 @@ -version: 2.1 - -orbs: - slack: circleci/slack@4.13.2 - -base_container: &base_container - image: buildpack-deps:buster - -build_container: &build_container - resource_class: arm.medium - docker: - - <<: *base_container - -slack_context: &slack_context - context: - - slack - -only_main: &only_main - filters: - branches: - only: - - main - -only_dependabot: &only_dependabot - filters: - branches: - only: - - /^dependabot.*/ - -only_main_and_dependabot: &only_main_and_dependabot - filters: - branches: - only: - - main - - /^dependabot.*/ - -commands: - notify: - steps: - - when: - condition: - matches: - pattern: "^dependabot.*" - value: << pipeline.git.branch >> - steps: - - slack/notify: - event: fail - channel: builds-dependabot - template: SLACK_FAILURE_NOTIFICATION - - slack/notify: - event: pass - channel: builds-dependabot - template: SLACK_SUCCESS_NOTIFICATION - - when: - condition: - matches: - pattern: "^(?!dependabot).*" - value: << pipeline.git.branch >> - steps: - - slack/notify: - event: fail - channel: dev - template: SLACK_FAILURE_NOTIFICATION - - slack/notify: - event: pass - channel: builds - template: SLACK_SUCCESS_NOTIFICATION - - configure_build_tools: - steps: - - run: ./scripts/ci/common/install-slack-deps.sh - - restore_cache: - keys: - - asdf-dependencies-{{ arch }}-v2-{{ checksum ".tool-versions" }} - - asdf-dependencies-{{ arch }}-v2- - - run: ./scripts/ci/common/install-asdf.sh - - run: ./scripts/ci/common/configure-asdf.sh - - run: ./scripts/ci/common/install-asdf-dependencies.sh - - save_cache: - key: asdf-dependencies-{{ arch }}-v2-{{ checksum ".tool-versions" }} - paths: - - ~/.asdf - - configure_secrets_tools: - steps: - - run: ./scripts/ci/common/install-git-crypt.sh - - run: ./scripts/ci/common/install-gpg-key.sh - - run: ./scripts/ci/common/configure-git.sh - - configure_release_tools: - steps: - - add_ssh_keys: - fingerprints: - - "SHA256:eGwh+0zeynOM7ykFaj4YjyjOlll/hy7r4IgQwPUellw" - - run: ./scripts/ci/common/configure-rubygems.sh - - configure_tools: - steps: - - configure_build_tools - - configure_secrets_tools - - configure_release_tools - -jobs: - build: - <<: *build_container - steps: - - checkout - - configure_tools - - run: ./scripts/ci/steps/build.sh - - notify - - test: - <<: *build_container - steps: - - checkout - - configure_tools - - run: ./scripts/ci/steps/test.sh - - notify - - prerelease: - <<: *build_container - steps: - - checkout - - configure_tools - - run: ./scripts/ci/steps/prerelease.sh - - notify - - release: - <<: *build_container - steps: - - checkout - - configure_tools - - run: ./scripts/ci/steps/release.sh - - notify - - merge_pull_request: - <<: *build_container - steps: - - checkout - - configure_tools - - run: ./scripts/ci/steps/merge-pull-request.sh - - notify - -workflows: - version: 2 - pipeline: - jobs: - - build: - <<: *only_main_and_dependabot - <<: *slack_context - - test: - <<: *only_main_and_dependabot - <<: *slack_context - requires: - - build - - merge_pull_request: - <<: *only_dependabot - <<: *slack_context - requires: - - test - - prerelease: - <<: *only_main - <<: *slack_context - requires: - - test - - slack/on-hold: - <<: *only_main - <<: *slack_context - requires: - - prerelease - channel: release - template: SLACK_ON_HOLD_NOTIFICATION - - hold: - <<: *only_main - type: approval - requires: - - prerelease - - slack/on-hold - - release: - <<: *only_main - <<: *slack_context - requires: - - hold diff --git a/.circleci/gpg.private.enc b/.github/gpg.private.enc similarity index 100% rename from .circleci/gpg.private.enc rename to .github/gpg.private.enc diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..e1edf84 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,135 @@ +name: Main +on: + push: + branches: + - main + +permissions: + contents: read + +jobs: + check: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + - name: Install tools + uses: infrablocks/github-actions/asdf_install@v1 + - name: Check + run: ./go library:check + - name: Notify Slack + if: ${{ !cancelled() }} + continue-on-error: true + run: ./go "slack:notify[${{ job.status }}]" + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + + test: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + - name: Install tools + uses: infrablocks/github-actions/asdf_install@v1 + - name: Test + run: ./go test:unit + - name: Notify Slack + if: ${{ !cancelled() }} + continue-on-error: true + run: ./go "slack:notify[${{ job.status }}]" + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + + prerelease: + needs: [check, test] + runs-on: ubuntu-latest + timeout-minutes: 30 + # Job-level group (here and on release): a run awaiting release approval + # holds the slot, and a workflow-level group would freeze all main CI for + # the approval window. queue: max keeps every queued run; the default + # cancels all but the newest. + concurrency: + group: main + cancel-in-progress: false + queue: max + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - name: Install tools + uses: infrablocks/github-actions/asdf_install@v1 + - name: Install secrets tools + run: ./scripts/ci/common/install-git-crypt.sh + - name: Unlock git-crypt + run: ./go git_crypt:unlock_with_encrypted_gpg_key + env: + ENCRYPTION_PASSPHRASE: ${{ secrets.ENCRYPTION_PASSPHRASE }} + - name: Configure RubyGems credentials + run: ./scripts/ci/common/configure-rubygems.sh + - name: Set CI git author + run: ./go repository:set_ci_author + - name: Bump version + run: ./go "version:bump[pre]" + - name: Release + run: ./go release + - name: Push commits + run: git push + - name: Push tags + run: git push --tags + - name: Notify Slack of release hold + continue-on-error: true + run: ./go "slack:notify[success,on_hold]" + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + - name: Notify Slack + if: ${{ !cancelled() }} + continue-on-error: true + run: ./go "slack:notify[${{ job.status }}]" + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + + release: + needs: [prerelease] + runs-on: ubuntu-latest + timeout-minutes: 30 + environment: release + concurrency: + group: main + cancel-in-progress: false + queue: max + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + with: + ref: main + - name: Pull latest main + # Publishes main as of approval time, not the SHA that triggered the + # run; --ff-only so a non-fast-forward fails loudly + run: git pull --ff-only + - name: Install tools + uses: infrablocks/github-actions/asdf_install@v1 + - name: Install secrets tools + run: ./scripts/ci/common/install-git-crypt.sh + - name: Unlock git-crypt + run: ./go git_crypt:unlock_with_encrypted_gpg_key + env: + ENCRYPTION_PASSPHRASE: ${{ secrets.ENCRYPTION_PASSPHRASE }} + - name: Configure RubyGems credentials + run: ./scripts/ci/common/configure-rubygems.sh + - name: Set CI git author + run: ./go repository:set_ci_author + - name: Bump version + run: ./go "version:bump[minor]" + - name: Release + run: ./go release + - name: Push commits + run: git push + - name: Push tags + run: git push --tags + - name: Notify Slack + if: ${{ !cancelled() }} + continue-on-error: true + run: ./go "slack:notify[${{ job.status }}]" + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml new file mode 100644 index 0000000..95916d8 --- /dev/null +++ b/.github/workflows/pr.yaml @@ -0,0 +1,115 @@ +name: Pull Request +on: + pull_request: + +permissions: + contents: read + +jobs: + check: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + - name: Install tools + uses: infrablocks/github-actions/asdf_install@v1 + - name: Check + run: ./go library:check + - name: Notify Slack + if: ${{ !cancelled() }} + continue-on-error: true + run: ./go "slack:notify[${{ job.status }}]" + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + + test: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + - name: Install tools + uses: infrablocks/github-actions/asdf_install@v1 + - name: Test + run: ./go test:unit + - name: Notify Slack + if: ${{ !cancelled() }} + continue-on-error: true + run: ./go "slack:notify[${{ job.status }}]" + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + + build: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + - name: Install tools + uses: infrablocks/github-actions/asdf_install@v1 + - name: Build + run: ./go library:build + - name: Notify Slack + if: ${{ !cancelled() }} + continue-on-error: true + run: ./go "slack:notify[${{ job.status }}]" + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + + prerelease: + needs: [check, test, build] + runs-on: ubuntu-latest + timeout-minutes: 30 + # Same-repo human PRs only: fork and Dependabot PRs carry no secrets, so + # git-crypt unlock / the RubyGems publish would fail. user.login is the + # immutable PR author, not github.actor. + if: >- + github.event.pull_request.head.repo.full_name == github.repository && + github.event.pull_request.user.login != 'dependabot[bot]' + # Queue per PR rather than cancel a mid-flight publish + concurrency: + group: pr-prerelease-${{ github.event.pull_request.number }} + cancel-in-progress: false + steps: + - uses: actions/checkout@v4 + - name: Install tools + uses: infrablocks/github-actions/asdf_install@v1 + - name: Install secrets tools + run: ./scripts/ci/common/install-git-crypt.sh + - name: Unlock git-crypt + run: ./go git_crypt:unlock_with_encrypted_gpg_key + env: + ENCRYPTION_PASSPHRASE: ${{ secrets.ENCRYPTION_PASSPHRASE }} + - name: Configure RubyGems credentials + run: ./scripts/ci/common/configure-rubygems.sh + - name: Publish prerelease + # Facts via env, never interpolated + run: ./go "prerelease:publish[$PR_NUMBER,$RUN_NUMBER,$RUN_ATTEMPT]" + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + RUN_NUMBER: ${{ github.run_number }} + RUN_ATTEMPT: ${{ github.run_attempt }} + - name: Notify Slack + if: ${{ !cancelled() }} + continue-on-error: true + run: ./go "slack:notify[${{ job.status }}]" + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + + merge-pull-request: + needs: [check, test, build] + runs-on: ubuntu-latest + timeout-minutes: 10 + if: github.event.pull_request.user.login == 'dependabot[bot]' + permissions: + contents: write + pull-requests: write + steps: + - name: Merge pull request + # --match-head-commit fails the merge if a commit landed after checks passed + # [skip ci] stops the merge commit triggering a release build + # PR title via env, never interpolated + run: gh pr merge --merge --match-head-commit "$HEAD_SHA" "$PR_URL" --subject "$PR_TITLE [skip ci]" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + PR_TITLE: ${{ github.event.pull_request.title }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Gemfile.lock b/Gemfile.lock index 34fc6d2..1eb4f52 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,38 +7,43 @@ PATH GEM remote: https://rubygems.org/ specs: - activesupport (7.1.3.4) + activesupport (8.1.3) base64 bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + json + logger (>= 1.4.2) minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) - addressable (2.8.7) - public_suffix (>= 2.0.2, < 7.0) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) + addressable (2.9.0) + public_suffix (>= 2.0.2, < 8.0) ast (2.4.3) - base64 (0.2.0) - bigdecimal (3.1.8) + base64 (0.3.0) + bigdecimal (4.1.2) childprocess (5.0.0) coderay (1.1.3) colored2 (3.1.2) - concurrent-ruby (1.3.4) - connection_pool (2.4.1) + concurrent-ruby (1.3.8) + connection_pool (3.0.2) diff-lcs (1.6.2) docile (1.4.0) - drb (2.2.1) - excon (0.111.0) + drb (2.2.3) + excon (1.6.0) + logger fakefs (3.0.0) faker (3.5.1) i18n (>= 1.8.11, < 2) - faraday (2.10.0) - faraday-net_http (>= 2.0, < 3.2) + faraday (2.14.3) + faraday-net_http (>= 2.0, < 3.5) + json logger - faraday-net_http (3.1.1) - net-http + faraday-net_http (3.4.4) + net-http (~> 0.5) ffi (1.17.1) ffi (1.17.1-arm64-darwin) ffi (1.17.1-x86_64-darwin) @@ -66,9 +71,9 @@ GEM rspec (>= 2.99.0, < 4.0) hamster (3.0.0) concurrent-ruby (~> 1.0) - i18n (1.14.6) + i18n (1.15.2) concurrent-ruby (~> 1.0) - immutable-struct (2.4.1) + immutable-struct (2.5.0) json (2.12.2) language_server-protocol (3.17.0.5) lino (4.1.0) @@ -79,19 +84,17 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - logger (1.6.0) + logger (1.7.0) lumberjack (1.2.10) method_source (1.1.0) - minitest (5.24.1) - mutex_m (0.2.0) + minitest (5.27.0) nenv (0.3.0) - net-http (0.4.1) - uri + net-http (0.9.1) + uri (>= 0.11.1) notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) - octokit (8.1.0) - base64 + octokit (10.0.0) faraday (>= 1, < 3) sawyer (~> 0.9) open4 (1.3.4) @@ -104,15 +107,10 @@ GEM pry (0.15.2) coderay (~> 1.1) method_source (~> 1.0) - public_suffix (6.0.1) + public_suffix (7.0.5) racc (1.8.1) rainbow (3.1.1) - rake (13.3.0) - rake_circle_ci (0.13.0) - colored2 (~> 3.1) - excon (~> 0.72) - rake_factory (~> 0.33) - sshkey (~> 2.0) + rake (13.4.2) rake_factory (0.33.0) activesupport (>= 4) rake (~> 13.0) @@ -120,26 +118,29 @@ GEM colored2 (~> 3.1) git (~> 1.13, >= 1.13.2) rake_factory (~> 0.33) - rake_git_crypt (0.2.0) + rake_git_crypt (0.4.0) colored2 (~> 3.1) + lino (~> 4.1) rake_factory (~> 0.33) ruby_git_crypt (~> 0.1) ruby_gpg2 (~> 0.12) - rake_github (0.15.0) + rake_github (0.17.0) colored2 (~> 3.1) - octokit (>= 4.16, < 9.0) + octokit (>= 7.0, < 11.0) rake_factory (~> 0.33) + rbnacl (~> 7.1) sshkey (~> 2.0) rake_gpg (0.20.0) rake_factory (~> 0.33) ruby_gpg2 (~> 0.12) - rake_ssh (0.12.0) - colored2 (~> 3.1) + rake_slack (0.3.0) + excon (>= 0.72, < 2.0) rake_factory (~> 0.33) - sshkey (~> 2.0) rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) + rbnacl (7.1.2) + ffi (~> 1) rchardet (1.8.0) regexp_parser (2.10.0) rspec (3.13.1) @@ -181,9 +182,10 @@ GEM lino (>= 4.1) ruby_gpg2 (0.12.0) lino (>= 4.1) - sawyer (0.9.2) + sawyer (0.9.3) addressable (>= 2.3.5) faraday (>= 0.17.3, < 3) + securerandom (0.4.1) shellany (0.0.1) simplecov (0.22.0) docile (~> 1.1) @@ -199,7 +201,7 @@ GEM unicode-display_width (3.1.4) unicode-emoji (~> 4.0, >= 4.0.4) unicode-emoji (4.0.4) - uri (0.13.2) + uri (1.1.1) PLATFORMS arm64-darwin-21 @@ -218,12 +220,11 @@ DEPENDENCIES guard guard-rspec rake - rake_circle_ci rake_git rake_git_crypt rake_github rake_gpg - rake_ssh + rake_slack rspec rubocop rubocop-rake diff --git a/README.md b/README.md index 738735f..43d35d1 100644 --- a/README.md +++ b/README.md @@ -136,16 +136,16 @@ release a new version, update the version number in `version.rb`, and then run git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). -### Managing CircleCI keys +### Managing CI keys -To encrypt a GPG key for use by CircleCI: +To encrypt a GPG key for use by CI: ```bash openssl aes-256-cbc \ -e \ -md sha1 \ -in ./config/secrets/ci/gpg.private \ - -out ./.circleci/gpg.private.enc \ + -out ./.github/gpg.private.enc \ -k "" ``` @@ -155,7 +155,7 @@ To check decryption is working correctly: openssl aes-256-cbc \ -d \ -md sha1 \ - -in ./.circleci/gpg.private.enc \ + -in ./.github/gpg.private.enc \ -k "" ``` diff --git a/Rakefile b/Rakefile index fbfe827..54c0118 100644 --- a/Rakefile +++ b/Rakefile @@ -1,15 +1,13 @@ # frozen_string_literal: true -require 'rake_circle_ci' require 'rake_git' require 'rake_git_crypt' require 'rake_github' require 'rake_gpg' -require 'rake_ssh' +require 'rake_slack' require 'rspec/core/rake_task' require 'rubocop/rake_task' require 'securerandom' -require 'yaml' task default: %i[ library:fix @@ -59,13 +57,6 @@ namespace :encryption do end namespace :keys do - namespace :deploy do - RakeSSH.define_key_tasks( - path: 'config/secrets/ci/', - comment: 'maintainers@infrablocks.io' - ) - end - namespace :gpg do RakeGPG.define_generate_key_task( output_directory: 'config/secrets/ci', @@ -91,7 +82,6 @@ namespace :secrets do desc 'Generate all generatable secrets.' task generate: %w[ encryption:passphrase:generate - keys:deploy:generate keys:gpg:generate ] @@ -115,57 +105,98 @@ namespace :library do desc 'Attempt to automatically fix issues with the library' task fix: [:'rubocop:autocorrect_all'] + + desc 'Build the library' + task :build do + sh 'gem build ruby_fly.gemspec' + end end namespace :test do RSpec::Core::RakeTask.new(:unit) end -RakeCircleCI.define_project_tasks( - namespace: :circle_ci, - project_slug: 'github/infrablocks/ruby_fly' -) do |t| - circle_ci_config = - YAML.load_file('config/secrets/circle_ci/config.yaml') - - t.api_token = circle_ci_config['circle_ci_api_token'] - t.environment_variables = { - ENCRYPTION_PASSPHRASE: - File.read('config/secrets/ci/encryption.passphrase') - .chomp - } - t.checkout_keys = [] - t.ssh_keys = [ - { - hostname: 'github.com', - private_key: File.read('config/secrets/ci/ssh.private') - } - ] +namespace :slack do + RakeSlack.define_notification_tasks do |t| + t.bot_token = ENV.fetch('SLACK_BOT_TOKEN', nil) + t.routing_rules = [ + { when: { type: 'on_hold' }, + channel: 'C038EDCRSQJ', format: :on_hold }, # release + { when: { actor: 'dependabot[bot]', outcome: 'success' }, + channel: 'C03N711HVDG', format: :success }, # builds-dependabot + { when: { actor: 'dependabot[bot]' }, + channel: 'C03N711HVDG', format: :failure }, # builds-dependabot + { when: { outcome: 'success' }, + channel: 'C023XUE76GH', format: :success }, # builds + # Failures go to builds, not team-dev (org default), to keep noise + # out of a popular channel while this pipeline beds in. + { when: {}, + channel: 'C023XUE76GH', format: :failure } # builds + ] + end +end + +namespace :repository do + desc 'Set the git author for CI' + task :set_ci_author do + sh 'git config --global user.name "InfraBlocks CI"' + sh 'git config --global user.email "ci@infrablocks.io"' + end end -RakeGithub.define_repository_tasks( +RakeGithub.define_repository_tasks( # rubocop:disable Metrics/BlockLength namespace: :github, repository: 'infrablocks/ruby_fly' ) do |t| - github_config = - YAML.load_file('config/secrets/github/config.yaml') - - t.access_token = github_config['github_personal_access_token'] - t.deploy_keys = [ - { - title: 'CircleCI', - public_key: File.read('config/secrets/ci/ssh.public') - } + # Operator's ambient auth. Resolve once and fail fast: a missing, + # unauthenticated, or absent gh yields an empty string, which would + # otherwise surface later as an opaque Octokit 401. An empty or + # whitespace-only GITHUB_TOKEN is treated as absent so an authenticated + # operator falls through to `gh auth token` rather than hitting the raise. + github_token = ENV['GITHUB_TOKEN'].to_s.strip + if github_token.empty? + github_token = begin + `gh auth token` + rescue Errno::ENOENT + '' + end.strip + end + if github_token.empty? + raise 'No GitHub token available: set GITHUB_TOKEN or run `gh auth login`' + end + + t.access_token = github_token + + # Actions store only: dependabot runs never reach the passphrase — the + # only pr.yaml job that unlocks git-crypt (prerelease) is guarded to + # same-repo human PRs. Guard against a locked clone: without + # it, File.read returns git-crypt ciphertext and github:secrets:ensure + # silently uploads garbage that only surfaces much later as an opaque + # GPG unlock failure in the release job. + passphrase_path = 'config/secrets/ci/encryption.passphrase' + unless File.exist?(passphrase_path) + raise "Passphrase file not found: #{passphrase_path} — expected a " \ + 'git-crypt-unlocked clone with the CI secrets present' + end + passphrase = File.binread(passphrase_path) + if passphrase.start_with?("\x00GITCRYPT") + raise 'encryption.passphrase is git-crypt ciphertext — unlock the ' \ + 'clone before provisioning' + end + t.secrets = [ + { name: 'ENCRYPTION_PASSPHRASE', value: passphrase.chomp } + ] + t.environments = [ + { name: 'release', + reviewers: [{ team: 'maintainers' }] } ] end namespace :pipeline do - desc 'Prepare CircleCI Pipeline' + desc 'Prepare GitHub Actions pipeline' task prepare: %i[ - circle_ci:env_vars:ensure - circle_ci:checkout_keys:ensure - circle_ci:ssh_keys:ensure - github:deploy_keys:ensure + github:secrets:ensure + github:environments:ensure ] end @@ -176,6 +207,38 @@ namespace :version do end end +namespace :prerelease do + desc 'Build and push a namespaced pre-release to RubyGems ' \ + '(PR CI only; no bump, no tag, no commit, no push)' + task :publish, %i[pr_number run_number run_attempt] do |_, args| + %i[pr_number run_number run_attempt].each do |name| + raise "Missing task argument: #{name}" if args[name].to_s.empty? + end + + version_file = 'lib/ruby_fly/version.rb' + version_pattern = /(VERSION\s*=\s*')([^']+)(')/ + source = File.read(version_file) + base = source[version_pattern, 2] + raise "Could not read VERSION from #{version_file}" unless base + + version = "#{base}.pr#{args.pr_number}" \ + ".#{args.run_number}.#{args.run_attempt}" + gem_file = "ruby_fly-#{version}.gem" + begin + File.write(version_file, + source.sub(version_pattern, "\\1#{version}\\3")) + # Build + push directly: `gem release` aborts on the (deliberately) + # uncommitted version rewrite. PR CI must not tag, commit, or push + # (contrast the `release` task). + sh 'gem build ruby_fly.gemspec' + sh "gem push #{gem_file}" + ensure + File.write(version_file, source) + rm_f gem_file + end + end +end + desc 'Release gem' task :release do sh 'gem release --tag --push' diff --git a/config/secrets/ci/ssh.private b/config/secrets/ci/ssh.private deleted file mode 100644 index fadfb6aac7d238dcbf847b1fafd985718a77e520..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3265 zcmV;y3_kM!M@dveQdv+`0O`<4Rl!U%pgx^mfiDP?hI0&o;eym)2gJg`UiC+omc0i& z5jtp05>oM^$G;+DI*H8rlMbj8BXWJdy4NIHRPk{aoRS8~?TWKI9(DYZ^(`T0ZbNp+ z#~7Eb3zI}qMYaQTTPZFQgUhM%L}b z>2}9aJ}-^97D?TFpBCwRr+Rb;UipT$Luju5JeVQzI`l9O%-DNy)DB^cw^dMz0Y<8z zC6W1(Y3t-5mj7RB$bhV;OPPSeN5X7fcNCQ+DwkNpWj_;Nb7m4F;hUnP6HDnq_}S+#mPD977Yp?k}>W%o^$Ko{-icn3e$QRvt=7&2dB z0Ku@{!sn~093uicf%k>K*&eMP0H*WqN!ZW6*k^bs(Int97Fr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4rp(UayVehd}o>50tKu^2OUOwVxT}ZA03;#!;bu?nAmt{oUBy4 zY@poWOPhrY;k(3>fof4i_Y-EjqdR_&`BxAcst5a&3?c^$bd@(H8a#AiLr4n0F*~

SpO44BN_C=$npn+` z?+G5RtE%3(T%48lxsq%lxfR%#x*?C$+?O58bgp6ghbM7gN}N9v#AG5BvGSGp6VTNN DJCk}Z diff --git a/config/secrets/circle_ci/config.yaml b/config/secrets/circle_ci/config.yaml deleted file mode 100644 index 551b9ef01d257d084ca380845f438c05666014ae..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 120 zcmV-;0EhnoM@dveQdv+`0O&!NW9*_pQKKG!6*_d~n9WEIaW84@9-VLi_xFD+xN2b5cK()bD7}Hzw0ur`wIt1IZ3#tv! a5XWiSOYyO=y`4&fN;nTZCSIsowIvRTtTjgf diff --git a/config/secrets/github/config.yaml b/config/secrets/github/config.yaml deleted file mode 100644 index 876531c104bf64293a409059ba929b1d97780148..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 152 zcmV;J0B8RIM@dveQdv+`0Pn22DV4g)7Q-^nDiNSTC7}D7&S3v#vntso2Yw?g%huT> zthnFq7*0D4om;%)05Q4<;dVX)D>=?=F_XPF3zcafuv0WT41Q-Sj6m1I)vgO%(OfCZ z(taMp4=!XbfQzqp$%cBS&v)^H5ljOnU%V*8B011HSjw8rW1n*A> "$BASH_ENV" diff --git a/scripts/ci/common/install-git-crypt.sh b/scripts/ci/common/install-git-crypt.sh index 236276d..4de784c 100755 --- a/scripts/ci/common/install-git-crypt.sh +++ b/scripts/ci/common/install-git-crypt.sh @@ -4,5 +4,5 @@ set -e set -o pipefail -apt-get update -apt-get install -y --no-install-recommends git ssh git-crypt +sudo apt-get update +sudo apt-get install -y --no-install-recommends git-crypt gnupg diff --git a/scripts/ci/common/install-gpg-key.sh b/scripts/ci/common/install-gpg-key.sh deleted file mode 100755 index 52d10c2..0000000 --- a/scripts/ci/common/install-gpg-key.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -[ -n "$DEBUG" ] && set -x -set -e -set -o pipefail - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -PROJECT_DIR="$( cd "$SCRIPT_DIR/../../.." && pwd )" - -cd "$PROJECT_DIR" - -set +e -openssl version -openssl aes-256-cbc \ - -d \ - -md sha1 \ - -in ./.circleci/gpg.private.enc \ - -k "${ENCRYPTION_PASSPHRASE}" | gpg --import - -set -e diff --git a/scripts/ci/common/install-slack-deps.sh b/scripts/ci/common/install-slack-deps.sh deleted file mode 100755 index 70abb6b..0000000 --- a/scripts/ci/common/install-slack-deps.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -[ -n "$DEBUG" ] && set -x -set -e -set -o pipefail - -apt-get update -apt-get install -y --no-install-recommends curl jq diff --git a/scripts/ci/steps/build.sh b/scripts/ci/steps/build.sh deleted file mode 100755 index d89621c..0000000 --- a/scripts/ci/steps/build.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -[ -n "$DEBUG" ] && set -x -set -e -set -o pipefail - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -PROJECT_DIR="$( cd "$SCRIPT_DIR/../../.." && pwd )" - -cd "$PROJECT_DIR" - -./go library:check diff --git a/scripts/ci/steps/merge-pull-request.sh b/scripts/ci/steps/merge-pull-request.sh deleted file mode 100755 index 63be3b1..0000000 --- a/scripts/ci/steps/merge-pull-request.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -[ -n "$DEBUG" ] && set -x -set -e -set -o pipefail - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -PROJECT_DIR="$( cd "$SCRIPT_DIR/../../.." && pwd )" - -cd "$PROJECT_DIR" - -git-crypt unlock - -CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) - -./go github:pull_requests:merge["$CURRENT_BRANCH","%s [skip ci]"] diff --git a/scripts/ci/steps/prerelease.sh b/scripts/ci/steps/prerelease.sh deleted file mode 100755 index a9bc6bf..0000000 --- a/scripts/ci/steps/prerelease.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -[ -n "$DEBUG" ] && set -x -set -e -set -o pipefail - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -PROJECT_DIR="$( cd "$SCRIPT_DIR/../../.." && pwd )" - -cd "$PROJECT_DIR" - -./go version:bump[pre] -./go release - -git status -git push --all -git push --tags diff --git a/scripts/ci/steps/release.sh b/scripts/ci/steps/release.sh deleted file mode 100755 index a9388ff..0000000 --- a/scripts/ci/steps/release.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -[ -n "$DEBUG" ] && set -x -set -e -set -o pipefail - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -PROJECT_DIR="$( cd "$SCRIPT_DIR/../../.." && pwd )" - -cd "$PROJECT_DIR" - -git pull - -./go version:bump[minor] -./go release - -git status -git push --all -git push --tags diff --git a/scripts/ci/steps/test.sh b/scripts/ci/steps/test.sh deleted file mode 100755 index d27b272..0000000 --- a/scripts/ci/steps/test.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -[ -n "$DEBUG" ] && set -x -set -e -set -o pipefail - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -PROJECT_DIR="$( cd "$SCRIPT_DIR/../../.." && pwd )" - -cd "$PROJECT_DIR" - -./go spec From 73d3c7d0f3d04b00d995a36fd5b4627151ff62ce Mon Sep 17 00:00:00 2001 From: Phil Helm Date: Wed, 22 Jul 2026 22:39:15 +0100 Subject: [PATCH 2/2] bump ffi to 1.17.4 after yank ffi 1.17.1 was yanked from RubyGems, breaking bundle install on fresh CI runners. Targeted `bundle lock --update=ffi` bumps it to 1.17.4; no other gems drift. --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1eb4f52..6cb2cd6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -44,10 +44,10 @@ GEM logger faraday-net_http (3.4.4) net-http (~> 0.5) - ffi (1.17.1) - ffi (1.17.1-arm64-darwin) - ffi (1.17.1-x86_64-darwin) - ffi (1.17.1-x86_64-linux) + ffi (1.17.4) + ffi (1.17.4-arm64-darwin) + ffi (1.17.4-x86_64-darwin) + ffi (1.17.4-x86_64-linux-gnu) formatador (1.1.0) gem-release (2.2.4) git (1.19.1)