-
-
Notifications
You must be signed in to change notification settings - Fork 392
101 lines (88 loc) · 2.53 KB
/
main.yml
File metadata and controls
101 lines (88 loc) · 2.53 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
101
name: Main CI
on:
push:
branches: ["main"]
paths:
- "lib/**"
- "spec/**"
- "gemfiles/**"
- "Gemfile"
- "Rakefile"
- "Appraisals"
- "ruby_llm.gemspec"
- ".gitleaks.toml"
- ".gitleaksignore"
- ".github/workflows/_gitleaks.yml"
- ".github/workflows/_lint.yml"
- ".github/workflows/_test-matrix.yml"
- ".github/workflows/main.yml"
- ".github/workflows/release.yml"
- "lib/ruby_llm/version.rb"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: main-ci-${{ github.ref }}
cancel-in-progress: true
jobs:
gitleaks:
uses: ./.github/workflows/_gitleaks.yml
lint:
uses: ./.github/workflows/_lint.yml
with:
ruby-version: "4.0"
bundler-cache: true
test:
needs: [gitleaks, lint]
uses: ./.github/workflows/_test-matrix.yml
with:
bundler-cache: true
secrets: inherit
release_needed:
name: Release Gate
needs: [test]
runs-on: ubuntu-latest
outputs:
should_release: ${{ steps.check_version.outputs.version_changed }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "4.0"
- name: Check if version needs publishing
id: check_version
run: |
set -euo pipefail
VERSION_FILE="./lib/ruby_llm/version.rb"
VERSION=$(ruby -r "$VERSION_FILE" -e "puts RubyLLM::VERSION" 2>/dev/null)
if [ -z "$VERSION" ]; then
echo "Error: Could not extract VERSION from $VERSION_FILE" >&2
exit 1
fi
echo "Local version: $VERSION"
GEM_NAME="ruby_llm"
ALL_PUBLISHED_VERSIONS=$(( \
gem list ^${GEM_NAME}$ -r --all 2>/dev/null || true; \
gem list ^${GEM_NAME}$ -r --prerelease 2>/dev/null || true; \
) | sed -n 's/.*(\(.*\)).*/\1/p' \
| tr ',' '\n' \
| sed 's/^[[:space:]]*//;s/[[:space:]]*$//' \
| grep . \
| sort -u )
if echo "$ALL_PUBLISHED_VERSIONS" | grep -Fxq "$VERSION"; then
echo "version_changed=false" >> "$GITHUB_OUTPUT"
else
echo "version_changed=true" >> "$GITHUB_OUTPUT"
fi
shell: bash
release:
if: needs.release_needed.outputs.should_release == 'true'
needs: [release_needed]
uses: ./.github/workflows/release.yml
permissions:
contents: read
packages: write
secrets: inherit