diff --git a/.github/workflows/release-tag.yml b/.github/workflows/release-tag.yml new file mode 100644 index 00000000..2a817435 --- /dev/null +++ b/.github/workflows/release-tag.yml @@ -0,0 +1,48 @@ +name: Create Release Tag + +on: + push: + branches: + - main + +env: + CI: true + +jobs: + create-tag: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Determine if latest commit is a version bump + id: check + run: | + commit_message=$(git log -1 --pretty=%B) + echo "Latest commit message: $commit_message" + if [[ "$commit_message" == "chore: update versions"* ]]; then + echo "is_version_bump=true" >> "$GITHUB_OUTPUT" + else + echo "is_version_bump=false" >> "$GITHUB_OUTPUT" + fi + + - name: Create and push git tag + if: steps.check.outputs.is_version_bump == 'true' + run: | + version=$(jq -r '.version' packages/agents/package.json) + tag="v${version}" + echo "Tag derived from package version: $tag" + + if git rev-parse "refs/tags/$tag" >/dev/null 2>&1; then + echo "Tag $tag already exists. Skipping." + exit 0 + fi + + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git tag -a "$tag" -m "Release $tag" + git push origin "$tag" \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 209194d9..bec33763 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Changesets +name: Changesets Release on: workflow_run: @@ -45,34 +45,10 @@ jobs: with: commit: 'chore: update versions' title: 'chore: update versions' + version: pnpm bump-version publish: pnpm ci:publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_CONFIG_PROVENANCE: true NPM_CONFIG_ACCESS: public - - - name: Push metadata changes - run: | - 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" - if git diff --quiet -- $files; then - echo "No metadata changes to push" - else - # -- Commit all the metadata.ts files -- - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git add $files - git commit -m "chore: sync metadata files" - git push origin HEAD:main - # -- Push a new release tag as well -- - # We don't use changeset release command because we always do release for all the packages - # Thus, creating git tags manually here - version=$(jq -r '.version' packages/agents/package.json) - tag="v${version}" - if git rev-parse "refs/tags/$tag" >/dev/null 2>&1; then - echo "Tag $tag already exists" - else - git tag -a "$tag" -m "Release $tag" - git push origin "$tag" - fi - fi diff --git a/package.json b/package.json index c4c481b2..f814222e 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "examples:tools-file-search": "pnpm -F tools start:file-search", "examples:tools-web-search": "pnpm -F tools start:web-search", "ci:publish": "pnpm publish -r --no-git-checks", + "bump-version": "changeset version && pnpm -F @openai/* prebuild", "prepare": "husky", "clear:deps": "rm -rf node_modules && pnpm -r exec rm -rf node_modules", "local-npm:reset": "rm -rf .cache/verdaccio/storage",