forked from hyperb1iss/git-iris
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
225 lines (199 loc) · 7.58 KB
/
action.yml
File metadata and controls
225 lines (199 loc) · 7.58 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
name: "Git-Iris Action"
description: "AI agent that crafts perfect Git artifacts - release notes, changelogs, and more"
author: "hyperb1iss"
branding:
icon: "git-commit"
color: "purple"
inputs:
command:
description: "Command to run: release-notes, changelog"
required: false
default: "release-notes"
from:
description: "Starting Git reference (tag, commit, or branch)"
required: true
to:
description: "Ending Git reference (defaults to HEAD)"
required: false
default: "HEAD"
provider:
description: "LLM provider (openai, anthropic, google)"
required: false
default: "openai"
model:
description: "Model to use (provider-specific)"
required: false
api-key:
description: "API key for the LLM provider"
required: true
output-file:
description: "File path to write output (optional)"
required: false
version-name:
description: "Explicit version name to use"
required: false
custom-instructions:
description: "Custom instructions for generation"
required: false
update-file:
description: "Update existing file (changelog only) - prepends to existing content"
required: false
default: "false"
version:
description: "Git-Iris version to use (defaults to latest)"
required: false
default: "latest"
build-from-source:
description: "Build from source instead of downloading binary"
required: false
default: "false"
binary-path:
description: "Path to pre-built git-iris binary (skips download and build)"
required: false
outputs:
content:
description: "Generated content"
value: ${{ steps.generate.outputs.content }}
output-file:
description: "Path to the output file (if specified)"
value: ${{ steps.generate.outputs.output_file }}
# Backwards compatibility aliases
release-notes:
description: "Generated content (alias for backwards compatibility)"
value: ${{ steps.generate.outputs.content }}
release-notes-file:
description: "Output file path (alias for backwards compatibility)"
value: ${{ steps.generate.outputs.output_file }}
runs:
using: "composite"
steps:
- name: Determine platform
id: platform
shell: bash
run: |
case "${{ runner.os }}-${{ runner.arch }}" in
Linux-X64)
echo "artifact=git-iris-linux-amd64" >> $GITHUB_OUTPUT
echo "binary=git-iris" >> $GITHUB_OUTPUT
;;
Linux-ARM64)
echo "artifact=git-iris-linux-arm64" >> $GITHUB_OUTPUT
echo "binary=git-iris" >> $GITHUB_OUTPUT
;;
macOS-ARM64|macOS-X64)
echo "artifact=git-iris-macos-arm64" >> $GITHUB_OUTPUT
echo "binary=git-iris" >> $GITHUB_OUTPUT
;;
Windows-X64)
echo "artifact=git-iris-windows-gnu" >> $GITHUB_OUTPUT
echo "binary=git-iris.exe" >> $GITHUB_OUTPUT
;;
*)
echo "::error::Unsupported platform: ${{ runner.os }}-${{ runner.arch }}"
exit 1
;;
esac
- name: Use pre-built binary
if: inputs.binary-path != ''
shell: bash
run: |
echo "Using pre-built binary: ${{ inputs.binary-path }}"
echo "GIT_IRIS_BIN=${{ inputs.binary-path }}" >> $GITHUB_ENV
- name: Install Rust (for build-from-source)
if: inputs.binary-path == '' && inputs.build-from-source == 'true'
uses: dtolnay/rust-toolchain@stable
- name: Rust cache (for build-from-source)
if: inputs.binary-path == '' && inputs.build-from-source == 'true'
uses: Swatinem/rust-cache@v2
- name: Download git-iris binary
if: inputs.binary-path == '' && inputs.build-from-source != 'true'
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
echo "::group::Downloading git-iris"
if [ "${{ inputs.version }}" = "latest" ]; then
VERSION=$(gh release view --repo hyperb1iss/git-iris --json tagName -q '.tagName')
else
VERSION="${{ inputs.version }}"
fi
echo "Downloading git-iris $VERSION for ${{ steps.platform.outputs.artifact }}"
gh release download "$VERSION" \
--repo hyperb1iss/git-iris \
--pattern "${{ steps.platform.outputs.artifact }}*" \
--dir /tmp/git-iris-download
# Downloaded file keeps original name (e.g., git-iris-linux-amd64 or git-iris-windows-gnu.exe)
DOWNLOADED=$(ls /tmp/git-iris-download/)
chmod +x "/tmp/git-iris-download/$DOWNLOADED"
sudo mv "/tmp/git-iris-download/$DOWNLOADED" /usr/local/bin/${{ steps.platform.outputs.binary }}
echo "git-iris installed successfully"
git-iris --version
echo "::endgroup::"
- name: Build git-iris from source
if: inputs.binary-path == '' && inputs.build-from-source == 'true'
shell: bash
run: |
echo "::group::Building git-iris from source"
cargo build --release --locked
echo "GIT_IRIS_BIN=./target/release/git-iris" >> $GITHUB_ENV
echo "::endgroup::"
- name: Generate content
id: generate
shell: bash
env:
# LLM provider configuration
OPENAI_API_KEY: ${{ inputs.provider == 'openai' && inputs.api-key || '' }}
ANTHROPIC_API_KEY: ${{ inputs.provider == 'anthropic' && inputs.api-key || '' }}
GOOGLE_API_KEY: ${{ inputs.provider == 'google' && inputs.api-key || '' }}
IRIS_PROVIDER: ${{ inputs.provider }}
IRIS_MODEL: ${{ inputs.model }}
IRIS_INSTRUCTIONS: ${{ inputs.custom-instructions }}
# Ensure clean markdown output - no colors or formatting
NO_COLOR: "1"
TERM: dumb
CLICOLOR: "0"
CLICOLOR_FORCE: "0"
run: |
echo "::group::Running git-iris ${{ inputs.command }}"
GIT_IRIS="${GIT_IRIS_BIN:-git-iris}"
COMMAND="${{ inputs.command }}"
echo "Provider: $IRIS_PROVIDER"
echo "Model: $IRIS_MODEL"
# Build base command (--raw ensures markdown output, --quiet suppresses spinners)
# Explicitly pass --provider to ensure it's used regardless of config
CMD="$GIT_IRIS $COMMAND --from '${{ inputs.from }}' --to '${{ inputs.to }}' --provider '${{ inputs.provider }}' --raw --quiet"
# Add version name if specified
if [ -n "${{ inputs.version-name }}" ]; then
CMD="$CMD --version-name '${{ inputs.version-name }}'"
fi
# Add model if specified
if [ -n "${{ inputs.model }}" ]; then
CMD="$CMD --model '${{ inputs.model }}'"
fi
# Execute and capture output
CONTENT=$(eval $CMD)
# Handle multiline output for GitHub Actions
echo "content<<EOF" >> $GITHUB_OUTPUT
echo "$CONTENT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# Write to file if specified
if [ -n "${{ inputs.output-file }}" ]; then
OUTPUT_FILE="${{ inputs.output-file }}"
if [ "${{ inputs.update-file }}" = "true" ] && [ -f "$OUTPUT_FILE" ]; then
# Prepend new content to existing file (for changelogs)
echo "Updating existing file: $OUTPUT_FILE"
EXISTING=$(cat "$OUTPUT_FILE")
echo "$CONTENT" > "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
echo "$EXISTING" >> "$OUTPUT_FILE"
else
echo "$CONTENT" > "$OUTPUT_FILE"
fi
echo "output_file=$OUTPUT_FILE" >> $GITHUB_OUTPUT
echo "Content written to $OUTPUT_FILE"
fi
echo "::endgroup::"
# Print preview
echo "::group::Generated Content Preview"
echo "$CONTENT"
echo "::endgroup::"