diff --git a/.github/actions/update-user-agent/action.yaml b/.github/actions/update-user-agent/action.yaml new file mode 100644 index 0000000..fd69253 --- /dev/null +++ b/.github/actions/update-user-agent/action.yaml @@ -0,0 +1,26 @@ +name: Update user-agent +description: Sets the version number in the default user-agent header. + +inputs: + branch: + description: Branch to checkout and update. + required: true + +runs: + using: composite + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + - name: Configure user-agent + run: | + version=$(jq -r '."."' .github/release-manifest.json) + version=${version#v} + sed -i "s/unfunco\/anthropic-sdk-go@v[0-9]*\.[0-9]*\.[0-9]*/unfunco\/anthropic-sdk-go@v$version/" anthropic.go + git config --local user.name "David Letterman" + git config --local user.email "48985810+david-letterman@users.noreply.github.com" + git add anthropic.go + git commit -m "Configure user-agent version number" + git push + shell: bash diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a85105d..7550494 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -39,6 +39,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Prepare a release id: release uses: google-github-actions/release-please-action@v4 @@ -46,14 +48,8 @@ jobs: config-file: .github/release-config.json manifest-file: .github/release-manifest.json token: ${{ secrets.GITHUB_TOKEN }} - - name: Configure version + - name: Update user-agent version number if: ${{ steps.release.outputs.prs_created }} - run: | - version=${{ steps.release.outputs.tag_name }} - version=${version#v} - sed -i "s/unfunco\/anthropic-sdk-go@v[0-9]*\.[0-9]*\.[0-9]*/unfunco\/anthropic-sdk-go@v$version/" anthropic.go - git config user.name "David Letterman" - git config user.email "48985810+david-letterman@users.noreply.github.com" - git add anthropic.go - git commit -m "Configure version number" - git push origin release-please--branches--main + uses: ./.github/actions/update-user-agent + with: + branch: ${{ fromJSON(steps.release.outputs.pr).headBranchName }}