Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add an update-user-agent composite action #7

Merged
merged 4 commits into from
Apr 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
chore: Add an update-user-agent composite action
This simplifies the process of updating the user-agent version number
when new release PRs are created.
unfunco committed Apr 18, 2024

Verified

This commit was signed with the committer’s verified signature.
unfunco Daniel Morris
commit 778469c964c204c9ecc70fbd0c468f4b3b5a7693
26 changes: 26 additions & 0 deletions .github/actions/update-user-agent/action.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/release-manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{".": "0.1.2"}
16 changes: 6 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -39,21 +39,17 @@ 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
with:
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
uses: ./.github/actions/update-user-agent
with:
branch: ${{ fromJSON(steps.release.outputs.pr).headBranchName }}