forked from danny-avila/agents
-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (121 loc) · 4.26 KB
/
Copy pathpublish.yml
File metadata and controls
142 lines (121 loc) · 4.26 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
name: Publish Package
on:
push:
branches:
- main
workflow_dispatch:
permissions:
id-token: write # Required for OIDC trusted publishing
contents: read
jobs:
validate:
uses: ./.github/workflows/validate.yml
secrets: inherit
publish:
needs: validate
runs-on: ubuntu-latest
environment: publish # Must match npm trusted publisher config
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '24.x'
registry-url: 'https://registry.npmjs.org'
- name: Update npm for OIDC support
run: npm install -g npm@latest # Must be 11.5.1+ for provenance
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
env:
NODE_ENV: production
- name: Prune development dependencies
run: npm prune --production
- name: Check version change
id: check
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
PUBLISHED_VERSION=$(npm view @librechat/agents version 2>/dev/null || echo "0.0.0")
if [ "$PACKAGE_VERSION" = "$PUBLISHED_VERSION" ]; then
echo "No version change, skipping publish"
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "Version changed, proceeding with publish"
echo "skip=false" >> $GITHUB_OUTPUT
fi
- name: Pack package
if: steps.check.outputs.skip != 'true'
run: npm pack
- name: Determine publish tag
if: steps.check.outputs.skip != 'true'
id: publish_tag
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
if echo "$PACKAGE_VERSION" | grep -q "-"; then
echo "tag=dev" >> $GITHUB_OUTPUT
else
echo "tag=latest" >> $GITHUB_OUTPUT
fi
- name: Publish
if: steps.check.outputs.skip != 'true'
run: npm publish $(ls librechat-agents-*.tgz) --access public --provenance --tag ${{ steps.publish_tag.outputs.tag }}
env:
NODE_ENV: production
release:
needs: publish
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '24.x'
- name: Detect version commit
id: version
run: |
VERSION=$(git log -1 --pretty=%s "$GITHUB_SHA")
if echo "$VERSION" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "is_version=true" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "is_version=false" >> "$GITHUB_OUTPUT"
echo "Head commit subject '$VERSION' is not a release commit; skipping."
- name: Validate package version
if: steps.version.outputs.is_version == 'true'
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
VERSION="${{ steps.version.outputs.version }}"
if [ "v$PACKAGE_VERSION" != "$VERSION" ]; then
echo "::error title=Version mismatch::Commit subject is $VERSION, but package.json version is $PACKAGE_VERSION."
exit 1
fi
- name: Create GitHub release
if: steps.version.outputs.is_version == 'true'
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.version.outputs.version }}
run: |
if git rev-parse --verify --quiet "refs/tags/$VERSION" >/dev/null; then
TAG_SHA=$(git rev-list -n 1 "$VERSION")
if [ "$TAG_SHA" != "$GITHUB_SHA" ]; then
echo "::error title=Tag points at a different commit::Tag $VERSION points to $TAG_SHA, expected $GITHUB_SHA."
exit 1
fi
fi
if gh release view "$VERSION" >/dev/null 2>&1; then
echo "Release $VERSION already exists; skipping."
exit 0
fi
gh release create "$VERSION" \
--target "$GITHUB_SHA" \
--title "$VERSION" \
--generate-notes