From 0f07895f6dd0333c05320fb0f5987009ac489de6 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 14 Jul 2025 22:59:22 +0200 Subject: [PATCH 1/6] CI: Generate Ruby matrix dynamically --- .github/workflows/ruby.yml | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 358266b..20c21bb 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -1,3 +1,4 @@ +--- name: Ruby on: @@ -7,16 +8,29 @@ on: - main jobs: - build: + rubocop_and_matrix: + runs-on: ubuntu-24.04 + outputs: + ruby: ${{ steps.ruby.outputs.versions }} + steps: + - uses: actions/checkout@v4 + - name: Setup ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.4" + bundler-cache: true + - name: Run linter + run: bundle exec rake rubocop + - id: ruby + uses: voxpupuli/ruby-version@v1 - runs-on: ubuntu-latest + build: + runs-on: ubuntu-24.04 + needs: rubocop_and_matrix strategy: fail-fast: false matrix: - ruby: - - 3.4 - - 3.3 - - 3.2 + ruby: ${{ fromJSON(needs.rubocop_and_matrix.outputs.ruby) }} steps: - uses: actions/checkout@v4 - name: Set up Ruby @@ -25,5 +39,3 @@ jobs: ruby-version: ${{ matrix.ruby }} bundler-cache: true - run: bundle exec rspec spec --color --format documentation --order random - - name: Rubocop - run: bundle exec rake rubocop From e0f9903e6eafe6e3838711b59e01bce6dde39619 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 14 Jul 2025 23:02:56 +0200 Subject: [PATCH 2/6] Add dummy job we can depend on --- .github/workflows/ruby.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 20c21bb..e75c7ba 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -24,7 +24,7 @@ jobs: - id: ruby uses: voxpupuli/ruby-version@v1 - build: + test: runs-on: ubuntu-24.04 needs: rubocop_and_matrix strategy: @@ -39,3 +39,12 @@ jobs: ruby-version: ${{ matrix.ruby }} bundler-cache: true - run: bundle exec rspec spec --color --format documentation --order random + + tests: + needs: + - rubocop_and_matrix + - test + runs-on: ubuntu-24.04 + name: Test suite + steps: + - run: echo Test suite completed From 3e4eddef4cbdeb79c482762b50c1568c0209a2ee Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 14 Jul 2025 23:03:45 +0200 Subject: [PATCH 3/6] Delete Perforce CODEOWNERS --- CODEOWNERS | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 CODEOWNERS diff --git a/CODEOWNERS b/CODEOWNERS deleted file mode 100644 index 16493de..0000000 --- a/CODEOWNERS +++ /dev/null @@ -1,3 +0,0 @@ -# This repo is owned by Puppet Release Engineering - -* @puppetlabs/release-engineering From 4378e401fb4ce654ea2b09313bf30b10b313d45a Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 14 Jul 2025 23:05:39 +0200 Subject: [PATCH 4/6] Add changelog rake task --- Gemfile | 5 +++++ Rakefile | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/Gemfile b/Gemfile index 1e60c65..1345cb4 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,8 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' gemspec + +group :release, optional: true do + gem 'faraday-retry', '~> 2.1', require: false + gem 'github_changelog_generator', '~> 1.16', require: false +end diff --git a/Rakefile b/Rakefile index 40e792f..0060d66 100644 --- a/Rakefile +++ b/Rakefile @@ -3,3 +3,29 @@ begin rescue LoadError # the voxpupuli-rubocop gem is optional end + +begin + require 'github_changelog_generator/task' +rescue LoadError + # gem is missing +else + GitHubChangelogGenerator::RakeTask.new :changelog do |config| + config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file." + config.exclude_labels = %w[duplicate question invalid wontfix wont-fix modulesync skip-changelog github_actions] + config.user = 'OpenVoxProject' + config.project = 'packaging' + config.future_release = Gem::Specification.load("#{config.project}.gemspec").version + end + + # Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715 + require 'rbconfig' + if RbConfig::CONFIG['host_os'].include?('linux') + task :changelog do + puts 'Fixing line endings...' + changelog_file = File.join(__dir__, 'CHANGELOG.md') + changelog_txt = File.read(changelog_file) + new_contents = changelog_txt.gsub("\r\n", "\n") + File.open(changelog_file, 'w') { |file| file.puts new_contents } + end + end +end From 5e4fdce8c74540c91a305babfebe95f86582a6d3 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 14 Jul 2025 23:06:56 +0200 Subject: [PATCH 5/6] CI: Add minimal permissions --- .github/workflows/ruby.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index e75c7ba..8d40847 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -7,6 +7,9 @@ on: branches: - main +permissions: + contents: read + jobs: rubocop_and_matrix: runs-on: ubuntu-24.04 From be7de78e116b3a387a7c2c0976e32fd91a8e1454 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 14 Jul 2025 23:08:12 +0200 Subject: [PATCH 6/6] Add OpenVoxProject release CI --- .github/release.yml | 40 ++++++++++++++++++ .github/workflows/gem_release.yaml | 65 ++++++++++++++++++++++++++++++ .github/workflows/release.yml | 24 ----------- 3 files changed, 105 insertions(+), 24 deletions(-) create mode 100644 .github/release.yml create mode 100644 .github/workflows/gem_release.yaml delete mode 100644 .github/workflows/release.yml diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..d0bd336 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,40 @@ +--- +# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes + +changelog: + exclude: + labels: + - duplicate + - invalid + - modulesync + - question + - skip-changelog + - wont-fix + - wontfix + - github_actions + + categories: + - title: Breaking Changes 🛠 + labels: + - backwards-incompatible + + - title: New Features 🎉 + labels: + - enhancement + + - title: Bug Fixes 🐛 + labels: + - bug + + - title: Documentation Updates 📚 + labels: + - documentation + - docs + + - title: Dependency Updates ⬆️ + labels: + - dependencies + + - title: Other Changes + labels: + - "*" diff --git a/.github/workflows/gem_release.yaml b/.github/workflows/gem_release.yaml new file mode 100644 index 0000000..2699a4a --- /dev/null +++ b/.github/workflows/gem_release.yaml @@ -0,0 +1,65 @@ +--- +name: Gem Release + +on: + push: + tags: + - '*' + +permissions: {} + +jobs: + build-release: + # Prevent releases from forked repositories + if: github.repository_owner == 'OpenVoxProject' + name: Build the gem + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - name: Install Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 'ruby' + - name: Build gem + shell: bash + run: gem build --verbose *.gemspec + - name: Upload gem to GitHub cache + uses: actions/upload-artifact@v4 + with: + name: gem-artifact + path: '*.gem' + retention-days: 1 + compression-level: 0 + + create-github-release: + needs: build-release + name: Create GitHub release + runs-on: ubuntu-24.04 + permissions: + contents: write # clone repo and create release + steps: + - name: Download gem from GitHub cache + uses: actions/download-artifact@v4 + with: + name: gem-artifact + - name: Create Release + shell: bash + env: + GH_TOKEN: ${{ github.token }} + run: gh release create --repo ${{ github.repository }} ${{ github.ref_name }} --generate-notes *.gem + + release-to-github: + needs: build-release + name: Release to GitHub + runs-on: ubuntu-24.04 + permissions: + packages: write # publish to rubygems.pkg.github.com + steps: + - name: Download gem from GitHub cache + uses: actions/download-artifact@v4 + with: + name: gem-artifact + - name: Publish gem to GitHub packages + run: gem push --host https://rubygems.pkg.github.com/${{ github.repository_owner }} *.gem + env: + GEM_HOST_API_KEY: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 7afc3b2..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Gem release - -on: - push: - tags: - - '*' - -jobs: - release: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Build gem - uses: scarhand/actions-ruby@master - with: - args: build *.gemspec - - name: Publish gem - uses: scarhand/actions-ruby@master - env: - RUBYGEMS_AUTH_TOKEN: ${{ secrets.RUBYGEMS_AUTH_TOKEN }} - with: - args: push *.gem -