-
Notifications
You must be signed in to change notification settings - Fork 3
262 lines (237 loc) · 8.77 KB
/
Copy pathrelease.yml
File metadata and controls
262 lines (237 loc) · 8.77 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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
name: Release
on:
pull_request:
types: [closed]
branches: [main]
permissions:
contents: write
id-token: write
jobs:
# ── Step 1: validate versions, create git tag + GitHub Release ─────────────
prepare:
if: >
github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.title, 'release:')
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_TOKEN }}
- name: Read version
id: version
run: |
VERSION=$(cat VERSION | tr -d '[:space:]')
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "tag=v${VERSION}" >> $GITHUB_OUTPUT
echo "Releasing ${VERSION}"
- name: Sync version to all SDK manifests
run: |
VERSION=$(cat VERSION | tr -d '[:space:]')
echo "Syncing version ${VERSION} to all SDK manifests"
# Python
sed -i "s/^version = \".*\"/version = \"${VERSION}\"/" python/pyproject.toml
# langchain-mq9
sed -i "s/^version = \".*\"/version = \"${VERSION}\"/" langchain-mq9/pyproject.toml
# JavaScript
sed -i "s/\"version\": \".*\"/\"version\": \"${VERSION}\"/" javascript/package.json
# Rust
sed -i "s/^version = \".*\"/version = \"${VERSION}\"/" rust/Cargo.toml
# Java (only the first <version> tag, which is the project version)
sed -i "0,/<version>.*<\/version>/s/<version>.*<\/version>/<version>${VERSION}<\/version>/" java/pom.xml
# C#
sed -i "s|<Version>.*</Version>|<Version>${VERSION}</Version>|" csharp/Mq9/Mq9.csproj
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add python/pyproject.toml langchain-mq9/pyproject.toml javascript/package.json rust/Cargo.toml java/pom.xml csharp/Mq9/Mq9.csproj
git diff --cached --quiet || git commit -m "chore: sync SDK versions to ${VERSION}"
git push
- name: Create and push git tag
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
TAG="v${{ steps.version.outputs.version }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if git rev-parse "${TAG}" >/dev/null 2>&1; then
echo "ERROR: tag ${TAG} already exists"
exit 1
fi
git tag "${TAG}" -m "Release ${TAG}"
git push origin "${TAG}"
echo "Pushed tag ${TAG}"
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.version.outputs.tag }}
name: ${{ steps.version.outputs.tag }}
generateReleaseNotes: true
makeLatest: true
token: ${{ secrets.RELEASE_TOKEN }}
# ── Step 2: publish all SDKs in parallel ───────────────────────────────────
release-langchain-mq9:
needs: prepare
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.tag }}
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build tools
run: pip install build twine
- name: Build
working-directory: langchain-mq9
run: python -m build
- name: Publish to PyPI
working-directory: langchain-mq9
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: twine upload dist/*
release-python:
needs: prepare
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.tag }}
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build tools
run: pip install build twine
- name: Build
working-directory: python
run: python -m build
- name: Publish to PyPI
working-directory: python
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: twine upload dist/*
release-javascript:
needs: prepare
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.tag }}
- uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
cache: npm
cache-dependency-path: javascript/package-lock.json
- name: Install dependencies
working-directory: javascript
run: npm ci
- name: Build
working-directory: javascript
run: npm run build
- name: Publish to npm
working-directory: javascript
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public
release-go:
needs: prepare
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.prepare.outputs.tag }}
- name: Push Go module tag
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
VERSION: ${{ needs.prepare.outputs.version }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "go/v${VERSION}" -m "Go SDK v${VERSION}"
git push origin "go/v${VERSION}"
release-rust:
needs: prepare
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.tag }}
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: rust
- name: Publish to crates.io
working-directory: rust
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish
release-java:
needs: prepare
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.tag }}
- uses: actions/setup-java@v4
with:
java-version: "17"
distribution: temurin
cache: maven
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Publish to Maven Central
working-directory: java
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: mvn --no-transfer-progress deploy -P release
release-csharp:
needs: prepare
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.tag }}
- uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0"
- name: Build and pack
working-directory: csharp/Mq9
run: dotnet pack -c Release -o nupkg
- name: Publish to NuGet
working-directory: csharp/Mq9
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push nupkg/*.nupkg --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json
# ── Step 3: summary ─────────────────────────────────────────────────────────
summary:
needs: [prepare, release-langchain-mq9, release-python, release-javascript, release-go, release-rust, release-java, release-csharp]
runs-on: ubuntu-22.04
if: always()
steps:
- name: Release summary
run: |
VERSION="${{ needs.prepare.outputs.version }}"
cat >> $GITHUB_STEP_SUMMARY << EOF
## Release v${VERSION}
| SDK | Registry | Status |
|-----|----------|--------|
| langchain-mq9 | PyPI | ${{ needs.release-langchain-mq9.result }} |
| Python | PyPI | ${{ needs.release-python.result }} |
| JavaScript | npm | ${{ needs.release-javascript.result }} |
| Go | pkg.go.dev | ${{ needs.release-go.result }} |
| Rust | crates.io | ${{ needs.release-rust.result }} |
| Java | Maven Central | ${{ needs.release-java.result }} |
| C# | NuGet | ${{ needs.release-csharp.result }} |
GitHub Release: https://github.com/${{ github.repository }}/releases/tag/v${VERSION}
EOF