Skip to content

Commit ebd0fc9

Browse files
authored
Adopt reviewed GitHub releases. (#28)
1 parent 546c810 commit ebd0fc9

14 files changed

Lines changed: 362 additions & 48 deletions

‎.github/release-rules/checks.json‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"target": "branch",
3+
"enforcement": "active",
4+
"conditions": {
5+
"ref_name": {
6+
"include": [
7+
"refs/heads/main"
8+
],
9+
"exclude": []
10+
}
11+
},
12+
"name": "Gem release checks",
13+
"bypass_actors": [
14+
{
15+
"actor_id": 5,
16+
"actor_type": "RepositoryRole",
17+
"bypass_mode": "pull_request"
18+
}
19+
],
20+
"rules": [
21+
{
22+
"type": "required_status_checks",
23+
"parameters": {
24+
"strict_required_status_checks_policy": true,
25+
"do_not_enforce_on_create": false,
26+
"required_status_checks": [
27+
{
28+
"context": "3.3 on ubuntu"
29+
},
30+
{
31+
"context": "3.3 on macos"
32+
},
33+
{
34+
"context": "3.4 on ubuntu"
35+
},
36+
{
37+
"context": "3.4 on macos"
38+
},
39+
{
40+
"context": "4.0 on ubuntu"
41+
},
42+
{
43+
"context": "4.0 on macos"
44+
},
45+
{
46+
"context": "check"
47+
},
48+
{
49+
"context": "ruby on ubuntu"
50+
},
51+
{
52+
"context": "ruby on macos"
53+
},
54+
{
55+
"context": "Release validation"
56+
}
57+
]
58+
}
59+
}
60+
]
61+
}

‎.github/release-rules/history.json‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"target": "branch",
3+
"enforcement": "active",
4+
"conditions": {
5+
"ref_name": {
6+
"include": [
7+
"refs/heads/main"
8+
],
9+
"exclude": []
10+
}
11+
},
12+
"name": "Gem release history",
13+
"bypass_actors": [],
14+
"rules": [
15+
{
16+
"type": "deletion"
17+
},
18+
{
19+
"type": "non_fast_forward"
20+
}
21+
]
22+
}

‎.github/release-rules/reviews.json‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"target": "branch",
3+
"enforcement": "active",
4+
"conditions": {
5+
"ref_name": {
6+
"include": [
7+
"refs/heads/main"
8+
],
9+
"exclude": []
10+
}
11+
},
12+
"name": "Gem release reviews",
13+
"bypass_actors": [
14+
{
15+
"actor_id": 5,
16+
"actor_type": "RepositoryRole",
17+
"bypass_mode": "pull_request"
18+
}
19+
],
20+
"rules": [
21+
{
22+
"type": "pull_request",
23+
"parameters": {
24+
"required_approving_review_count": 2,
25+
"dismiss_stale_reviews_on_push": true,
26+
"require_last_push_approval": true,
27+
"required_review_thread_resolution": true,
28+
"require_code_owner_review": false,
29+
"allowed_merge_methods": [
30+
"merge",
31+
"squash",
32+
"rebase"
33+
]
34+
}
35+
}
36+
]
37+
}

