Skip to content

Commit 94e7265

Browse files
authored
Merge pull request #417 from smalruby/feature/smalruby3-gem-publishing
feat: prepare smalruby3 gem for RubyGems publishing (v26.3.291)
2 parents af7c98e + 8e5cda4 commit 94e7265

9 files changed

Lines changed: 473 additions & 3 deletions

File tree

.claude/rules/ruby/smalruby3.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,50 @@ paths:
1212

1313
smalruby3 は scratch-vm の Ruby 実装。smalruby3-editor で生成した Ruby スクリプトをデスクトップでネイティブ実行する。
1414

15+
## RubyGems 公開
16+
17+
- **gem 名**: `smalruby3`https://rubygems.org/gems/smalruby3)
18+
- **所有者**: Kouji Takao
19+
20+
### バージョニング: YY.MR.DDR
21+
22+
semantic versioning 互換かつリリース日推測可能な形式:
23+
24+
| フィールド | 意味 ||
25+
|-----------|------|-----|
26+
| `YY` (MAJOR) | 年の下2桁 | `26` = 2026 |
27+
| `MR` (MINOR) | 月 × 10 + 月内リリース番号 | `31` = 3月1回目, `32` = 3月2回目 |
28+
| `DDR` (PATCH) | 日 × 10 + 日内リリース番号 | `291` = 29日1回目, `292` = 29日2回目 |
29+
30+
****:
31+
- `26.31.291` — 2026年3月29日、月内1回目、日内1回目
32+
- `26.31.292` — 同日2回目
33+
- `26.32.301` — 3月30日、月内2回目(機能追加)
34+
- `26.41.11` — 4月1日、月内1回目
35+
36+
**CRITICAL**: MINOR を上げても月が変わったことを意味しない。月内の機能リリース回数を表す。
37+
38+
### ライセンス
39+
40+
- **smalruby3 本体**: MIT
41+
- **依存ライブラリ**(LICENSE の Third-Party Notices に記載):
42+
- ruby-sdl2: LGPL-3.0(gem 依存、動的リンク)
43+
- resvg: MPL-2.0(Rust crate、smalruby3_imageutil にコンパイル)
44+
- rsdl: Ruby's License(smalruby3_launcher の元コード)
45+
46+
### gem ビルド・公開
47+
48+
```bash
49+
# ビルド
50+
cd ruby/smalruby3
51+
gem build smalruby3.gemspec
52+
53+
# 公開
54+
gem push smalruby3-YY.MR.DDR.gem
55+
```
56+
57+
**注意**: `spec.files``Dir[...]` で列挙し、`ext/smalruby3_imageutil/target/` を除外する。
58+
1559
## Tech Stack
1660

