Skip to content

Commit 7129561

Browse files
authored
Merge pull request #17 from github/release-updates
Release Updates
2 parents dc5910c + 9620550 commit 7129561

27 files changed

+168
-117
lines changed

.github/workflows/acceptance.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
has_change: ${{ steps.diff.outputs.has_change}}
1818

1919
steps:
20-
- uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # pin@v2
20+
- uses: actions/checkout@v3
2121

2222
- id: fetch-base
2323
if: github.event_name == 'pull_request'
@@ -65,9 +65,9 @@ jobs:
6565
run: |
6666
echo "✅ Bypassing acceptance tests - they are not required for this change"
6767
68-
- name: Check out code
68+
- name: checkout
6969
if: ${{ needs.changes.outputs.has_change == 'true' }}
70-
uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # pin@v2
70+
uses: actions/checkout@v3
7171

7272
# Use Docker layer caching for 'docker build' and 'docker-compose build' commands.
7373
# https://github.com/satackey/action-docker-layer-caching/releases/tag/v0.0.11

.github/workflows/build.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: checkout
22+
uses: actions/checkout@v3
23+
24+
- uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # [email protected]
25+
with:
26+
bundler-cache: true
27+
28+
- name: bootstrap
29+
run: script/bootstrap
30+
31+
- name: build
32+
run: |
33+
GEM_NAME=$(ls | grep gemspec | cut -d. -f1)
34+
echo "Attempting to build gem $GEM_NAME..."
35+
gem build $GEM_NAME
36+
if [ $? -eq 0 ]; then
37+
echo "Gem built successfully!"
38+
else
39+
echo "Gem build failed!"
40+
exit 1
41+
fi

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "CodeQL"
1+
name: CodeQL
22

33
on:
44
push:
@@ -25,7 +25,7 @@ jobs:
2525

2626
steps:
2727
- name: Checkout repository
28-
uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # pin@v2
28+
uses: actions/checkout@v3
2929

3030
# Initializes the CodeQL tools for scanning.
3131
- name: Initialize CodeQL

.github/workflows/gem.yml

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,61 @@
1-
name: Publish and Release Gem
1+
name: release
2+
23
on:
3-
push:
4-
branches: [ $default-branch ]
5-
paths: [ "VERSION" ]
64
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- lib/version.rb
10+
11+
permissions:
12+
contents: write
13+
packages: write
714

815
jobs:
916
release:
1017
runs-on: ubuntu-latest
1118

1219
steps:
13-
- name: Checkout
14-
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
20+
- name: checkout
21+
uses: actions/checkout@v3
1522

16-
- name: Setup Ruby
17-
uses: ruby/setup-ruby@8a45918450651f5e4784b6031db26f4b9f76b251
23+
- uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # [email protected]
1824
with:
1925
bundler-cache: true
2026

21-
- name: Run Tests
27+
- name: bootstrap
28+
run: script/bootstrap
29+
30+
- name: lint
31+
run: bundle exec rubocop -c .rubocop.yml lib/ spec/
32+
33+
- name: test
2234
run: script/test
2335

24-
- name: Build Gem
36+
- name: set GEM_NAME from gemspec
37+
run: echo "GEM_NAME=$(ls | grep gemspec | cut -d. -f1)" >> $GITHUB_ENV
38+
39+
# builds the gem and saves the version to GITHUB_ENV
40+
- name: build
41+
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
42+
43+
- name: publish to GitHub packages
2544
run: |
26-
echo "GEM_VERSION=$(gem build entitlements-gitrepo-auditor-plugin.gemspec 2>&1 | grep Version | cut -d':' -f 2 | tr -d " \t\n\r")" >> $GITHUB_ENV
27-
- name: Publish to GitHub Packages
45+
export OWNER=$( echo ${{ github.repository }} | cut -d "/" -f 1 )
46+
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
47+
48+
- name: release
49+
uses: ncipollo/release-action@a2e71bdd4e7dab70ca26a852f29600c98b33153e # [email protected]
50+
with:
51+
artifacts: "${{ env.GEM_NAME }}-${{ env.GEM_VERSION }}.gem"
52+
tag: "v${{ env.GEM_VERSION }}"
53+
generateReleaseNotes: true
54+
55+
- name: Publish to RubyGems
2856
run: |
29-
GEM_HOST_API_KEY=${{ secrets.GITHUB_TOKEN }} gem push --KEY github --host https://rubygems.pkg.github.com/github entitlements-gitrepo-auditor-plugin-${{ env.GEM_VERSION }}.gem
57+
mkdir -p ~/.gem
58+
echo -e "---\n:rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}" > ~/.gem/credentials
59+
chmod 0600 ~/.gem/credentials
60+
gem push ${{ env.GEM_NAME }}-${{ env.GEM_VERSION }}.gem
61+
rm ~/.gem/credentials

.github/workflows/lint.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ jobs:
1414
contents: read
1515