‎.github/release-rules/tags.json‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "Gem release tags",
3+
"target": "tag",
4+
"enforcement": "active",
5+
"bypass_actors": [],
6+
"conditions": {
7+
"ref_name": {
8+
"include": [
9+
"refs/tags/v*"
10+
],
11+
"exclude": []
12+
}
13+
},
14+
"rules": [
15+
{
16+
"type": "deletion"
17+
},
18+
{
19+
"type": "non_fast_forward"
20+
}
21+
]
22+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Prepare release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
bump:
7+
description: Version increment
8+
required: true
9+
type: choice
10+
options: [patch, minor, major]
11+
refresh:
12+
description: Preserve and regenerate an existing release branch
13+
type: boolean
14+
default: false
15+
16+
permissions:
17+
contents: write
18+
pull-requests: write
19+
20+
concurrency:
21+
group: release-prepare
22+
cancel-in-progress: false
23+
24+
env:
25+
BUNDLE_WITH: maintenance
26+
27+
jobs:
28+
prepare:
29+
if: github.ref == 'refs/heads/main'
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v7
33+
with:
34+
ref: main
35+
fetch-depth: 0
36+
persist-credentials: false
37+
- uses: ruby/setup-ruby@v1
38+
with:
39+
ruby-version: "3.4"
40+
bundler-cache: true
41+
- name: Create release PR
42+
env:
43+
GITHUB_TOKEN: ${{ github.token }}
44+
BUMP: ${{ inputs.bump }}
45+
REFRESH: ${{ inputs.refresh }}
46+
run: |
47+
# GitHub.com's shared Actions bot ID; this identity is not for GitHub Enterprise Server.
48+
# https://github.com/actions/checkout#push-a-commit-using-the-built-in-token
49+
git config user.name 'github-actions[bot]'
50+
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
51+
case "$BUMP" in patch|minor|major) ;; *) exit 1 ;; esac
52+
bundle exec bake "gem:github:release:$BUMP" "refresh=$REFRESH"
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Publish release
2+
3+
# Inspect the exact pushed commit and publish only a validated, merged release PR.
4+
on:
5+
push:
6+
branches: ["main"]
7+
8+
permissions:
9+
contents: read
10+
pull-requests: read
11+
12+
env:
13+
BUNDLE_WITH: maintenance
14+
15+
jobs:
16+
inspect:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
release: ${{ steps.inspect.outputs.release }}
20+
commit: ${{ steps.inspect.outputs.commit }}
21+
pull_request: ${{ steps.inspect.outputs.pull_request }}
22+
steps:
23+
- uses: actions/checkout@v7
24+
with:
25+
ref: ${{ github.sha }}
26+
fetch-depth: 0
27+
persist-credentials: false
28+
- uses: ruby/setup-ruby@v1
29+
with:
30+
ruby-version: "3.4"
31+
bundler-cache: true
32+
- id: inspect
33+
env:
34+
GITHUB_TOKEN: ${{ github.token }}
35+
RELEASE_COMMIT: ${{ github.sha }}
36+
run: bundle exec bake gem:github:release:resolve
37+
38+
publish:
39+
needs: inspect
40+
if: needs.inspect.outputs.release == 'true'
41+
runs-on: ubuntu-latest
42+
environment: rubygems
43+
concurrency:
44+
group: release-publish
45+
cancel-in-progress: false
46+
queue: max
47+
env:
48+
RELEASE_PR: ${{ needs.inspect.outputs.pull_request }}
49+
permissions:
50+
contents: write
51+
pull-requests: read
52+
actions: read
53+
id-token: write
54+
attestations: write
55+
steps:
56+
- uses: actions/checkout@v7
57+
with:
58+
# Inspection verified this merged commit belongs to the default branch.
59+
ref: ${{ needs.inspect.outputs.commit }}
60+
fetch-depth: 0
61+
persist-credentials: false
62+
- uses: ruby/setup-ruby@v1
63+
with:
64+
ruby-version: "3.4"
65+
rubygems: '4.0.21'
66+
bundler-cache: true
67+
- name: Build or restore artifact
68+
id: build
69+
env:
70+
GITHUB_TOKEN: ${{ github.token }}
71+
run: bundle exec bake gem:github:release:build
72+
- name: Sign RubyGems attestation
73+
if: steps.build.outputs.restored != 'true'
74+
env:
75+
PACKAGE: ${{ steps.build.outputs.package }}
76+
run: gem exec sigstore-cli:0.2.3 sign "$PACKAGE" --bundle "$PACKAGE.sigstore.json"
77+
- name: Attest gem and release receipt
78+
if: steps.build.outputs.restored != 'true'
79+
id: attest
80+
uses: actions/attest@v4
81+
with:
82+
subject-path: |
83+
${{ steps.build.outputs.package }}
84+
pkg/release.json
85+
- name: Retain provenance bundle
86+
if: steps.build.outputs.restored != 'true'
87+
env:
88+
ATTESTATION_BUNDLE: ${{ steps.attest.outputs.bundle-path }}
89+
run: cp "$ATTESTATION_BUNDLE" pkg/provenance.sigstore.json
90+
- name: Preserve release before upload
91+
if: steps.build.outputs.restored != 'true'
92+
uses: actions/upload-artifact@v7
93+
with:
94+
name: ${{ steps.build.outputs.artifact }}
95+
path: pkg/
96+
if-no-files-found: error
97+
retention-days: 90
98+
- uses: rubygems/configure-rubygems-credentials@main
99+
- name: Verify, publish, and finalize
100+
env:
101+
GITHUB_TOKEN: ${{ github.token }}
102+
run: bundle exec bake gem:github:release:publish
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Validate release
2+
3+
on:
4+
pull_request:
5+
branches: ["main"]
6+
7+
permissions:
8+
contents: read
9+
10+
env:
11+
BUNDLE_WITH: maintenance
12+
13+
jobs:
14+
validate:
15+
name: Release validation
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v7
19+
with:
20+
ref: ${{ github.event.pull_request.head.sha }}
21+
fetch-depth: 0
22+
persist-credentials: false
23+
- uses: ruby/setup-ruby@v1
24+
with:
25+
ruby-version: "3.4"
26+
bundler-cache: true
27+
- name: Regenerate release content
28+
env:
29+
RELEASE_BASE: ${{ github.event.pull_request.base.sha }}
30+
run: bundle exec bake gem:github:release:validate "base=$RELEASE_BASE"
31+
- name: Build unsigned package
32+
run: bundle exec bake gem:build signing_key=false

‎bake.rb‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,11 @@
33
# Released under the MIT License.
44
# Copyright, 2025-2026, by Samuel Williams.
55

6-
# Update the project documentation with the new version number.
6+
# Update copyrights and project documentation for the new version.
77
#
88
# @parameter version [String] The new version number.
99
def after_gem_release_version_increment(version)
10+
context["modernize:license"].call
1011
context["releases:update"].call(version)
1112
context["utopia:project:update"].call
1213
end
13-
14-
# Create a GitHub release for the given tag.
15-
#
16-
# @parameter tag [String] The tag to create a release for.
17-
def after_gem_release(tag:, **options)
18-
context["releases:github:release"].call(tag)
19-
end

‎config/release.yaml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
schema: 1
3+
repository: socketry/protocol-websocket
4+
branch: main
5+
checks:
6+
- 3.3 on ubuntu
7+
- 3.3 on macos
8+
- 3.4 on ubuntu
9+
- 3.4 on macos
10+
- 4.0 on ubuntu
11+
- 4.0 on macos
12+
- check
13+
- ruby on ubuntu
14+
- ruby on macos
15+
- Release validation
16+
approvals: 2
17+
ruby: '3.4'
18+
environment: rubygems

‎gems.rb‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
gemspec
1111

1212
group :maintenance, optional: true do
13-
gem "bake-gem"
14-
gem "bake-modernize"
15-
gem "bake-releases"
13+
gem "bake-gem-github", "~> 0.7.0"
14+
gem "bake-modernize", "~> 0.66"
1615

1716
gem "agent-context"
1817

0 commit comments

Comments
 (0)