Skip to content

Automated Releases #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
42 changes: 42 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: build

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_call:

permissions:
contents: read

jobs:
build:
name: build

strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}

steps:
- name: checkout
uses: actions/checkout@v4

- uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # pin@v1.221.0
with:
bundler-cache: true

- name: build
run: |
GEM_NAME=$(ls | grep gemspec | cut -d. -f1)
echo "Attempting to build gem $GEM_NAME..."
gem build $GEM_NAME
if [ $? -eq 0 ]; then
echo "Gem built successfully!"
else
echo "Gem build failed!"
exit 1
fi
26 changes: 26 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: lint

on:
push:
branches:
- main
pull_request:

permissions:
contents: read

jobs:
lint:
name: lint
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v4

- uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # pin@v1.221.0
with:
bundler-cache: true

- name: lint
run: script/lint
58 changes: 58 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: release

on:
workflow_dispatch:
push:
branches:
- main
paths:
- lib/version.rb

permissions:
contents: write
packages: write

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v4

- uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # pin@v1.221.0
with:
bundler-cache: true

- name: lint
run: script/lint

- name: test
run: script/test

- name: set GEM_NAME from gemspec
run: echo "GEM_NAME=$(ls | grep gemspec | cut -d. -f1)" >> $GITHUB_ENV

# builds the gem and saves the version to GITHUB_ENV
- name: build
run: echo "GEM_VERSION=$(gem build ${{ env.GEM_NAME }}.gemspec 2>&1 | grep Version | cut -d':' -f 2 | tr -d " \t\n\r")" >> $GITHUB_ENV

- name: publish to GitHub packages
run: |
export OWNER=$( echo ${{ github.repository }} | cut -d "/" -f 1 )
GEM_HOST_API_KEY=${{ secrets.GITHUB_TOKEN }} gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} ${{ env.GEM_NAME }}-${{ env.GEM_VERSION }}.gem

- name: release
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # pin@v1.14.0
with:
artifacts: "${{ env.GEM_NAME }}-${{ env.GEM_VERSION }}.gem"
tag: "v${{ env.GEM_VERSION }}"
generateReleaseNotes: true

- name: publish to RubyGems
run: |
mkdir -p ~/.gem
echo -e "---\n:rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}" > ~/.gem/credentials
chmod 0600 ~/.gem/credentials
gem push ${{ env.GEM_NAME }}-${{ env.GEM_VERSION }}.gem
rm ~/.gem/credentials
24 changes: 16 additions & 8 deletions .github/workflows/ci.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
name: CI
name: test

on:
push:
branches:
- main
pull_request:

permissions:
contents: read

on: pull_request

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby_version: ["3.0", "3.1", "3.2", "3.3"]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Update .ruby-version with matrix value
run: echo "${{ matrix.ruby_version }}" >| .ruby-version
- name: Set up Ruby
uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777

- uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # pin@v1.221.0
with:
bundler-cache: true
- name: Run tests
run: bundle exec rake

- name: test
run: script/test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ spec/reports
test/tmp
test/version_tmp
tmp
bin/

# YARD artifacts
.yardoc
Expand Down
15 changes: 5 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ We welcome your contributions to the project. Thank you!

Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.


## What to contribute

This repository, `rubocop-github`, is part of a broader RuboCop ecosystem.
Expand Down Expand Up @@ -50,12 +49,8 @@ Rubocop regularly releases new versions with new cops. We want to keep up to dat

### Releasing a new version

1. Update `rubocop-github.gemspec` with the next version number
1. Update the `CHANGELOG` with changes and contributor
1. Run `bundle` to update gem version contained in the lockfile
1. Make a commit: `Release v{VERSION}`
1. Tag the commit : `git tag v{VERSION}`
1. Create the package: `gem build rubocop-github.gemspec`
1. Push to GitHub: `git push origin && git push origin --tags`
1. Push to Rubygems: `gem push rubocop-github-{VERSION}.gem`
1. Publish a new release on GitHub: https://github.com/github/rubocop-github/releases/new
1. Update [`lib/version.rb`](lib/version.rb) with the next version number
2. Update the `CHANGELOG` with changes and contributor
3. Run `bundle` to update gem version contained in the lockfile
4. Commit your changes and open a pull request
5. When the pull request is approved and merged into `main`, the [`.github/workflows/release.yml`](.github/workflows/release.yml) workflow will automatically run to release the new version to RubyGems and GitHub Packages 🎉.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# RuboCop GitHub ![CI](https://github.com/github/rubocop-github/workflows/CI/badge.svg?event=push)
# RuboCop GitHub

[![test](https://github.com/github/rubocop-github/actions/workflows/test.yml/badge.svg)](https://github.com/github/rubocop-github/actions/workflows/test.yml)
[![build](https://github.com/github/rubocop-github/actions/workflows/build.yml/badge.svg)](https://github.com/github/rubocop-github/actions/workflows/build.yml)
[![lint](https://github.com/github/rubocop-github/actions/workflows/lint.yml/badge.svg)](https://github.com/github/rubocop-github/actions/workflows/lint.yml)
[![release](https://github.com/github/rubocop-github/actions/workflows/release.yml/badge.svg)](https://github.com/github/rubocop-github/actions/workflows/release.yml)

This repository provides recommended RuboCop configuration and additional Cops for use on GitHub open source and internal Ruby projects, and is the home of [GitHub's Ruby Style Guide](./STYLEGUIDE.md).

Expand Down
3 changes: 3 additions & 0 deletions lib/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# frozen_string_literal: true

VERSION = "0.22.0"
12 changes: 10 additions & 2 deletions rubocop-github.gemspec
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
# frozen_string_literal: true

require_relative "lib/version"

Gem::Specification.new do |s|
s.name = "rubocop-github"
s.version = "0.22.0"
s.version = VERSION
s.summary = "RuboCop GitHub"
s.description = "Code style checking for GitHub Ruby repositories "
s.description = "Code style checking for GitHub Ruby repositories"
s.homepage = "https://github.com/github/rubocop-github"
s.license = "MIT"

s.metadata = {
"source_code_uri" => "https://github.com/github/rubocop-github",
"documentation_uri" => "https://github.com/github/rubocop-github",
"bug_tracker_uri" => "https://github.com/github/rubocop-github/issues"
}

s.files = Dir["README.md", "STYLEGUIDE.md", "LICENSE", "config/*.yml", "lib/**/*.rb", "guides/*.md"]

s.add_dependency "rubocop", ">= 1.37"
Expand Down
5 changes: 5 additions & 0 deletions script/lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! /usr/bin/env bash

set -e

bundle exec rake rubocop
5 changes: 5 additions & 0 deletions script/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! /usr/bin/env bash

set -e

bundle exec rake test