Skip to content

Commit 2aa67be

Browse files
authored
Automated Releases (#252)
* add a new ci job to test builds * add a new ci job to run a linter * add a new ci job for automatically publishing new releases to RubyGems and GitHub Packages * use `lib/version.rb` for fetching the gem version to use * remove extra whitespace * add extra gem metadata * ensure that the CI job runs on PRs and pushes to `main` * update `ruby/setup-ruby` pins * move CODEOWNERS into `.github/` dir * fmt * update release docs * update status badges * add pin comment * only run on `workflow_dispatch` events for now * rename `ci` job to `test` * use "scripts to rule them all" pattern -> https://github.blog/engineering/scripts-to-rule-them-all/ * add missing bootstrap * add back push to main logic * only use `script/test` and `script/lint` for now
1 parent a51f07d commit 2aa67be

File tree

12 files changed

+177
-21
lines changed

12 files changed

+177
-21
lines changed
File renamed without changes.

.github/workflows/build.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_call:
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build:
17+
name: build
18+
19+
strategy:
20+
matrix:
21+
os: [ubuntu-latest, macos-latest]
22+
runs-on: ${{ matrix.os }}
23+
24+
steps:
25+
- name: checkout
26+
uses: actions/checkout@v4
27+
28+
- uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # pin@v1.221.0
29+
with:
30+
bundler-cache: true
31+
32+
- name: build
33+
run: |
34+
GEM_NAME=$(ls | grep gemspec | cut -d. -f1)
35+
echo "Attempting to build gem $GEM_NAME..."
36+
gem build $GEM_NAME
37+
if [ $? -eq 0 ]; then
38+
echo "Gem built successfully!"
39+
else
40+
echo "Gem build failed!"
41+
exit 1
42+
fi

.github/workflows/lint.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: lint
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
lint:
14+
name: lint
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: checkout
19+
uses: actions/checkout@v4
20+
21+
- uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # pin@v1.221.0
22+
with:
23+
bundler-cache: true
24+
25+
- name: lint
26+
run: script/lint

.github/workflows/release.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- lib/version.rb
10+
11+
permissions:
12+
contents: write
13+
packages: write
14+
15+
jobs:
16+
release:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: checkout
21+
uses: actions/checkout@v4
22+
23+
- uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # pin@v1.221.0
24+
with:
25+
bundler-cache: true
26+
27+
- name: lint
28+
run: script/lint
29+
30+
- name: test
31+
run: script/test
32+
33+
- name: set GEM_NAME from gemspec
34+
run: echo "GEM_NAME=$(ls | grep gemspec | cut -d. -f1)" >> $GITHUB_ENV
35+
36+
# builds the gem and saves the version to GITHUB_ENV
37+
- name: build
38+
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
39+
40+
- name: publish to GitHub packages
41+
run: |
42+
export OWNER=$( echo ${{ github.repository }} | cut -d "/" -f 1 )
43+
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
44+
45+
- name: release
46+
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # pin@v1.14.0
47+
with:
48+
artifacts: "${{ env.GEM_NAME }}-${{ env.GEM_VERSION }}.gem"
49+
tag: "v${{ env.GEM_VERSION }}"
50+
generateReleaseNotes: true
51+
52+
- name: publish to RubyGems
53+
run: |
54+
mkdir -p ~/.gem
55+
echo -e "---\n:rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}" > ~/.gem/credentials
56+
chmod 0600 ~/.gem/credentials
57+
gem push ${{ env.GEM_NAME }}-${{ env.GEM_VERSION }}.gem
58+
rm ~/.gem/credentials
Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
1-
name: CI
1+
name: test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
29
permissions:
310
contents: read
411

5-
on: pull_request
6-
712
jobs:
813
test:
14+
runs-on: ubuntu-latest
915
strategy:
1016
fail-fast: false
1117
matrix:
1218
ruby_version: ["3.0", "3.1", "3.2", "3.3"]
13-
runs-on: ubuntu-latest
19+
1420
steps:
1521
- uses: actions/checkout@v4
22+
1623
- name: Update .ruby-version with matrix value
1724
run: echo "${{ matrix.ruby_version }}" >| .ruby-version
18-
- name: Set up Ruby
19-
uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777
25+
26+
- uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # pin@v1.221.0
2027
with:
2128
bundler-cache: true
22-
- name: Run tests
23-
run: bundle exec rake
29+
30+
- name: test
31+
run: script/test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ spec/reports
1111
test/tmp
1212
test/version_tmp
1313
tmp
14+
bin/
1415

1516
# YARD artifacts
1617
.yardoc

CONTRIBUTING.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ We welcome your contributions to the project. Thank you!
44

55
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.
66

7-
87
## What to contribute
98

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

5150
### Releasing a new version
5251

53-
1. Update `rubocop-github.gemspec` with the next version number
54-
1. Update the `CHANGELOG` with changes and contributor
55-
1. Run `bundle` to update gem version contained in the lockfile
56-
1. Make a commit: `Release v{VERSION}`
57-
1. Tag the commit : `git tag v{VERSION}`
58-
1. Create the package: `gem build rubocop-github.gemspec`
59-
1. Push to GitHub: `git push origin && git push origin --tags`
60-
1. Push to Rubygems: `gem push rubocop-github-{VERSION}.gem`
61-
1. Publish a new release on GitHub: https://github.com/github/rubocop-github/releases/new
52+
1. Update [`lib/version.rb`](lib/version.rb) with the next version number
53+
2. Update the `CHANGELOG` with changes and contributor
54+
3. Run `bundle` to update gem version contained in the lockfile
55+
4. Commit your changes and open a pull request
56+
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 🎉.

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# RuboCop GitHub ![CI](https://github.com/github/rubocop-github/workflows/CI/badge.svg?event=push)
1+
# RuboCop GitHub
2+
3+
[![test](https://github.com/github/rubocop-github/actions/workflows/test.yml/badge.svg)](https://github.com/github/rubocop-github/actions/workflows/test.yml)
4+
[![build](https://github.com/github/rubocop-github/actions/workflows/build.yml/badge.svg)](https://github.com/github/rubocop-github/actions/workflows/build.yml)
5+
[![lint](https://github.com/github/rubocop-github/actions/workflows/lint.yml/badge.svg)](https://github.com/github/rubocop-github/actions/workflows/lint.yml)
6+
[![release](https://github.com/github/rubocop-github/actions/workflows/release.yml/badge.svg)](https://github.com/github/rubocop-github/actions/workflows/release.yml)
27

38
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).
49

lib/version.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# frozen_string_literal: true
2+
3+
VERSION = "0.22.0"

rubocop-github.gemspec

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
# frozen_string_literal: true
22

3+
require_relative "lib/version"
4+
35
Gem::Specification.new do |s|
46
s.name = "rubocop-github"
5-
s.version = "0.22.0"
7+
s.version = VERSION
68
s.summary = "RuboCop GitHub"
7-
s.description = "Code style checking for GitHub Ruby repositories "
9+
s.description = "Code style checking for GitHub Ruby repositories"
810
s.homepage = "https://github.com/github/rubocop-github"
911
s.license = "MIT"
1012

13+
s.metadata = {
14+
"source_code_uri" => "https://github.com/github/rubocop-github",
15+
"documentation_uri" => "https://github.com/github/rubocop-github",
16+
"bug_tracker_uri" => "https://github.com/github/rubocop-github/issues"
17+
}
18+
1119
s.files = Dir["README.md", "STYLEGUIDE.md", "LICENSE", "config/*.yml", "lib/**/*.rb", "guides/*.md"]
1220

1321
s.add_dependency "rubocop", ">= 1.37"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy