-
Notifications
You must be signed in to change notification settings - Fork 6
130 lines (108 loc) · 3.66 KB
/
build-and-release.yml
File metadata and controls
130 lines (108 loc) · 3.66 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
name: Build and Release
on:
workflow_call:
inputs:
tag:
description: 'The tag to release (e.g., v0.2.6)'
required: true
type: string
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.tag }}
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Build extension
run: npm run build
- name: Get version from tag
id: version
run: echo "VERSION=${TAG#v}" >> $GITHUB_OUTPUT
env:
TAG: ${{ inputs.tag }}
- name: Update versions in config files
run: |
set -e
VERSION="${{ steps.version.outputs.VERSION }}"
# Update package.json version
npm version "$VERSION" --no-git-tag-version --allow-same-version
# Helper function to safely update JSON file version
update_json_version() {
local file="$1"
local tmp_file="${file}.tmp"
# Check file exists
if [[ ! -f "$file" ]]; then
echo "Error: $file not found"
exit 1
fi
# Update version to temp file
if ! jq --arg v "$VERSION" '.version = $v' "$file" > "$tmp_file"; then
echo "Error: jq failed to process $file"
rm -f "$tmp_file"
exit 1
fi
# Validate temp file is well-formed JSON
if ! jq empty "$tmp_file" 2>/dev/null; then
echo "Error: Invalid JSON produced for $file"
rm -f "$tmp_file"
exit 1
fi
# Move temp file into place
mv "$tmp_file" "$file"
echo "Updated version in $file to $VERSION"
}
# Update both config files
update_json_version "gemini-extension.json"
update_json_version "release/gemini-extension.json"
- name: Create release archive
run: |
set -e
errors=()
# Validate required directories exist
for dir in dist commands; do
if [[ ! -d "$dir" ]]; then
errors+=("Missing required directory: $dir")
fi
done
# Validate required files exist
for file in release/gemini-extension.json deep-research-GEMINI.md dist/index.js; do
if [[ ! -f "$file" ]]; then
errors+=("Missing required file: $file")
fi
done
# Fail if any validation errors
if [[ ${#errors[@]} -gt 0 ]]; then
echo "Error: Release archive validation failed:"
for err in "${errors[@]}"; do
echo " - $err"
done
exit 1
fi
# Create archive with bundled output (no node_modules needed)
tar -czvf release/gemini-deep-research.tar.gz \
--transform 's|release/gemini-extension.json|gemini-extension.json|' \
dist \
commands \
release/gemini-extension.json \
deep-research-GEMINI.md
echo "Release archive created: release/gemini-deep-research.tar.gz"
echo "Archive contents:"
tar -tzvf release/gemini-deep-research.tar.gz
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.tag }}
files: release/gemini-deep-research.tar.gz
generate_release_notes: true
make_latest: true