1761
- **Ruby**: 3.3+ (`rbenv local 3.3.9` が設定済み)
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
name: gem-release
3+
description: "Build and release the smalruby3 gem to RubyGems. Handles version bump, gem build, and push."
4+
argument-hint: "[version e.g. 26.31.291]"
5+
---
6+
7+
# /gem-release - smalruby3 gem リリース
8+
9+
smalruby3 gem をビルドして RubyGems に公開する。
10+
11+
## 引数
12+
13+
- `$ARGUMENTS` — リリースバージョン(例: `26.31.291`
14+
15+
バージョン未指定の場合は `ruby/smalruby3/lib/smalruby3/version.rb` の現在のバージョンを使用する。
16+
17+
## バージョニング: YY.MR.DDR
18+
19+
| フィールド | 意味 ||
20+
|-----------|------|-----|
21+
| YY (MAJOR) | 年の下2桁 | 26 = 2026 |
22+
| MR (MINOR) | 月 × 10 + 月内リリース番号 | 31 = 3月1回目 |
23+
| DDR (PATCH) | 日 × 10 + 日内リリース番号 | 291 = 29日1回目 |
24+
25+
## 手順
26+
27+
### Step 1: バージョン確認・更新
28+
29+
1. `ruby/smalruby3/lib/smalruby3/version.rb` の現在のバージョンを読む
30+
2. 引数でバージョンが指定されている場合:
31+
- `version.rb` を更新する
32+
- YY.MR.DDR 形式であることを検証する
33+
3. 引数がない場合:
34+
- 現在のバージョンをそのまま使用する
35+
- ユーザーに確認: 「バージョン X.XX.XXX でリリースしますか?」
36+
37+
### Step 2: テスト・lint
38+
39+
```bash
40+
docker compose run --rm smalruby3 bash -c "bundle exec standardrb && bundle exec rake test"
41+
```
42+
43+
テストが失敗した場合はリリースを中止する。
44+
45+
### Step 3: gem ビルド
46+
47+
```bash
48+
cd ruby/smalruby3
49+
gem build smalruby3.gemspec
50+
```
51+
52+
ビルド成功を確認し、`gem specification smalruby3-VERSION.gem` で metadata を表示する。
53+
54+
### Step 4: ユーザーに最終確認
55+
56+
以下を表示してユーザーに確認を求める:
57+
- バージョン
58+
- gem ファイル名
59+
- gem に含まれるファイル数
60+
- 依存関係
61+
62+
`gem push` を実行してよいですか?」と確認する。
63+
64+
### Step 5: gem push
65+
66+
**IMPORTANT**: この手順はユーザーの明示的な承認後のみ実行する。
67+
68+
```bash
69+
cd ruby/smalruby3
70+
gem push smalruby3-VERSION.gem
71+
```
72+
73+
初回は認証情報の入力が必要。ユーザーに `! gem push smalruby3-VERSION.gem` の実行を案内する(インタラクティブ認証が必要なため)。
74+
75+
### Step 6: タグ付け・コミット・プッシュ
76+
77+
1. バージョン更新がある場合はコミット:
78+
```bash
79+
git add ruby/smalruby3/lib/smalruby3/version.rb
80+
git commit -m "release: smalruby3 vVERSION"
81+
```
82+
83+
2. タグを作成:
84+
```bash
85+
git tag smalruby3-vVERSION
86+
```
87+
88+
3. プッシュ:
89+
```bash
90+
git push origin HEAD
91+
git push origin smalruby3-vVERSION
92+
```
93+
94+
### Step 7: 完了報告
95+
96+
- RubyGems の URL: https://rubygems.org/gems/smalruby3/versions/VERSION
97+
- タグ: `smalruby3-vVERSION`
98+
- 次回リリース時のバージョン例を提示

.github/workflows/ci-ruby.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ jobs:
3636
run: bundle exec standardrb
3737

3838
unit-test:
39-
name: "[smalruby3] Unit Tests"
39+
name: "[smalruby3] Unit Tests (Ruby ${{ matrix.ruby }})"
4040
runs-on: ubuntu-latest
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
ruby: ['3.3', '3.4', '4.0']
4145
defaults:
4246
run:
4347
working-directory: ruby/smalruby3
@@ -51,7 +55,7 @@ jobs:
5155
uses: dtolnay/rust-toolchain@stable
5256
- uses: ruby/setup-ruby@v1
5357
with:
54-
ruby-version-file: ruby/smalruby3/.ruby-version
58+
ruby-version: ${{ matrix.ruby }}
5559
bundler-cache: true
5660
working-directory: ruby/smalruby3
5761
- name: Compile native extension
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: Gem Build Check (cross-platform)
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
ruby-version:
7+
description: 'Ruby version to test'
8+
required: false
9+
default: '3.4'
10+
type: choice
11+
options:
12+
- '3.3'
13+
- '3.4'
14+
- '4.0'
15+
16+
concurrency:
17+
group: "${{ github.workflow }} @ ${{ github.head_ref || github.ref }}"
18+
cancel-in-progress: true
19+
20+
jobs:
21+
build-linux:
22+
name: "Build gem (Linux / Ruby ${{ inputs.ruby-version || '3.4' }})"
23+
runs-on: ubuntu-latest
24+
defaults:
25+
run:
26+
working-directory: ruby/smalruby3
27+
steps:
28+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
29+
30+
- name: Install SDL2 development libraries
31+
run: |
32+
sudo apt-get update
33+
sudo apt-get install -y libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev
34+
35+
- name: Install Rust toolchain
36+
uses: dtolnay/rust-toolchain@stable
37+
38+
- uses: ruby/setup-ruby@v1
39+
with:
40+
ruby-version: ${{ inputs.ruby-version || '3.4' }}
41+
bundler-cache: true
42+
working-directory: ruby/smalruby3
43+
44+
- name: Build gem
45+
run: gem build smalruby3.gemspec
46+
47+
- name: Install gem locally
48+
run: gem install --local smalruby3-*.gem --no-document
49+
50+
- name: Compile native extension
51+
run: bundle exec rake compile
52+
53+
- name: Run tests
54+
run: bundle exec rake test
55+
56+
- name: Verify smalruby3 loads
57+
run: ruby -r smalruby3 -e 'puts "smalruby3 v#{Smalruby3::VERSION} loaded OK"'
58+
59+
- name: Upload gem artifact
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: smalruby3-gem-linux
63+
path: ruby/smalruby3/smalruby3-*.gem
64+
65+
build-windows:
66+
name: "Build gem (Windows / Ruby ${{ inputs.ruby-version || '3.4' }})"
67+
runs-on: windows-latest
68+
defaults:
69+
run:
70+
working-directory: ruby/smalruby3
71+
steps:
72+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
73+
74+
- name: Install SDL2 via MSYS2
75+
uses: msys2/setup-msys2@v2
76+
with:
77+
msystem: UCRT64
78+
update: true
79+
install: >-
80+
mingw-w64-ucrt-x86_64-SDL2
81+
mingw-w64-ucrt-x86_64-SDL2_image
82+
mingw-w64-ucrt-x86_64-SDL2_mixer
83+
mingw-w64-ucrt-x86_64-SDL2_ttf
84+
85+
- name: Install Rust toolchain
86+
uses: dtolnay/rust-toolchain@stable
87+
88+
- uses: ruby/setup-ruby@v1
89+
with:
90+
ruby-version: ${{ inputs.ruby-version || '3.4' }}
91+
bundler-cache: true
92+
working-directory: ruby/smalruby3
93+
94+
- name: Add MSYS2 to PATH
95+
shell: bash
96+
run: echo "C:/msys64/ucrt64/bin" >> "$GITHUB_PATH"
97+
98+
- name: Build gem
99+
run: gem build smalruby3.gemspec
100+
101+
- name: Compile native extension
102+
shell: bash
103+
env:
104+
CPATH: C:/msys64/ucrt64/include
105+
LIBRARY_PATH: C:/msys64/ucrt64/lib
106+
PKG_CONFIG_PATH: C:/msys64/ucrt64/lib/pkgconfig
107+
run: bundle exec rake compile
108+
109+
- name: Run tests
110+
shell: bash
111+
env:
112+
CPATH: C:/msys64/ucrt64/include
113+
LIBRARY_PATH: C:/msys64/ucrt64/lib
114+
PKG_CONFIG_PATH: C:/msys64/ucrt64/lib/pkgconfig
115+
run: bundle exec rake test
116+
117+
- name: Verify smalruby3 loads
118+
run: ruby -r smalruby3 -e "puts \"smalruby3 v#{Smalruby3::VERSION} loaded OK\""
119+
120+
- name: Upload gem artifact
121+
uses: actions/upload-artifact@v4
122+
with:
123+
name: smalruby3-gem-windows
124+
path: ruby/smalruby3/smalruby3-*.gem

.github/workflows/release-gem.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Release - smalruby3 gem
2+
3+
on:
4+
push:
5+
tags:
6+
- 'smalruby3-v*'
7+
8+
permissions:
9+
contents: write
10+
id-token: write
11+
12+
jobs:
13+
test:
14+
name: "[smalruby3] Test before release"
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
ruby: ['3.3', '3.4', '4.0']
20+
defaults:
21+
run:
22+
working-directory: ruby/smalruby3
23+
steps:
24+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
25+
- name: Install SDL2 development libraries
26+
run: |
27+
sudo apt-get update
28+
sudo apt-get install -y libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev
29+
- name: Install Rust toolchain
30+
uses: dtolnay/rust-toolchain@stable
31+
- uses: ruby/setup-ruby@v1
32+
with:
33+
ruby-version: ${{ matrix.ruby }}
34+
bundler-cache: true
35+
working-directory: ruby/smalruby3
36+
- name: Compile native extension
37+
run: bundle exec rake compile
38+
- name: Run lint
39+
if: matrix.ruby == '4.0'
40+
run: bundle exec standardrb
41+
- name: Run unit tests
42+
run: bundle exec rake test
43+
44+
release:
45+
name: "[smalruby3] Publish to RubyGems"
46+
needs: test
47+
runs-on: ubuntu-latest
48+
environment: rubygems
49+
defaults:
50+
run:
51+
working-directory: ruby/smalruby3
52+
steps:
53+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
54+
55+
- name: Extract version from tag
56+
id: version
57+
run: |
58+
VERSION="${GITHUB_REF_NAME#smalruby3-v}"
59+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
60+
echo "Releasing smalruby3 v${VERSION}"
61+
62+
- name: Verify version matches
63+
run: |
64+
GEM_VERSION=$(ruby -r ./lib/smalruby3/version -e 'puts Smalruby3::VERSION')
65+
TAG_VERSION="${{ steps.version.outputs.version }}"
66+
if [ "$GEM_VERSION" != "$TAG_VERSION" ]; then
67+
echo "::error::Version mismatch: gem=$GEM_VERSION tag=$TAG_VERSION"
68+
exit 1
69+
fi
70+
71+
- name: Install SDL2 development libraries
72+
run: |
73+
sudo apt-get update
74+
sudo apt-get install -y libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev
75+
76+
- uses: ruby/setup-ruby@v1
77+
with:
78+
ruby-version-file: ruby/smalruby3/.ruby-version
79+
bundler-cache: true
80+
working-directory: ruby/smalruby3
81+
82+
- name: Build gem
83+
run: gem build smalruby3.gemspec
84+
85+
- name: Push to RubyGems (Trusted Publishing)
86+
uses: rubygems/release-gem@v1
87+
with:
88+
working-directory: ruby/smalruby3
89+
90+
- name: Create GitHub Release
91+
env:
92+
GH_TOKEN: ${{ github.token }}
93+
run: |
94+
gh release create "$GITHUB_REF_NAME" \
95+
--repo "$GITHUB_REPOSITORY" \
96+
--title "smalruby3 v${{ steps.version.outputs.version }}" \
97+
--generate-notes \
98+
smalruby3-${{ steps.version.outputs.version }}.gem

0 commit comments

Comments
 (0)