1616
steps:
17-
- name: Check out code
18-
uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # pin@v2
17+
- name: checkout
18+
uses: actions/checkout@v3
1919

20-
- uses: ruby/setup-ruby@8029ebd6e5bd8f4e0d6f7623ea76a01ec5b1010d # pin@v1.110.0
20+
- uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # pin@v1.152.0
2121
with:
22-
ruby-version: 3.1.2
2322
bundler-cache: true
2423

2524
- name: rubocop

.github/workflows/test.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ jobs:
1414
contents: read
1515

1616
steps:
17-
- name: Check out code
18-
uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # pin@v2
17+
- name: checkout
18+
uses: actions/checkout@v3
1919

20-
- uses: ruby/setup-ruby@8029ebd6e5bd8f4e0d6f7623ea76a01ec5b1010d # pin@v1.110.0
20+
- uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # pin@v1.152.0
2121
with:
22-
ruby-version: 3.1.2
2322
bundler-cache: true
2423

2524
- name: rspec tests

.rubocop.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ inherit_gem:
33
- config/default.yml
44

55
AllCops:
6+
SuggestExtensions: false
67
DisplayCopNames: true
7-
TargetRubyVersion: 2.7.5
8+
TargetRubyVersion: 3.1
89
Exclude:
910
- 'bin/*'
1011
- 'spec/acceptance/fixtures/**/*'

Gemfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
PATH
22
remote: .
33
specs:
4-
entitlements-gitrepo-auditor-plugin (0.2.3)
4+
entitlements-gitrepo-auditor-plugin (0.3.0)
55
contracts (= 0.17)
66
entitlements (= 0.2.0)
77

88
GEM
99
remote: https://rubygems.org/
1010
specs:
11-
activesupport (7.0.6)
11+
activesupport (7.0.7.2)
1212
concurrent-ruby (~> 1.0, >= 1.0.2)
1313
i18n (>= 1.6, < 2)
1414
minitest (>= 5.1)
1515
tzinfo (~> 2.0)
16-
addressable (2.8.4)
16+
addressable (2.8.5)
1717
public_suffix (>= 2.0.2, < 6.0)
1818
ast (2.4.2)
1919
concurrent-ruby (1.1.9)
@@ -36,7 +36,7 @@ GEM
3636
i18n (1.14.1)
3737
concurrent-ruby (~> 1.0)
3838
json (2.6.3)
39-
minitest (5.18.1)
39+
minitest (5.19.0)
4040
net-ldap (0.18.0)
4141
octokit (4.25.1)
4242
faraday (>= 1, < 3)
@@ -52,7 +52,7 @@ GEM
5252
rainbow (3.1.1)
5353
rake (13.0.6)
5454
regexp_parser (2.8.1)
55-
rexml (3.2.5)
55+
rexml (3.2.6)
5656
rspec (3.8.0)
5757
rspec-core (~> 3.8.0)
5858
rspec-expectations (~> 3.8.0)

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# entitlements-gitrepo-auditor-plugin
22

