Skip to content

Commit 1c98b46

Browse files
committed
Add GH workflows
1 parent 3ba3b8c commit 1c98b46

File tree

2 files changed

+171
-0
lines changed

2 files changed

+171
-0
lines changed

.github/workflows/ci.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
ruby: ['3.1', '3.2', '3.3']
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Ruby
22+
uses: ruby/setup-ruby@v1
23+
with:
24+
ruby-version: ${{ matrix.ruby }}
25+
bundler-cache: true
26+
27+
- name: Run tests
28+
run: bundle exec rspec
29+
30+
- name: Run RuboCop (if you add it)
31+
run: bundle exec rubocop
32+
continue-on-error: true
33+
34+
security:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout code
38+
uses: actions/checkout@v4
39+
40+
- name: Set up Ruby
41+
uses: ruby/setup-ruby@v1
42+
with:
43+
ruby-version: '3.2'
44+
bundler-cache: true
45+
46+
- name: Run bundle audit
47+
run: |
48+
gem install bundler-audit
49+
bundle audit --update
50+
51+
gem-build:
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Checkout code
55+
uses: actions/checkout@v4
56+
57+
- name: Set up Ruby
58+
uses: ruby/setup-ruby@v1
59+
with:
60+
ruby-version: '3.2'
61+
bundler-cache: true
62+
63+
- name: Build gem
64+
run: gem build *.gemspec
65+
66+
- name: Upload gem artifact
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: gem-file
70+
path: '*.gem'

.github/workflows/release.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Release & Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Version to release (e.g., 0.1.1)'
11+
required: true
12+
type: string
13+
prerelease:
14+
description: 'Is this a pre-release?'
15+
required: false
16+
default: false
17+
type: boolean
18+
19+
jobs:
20+
test:
21+
uses: ./.github/workflows/ci.yml
22+
23+
release:
24+
needs: test
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: write
28+
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Set up Ruby
36+
uses: ruby/setup-ruby@v1
37+
with:
38+
ruby-version: '3.2'
39+
bundler-cache: true
40+
41+
- name: Configure Git
42+
run: |
43+
git config --global user.name "github-actions[bot]"
44+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
45+
46+
- name: Update version (manual release)
47+
if: github.event_name == 'workflow_dispatch'
48+
run: |
49+
echo "Updating version to ${{ github.event.inputs.version }}"
50+
sed -i 's/VERSION = ".*"/VERSION = "${{ github.event.inputs.version }}"/' lib/ruby_llm/template/version.rb
51+
git add lib/ruby_llm/template/version.rb
52+
git commit -m "Bump version to ${{ github.event.inputs.version }}"
53+
git tag "v${{ github.event.inputs.version }}"
54+
git push origin main
55+
git push origin "v${{ github.event.inputs.version }}"
56+
57+
- name: Extract version from tag
58+
id: version
59+
run: |
60+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
61+
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
62+
else
63+
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
64+
fi
65+
66+
- name: Build gem
67+
run: |
68+
gem build *.gemspec
69+
echo "GEM_FILE=$(ls *.gem)" >> $GITHUB_ENV
70+
71+
- name: Publish to RubyGems
72+
env:
73+
RUBYGEMS_AUTH_TOKEN: ${{ secrets.RUBYGEMS_AUTH_TOKEN }}
74+
run: |
75+
mkdir -p ~/.gem
76+
echo ":rubygems_api_key: $RUBYGEMS_AUTH_TOKEN" > ~/.gem/credentials
77+
chmod 0600 ~/.gem/credentials
78+
gem push ${{ env.GEM_FILE }}
79+
80+
- name: Create GitHub Release
81+
uses: softprops/action-gh-release@v2
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84+
with:
85+
tag_name: v${{ steps.version.outputs.version }}
86+
name: Release v${{ steps.version.outputs.version }}
87+
generate_release_notes: true
88+
prerelease: ${{ github.event.inputs.prerelease == 'true' }}
89+
files: ${{ env.GEM_FILE }}
90+
body: |
91+
## Installation
92+
93+
```bash
94+
gem install ruby_llm-template -v ${{ steps.version.outputs.version }}
95+
```
96+
97+
Or add to your Gemfile:
98+
99+
```ruby
100+
gem 'ruby_llm-template', '~> ${{ steps.version.outputs.version }}'
101+
```

0 commit comments

Comments
 (0)