Skip to content

Commit cbfe3b3

Browse files
seratchvrtnis
authored andcommitted
Improve the release operation jobs (#256)
- customize the version script to include metadata.ts changes in changesets PR - move git tag operation to a separate job
1 parent c13b5c5 commit cbfe3b3

File tree

3 files changed

+51
-26
lines changed

3 files changed

+51
-26
lines changed

.github/workflows/release-tag.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Create Release Tag
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
CI: true
10+
11+
jobs:
12+
create-tag:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Determine if latest commit is a version bump
23+
id: check
24+
run: |
25+
commit_message=$(git log -1 --pretty=%B)
26+
echo "Latest commit message: $commit_message"
27+
if [[ "$commit_message" == "chore: update versions"* ]]; then
28+
echo "is_version_bump=true" >> "$GITHUB_OUTPUT"
29+
else
30+
echo "is_version_bump=false" >> "$GITHUB_OUTPUT"
31+
fi
32+
33+
- name: Create and push git tag
34+
if: steps.check.outputs.is_version_bump == 'true'
35+
run: |
36+
version=$(jq -r '.version' packages/agents/package.json)
37+
tag="v${version}"
38+
echo "Tag derived from package version: $tag"
39+
40+
if git rev-parse "refs/tags/$tag" >/dev/null 2>&1; then
41+
echo "Tag $tag already exists. Skipping."
42+
exit 0
43+
fi
44+
45+
git config user.name "github-actions[bot]"
46+
git config user.email "github-actions[bot]@users.noreply.github.com"
47+
git tag -a "$tag" -m "Release $tag"
48+
git push origin "$tag"

.github/workflows/release.yml

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Changesets
1+
name: Changesets Release
22

33
on:
44
workflow_run:
@@ -45,34 +45,10 @@ jobs:
4545
with:
4646
commit: 'chore: update versions'
4747
title: 'chore: update versions'
48+
version: pnpm bump-version
4849
publish: pnpm ci:publish
4950
env:
5051
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5152
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
5253
NPM_CONFIG_PROVENANCE: true
5354
NPM_CONFIG_ACCESS: public
54-
55-
- name: Push metadata changes
56-
run: |
57-
files="packages/agents-core/src/metadata.ts packages/agents-extensions/src/metadata.ts packages/agents-openai/src/metadata.ts packages/agents-realtime/src/metadata.ts packages/agents/src/metadata.ts"
58-
if git diff --quiet -- $files; then
59-
echo "No metadata changes to push"
60-
else
61-
# -- Commit all the metadata.ts files --
62-
git config user.name "github-actions[bot]"
63-
git config user.email "github-actions[bot]@users.noreply.github.com"
64-
git add $files
65-
git commit -m "chore: sync metadata files"
66-
git push origin HEAD:main
67-
# -- Push a new release tag as well --
68-
# We don't use changeset release command because we always do release for all the packages
69-
# Thus, creating git tags manually here
70-
version=$(jq -r '.version' packages/agents/package.json)
71-
tag="v${version}"
72-
if git rev-parse "refs/tags/$tag" >/dev/null 2>&1; then
73-
echo "Tag $tag already exists"
74-
else
75-
git tag -a "$tag" -m "Release $tag"
76-
git push origin "$tag"
77-
fi
78-
fi

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"examples:tools-file-search": "pnpm -F tools start:file-search",
3939
"examples:tools-web-search": "pnpm -F tools start:web-search",
4040
"ci:publish": "pnpm publish -r --no-git-checks",
41+
"bump-version": "changeset version && pnpm -F @openai/* prebuild",
4142
"prepare": "husky",
4243
"clear:deps": "rm -rf node_modules && pnpm -r exec rm -rf node_modules",
4344
"local-npm:reset": "rm -rf .cache/verdaccio/storage",

0 commit comments

Comments
 (0)