3-
[![acceptance](https://github.com/github/entitlements-gitrepo-auditor-plugin/actions/workflows/acceptance.yml/badge.svg)](https://github.com/github/entitlements-gitrepo-auditor-plugin/actions/workflows/acceptance.yml) [![test](https://github.com/github/entitlements-gitrepo-auditor-plugin/actions/workflows/test.yml/badge.svg)](https://github.com/github/entitlements-gitrepo-auditor-plugin/actions/workflows/test.yml) [![lint](https://github.com/github/entitlements-gitrepo-auditor-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/github/entitlements-gitrepo-auditor-plugin/actions/workflows/lint.yml) [![coverage](https://img.shields.io/badge/coverage-100%25-success)](https://img.shields.io/badge/coverage-100%25-success) [![style](https://img.shields.io/badge/code%20style-rubocop--github-blue)](https://github.com/github/rubocop-github)
3+
[![acceptance](https://github.com/github/entitlements-gitrepo-auditor-plugin/actions/workflows/acceptance.yml/badge.svg)](https://github.com/github/entitlements-gitrepo-auditor-plugin/actions/workflows/acceptance.yml) [![test](https://github.com/github/entitlements-gitrepo-auditor-plugin/actions/workflows/test.yml/badge.svg)](https://github.com/github/entitlements-gitrepo-auditor-plugin/actions/workflows/test.yml) [![lint](https://github.com/github/entitlements-gitrepo-auditor-plugin/actions/workflows/lint.yml/badge.svg)](https://github.com/github/entitlements-gitrepo-auditor-plugin/actions/workflows/lint.yml) [![build](https://github.com/github/entitlements-gitrepo-auditor-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/github/entitlements-gitrepo-auditor-plugin/actions/workflows/build.yml) [![release](https://github.com/github/entitlements-gitrepo-auditor-plugin/actions/workflows/gem.yml/badge.svg)](https://github.com/github/entitlements-gitrepo-auditor-plugin/actions/workflows/gem.yml) [![codeql](https://github.com/github/entitlements-gitrepo-auditor-plugin/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/github/entitlements-gitrepo-auditor-plugin/actions/workflows/codeql-analysis.yml) [![coverage](https://img.shields.io/badge/coverage-100%25-success)](https://img.shields.io/badge/coverage-100%25-success) [![style](https://img.shields.io/badge/code%20style-rubocop--github-blue)](https://github.com/github/rubocop-github)
44

55
`entitlements-gitrepo-auditor-plugin` is an [entitlements-app](https://github.com/github/entitlements-app) plugin allowing further auditing capabilities in entitlements by writing each deploy log to a separate GitHub repo.
66

@@ -71,3 +71,13 @@ auditors:
7171
```
7272
7373
At the end of each `entitlements-app` run, the `entitlements-gitrepo-auditor-plugin` will write a commit to the repo defined above with the details of the deployment.
74+
75+
## Release 🚀
76+
77+
To release a new version of this Gem, do the following:
78+
79+
1. Update the version number in the [`lib/version.rb`](lib/version.rb) file
80+
2. Run `bundle install` to update the `Gemfile.lock` file with the new version
81+
3. Commit your changes, push them to GitHub, and open a PR
82+
83+
Once your PR is approved and the changes are merged, a new release will be created automatically by the [`release.yml`](.github/workflows/gem.yml) workflow. The latest version of the Gem will be published to the GitHub Package Registry and RubyGems.

VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

entitlements-gitrepo-auditor-plugin.gemspec

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# frozen_string_literal: true
22

3+
require_relative "lib/version"
4+
35
Gem::Specification.new do |s|
46
s.name = "entitlements-gitrepo-auditor-plugin"
5-
s.version = File.read("VERSION").chomp
7+
s.version = Entitlements::Version::VERSION
68
s.summary = "Entitlements GitRepo Auditor"
7-
s.description = ""
9+
s.description = "Entitlements plugin for a robust audit log"
810
s.authors = ["GitHub, Inc. Security Ops"]
911
s.email = "[email protected]"
1012
s.license = "MIT"
11-
s.files = Dir.glob("lib/**/*") + %w[VERSION]
13+
s.files = Dir.glob("lib/**/*")
1214
s.homepage = "https://github.com/github/entitlements-gitrepo-auditor-plugin"
1315
s.executables = %w[]
1416

lib/entitlements/auditor/gitrepo.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def setup
2626
@repo = Entitlements::Util::GitRepo.new(
2727
repo: config["repo"],
2828
sshkey: Base64.decode64(config["sshkey"]),
29-
logger: logger
29+
logger:
3030
)
3131
@repo.github = config["github_override"] if config["github_override"]
3232
@repo.send(operation, checkout_directory)
@@ -59,10 +59,10 @@ def commit(actions:, successful_actions:, provider_exception:)
5959
%w[update_files delete_files].each do |m|
6060
send(
6161
m.to_sym,
62-
action_hash: action_hash,
63-
successful_actions: successful_actions,
64-
sync_changes: sync_changes,
65-
valid_changes: valid_changes
62+
action_hash:,
63+
successful_actions:,
64+
sync_changes:,
65+
valid_changes:
6666
)
6767
end
6868

lib/version.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
module Entitlements
4+
module Version
5+
VERSION = "0.3.0"
6+
end
7+
end

script/release

Lines changed: 0 additions & 40 deletions
This file was deleted.

spec/acceptance/Dockerfile.entitlements-gitrepo-auditor-plugin

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ RUN gem install bundler
2222
# Bootstrap files and caching for speed
2323
COPY "vendor/cache/" "/data/entitlements/vendor/cache/"
2424
COPY "script/" "/data/entitlements/script/"
25-
COPY [".rubocop.yml", ".ruby-version", "entitlements-gitrepo-auditor-plugin.gemspec", "Gemfile", "Gemfile.lock", "VERSION", "/data/entitlements/"]
25+
COPY [".rubocop.yml", ".ruby-version", "entitlements-gitrepo-auditor-plugin.gemspec", "Gemfile", "Gemfile.lock", "/data/entitlements/"]
26+
COPY "lib/version.rb" "/data/entitlements/lib/version.rb"
2627
RUN ./script/bootstrap
2728

2829
# Source Files

spec/acceptance/tests/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def run(fixture_dir, args = [])
6363
command_parts = [binary, "--config-file", configfile] + args
6464
command = command_parts.map { |i| Shellwords.escape(i) }.join(" ")
6565
stdout, stderr, exitstatus = Open3.capture3(command)
66-
OpenStruct.new({ stdout: stdout, stderr: stderr, exitstatus: exitstatus.exitstatus, success?: exitstatus.exitstatus == 0 })
66+
OpenStruct.new({ stdout:, stderr:, exitstatus: exitstatus.exitstatus, success?: exitstatus.exitstatus == 0 })
6767
end
6868

6969
def log(priority, pattern)

0 commit comments

Comments
 (0)