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