-
Notifications
You must be signed in to change notification settings - Fork 1
100 lines (83 loc) · 2.62 KB
/
ci.yml
File metadata and controls
100 lines (83 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: CI
on:
pull_request:
push:
branches: [ main ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4'
bundler-cache: true
- name: Run linters
run: bundle exec rake ci:lint
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4'
bundler-cache: true
- name: Cache Claude CLI
id: cache-claude
uses: actions/cache@v4
with:
path: ~/.local/bin/claude
key: claude-cli-${{ runner.os }}-${{ github.run_number }}
restore-keys: |
claude-cli-${{ runner.os }}-
- name: Install Claude Code CLI
if: steps.cache-claude.outputs.cache-hit != 'true'
run: curl -fsSL https://claude.ai/install.sh | bash
- name: Add Claude to PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Verify Claude installation
run: claude --version
- name: Run tests
run: bundle exec rake ci:test
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
publish:
needs: [lint, test]
name: Publish to RubyGems
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4'
bundler-cache: true
- name: Build gem
run: gem build ruby_agent.gemspec
- name: Publish to RubyGems
run: |
mkdir -p ~/.gem
echo "---" > ~/.gem/credentials
echo ":rubygems_api_key: ${RUBYGEMS_API_KEY}" >> ~/.gem/credentials
chmod 0600 ~/.gem/credentials
gem push ruby_agent-*.gem
env:
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
- name: Create git tag
run: |
VERSION=$(ruby -r ./lib/ruby_agent/version.rb -e "puts RubyAgent::VERSION")
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v${VERSION}" -m "Release v${VERSION}" || echo "Tag already exists"
git push origin "v${VERSION}" || echo "Tag already pushed"