From 778469c964c204c9ecc70fbd0c468f4b3b5a7693 Mon Sep 17 00:00:00 2001 From: Daniel Morris Date: Thu, 18 Apr 2024 11:22:45 +0100 Subject: [PATCH 1/3] 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. --- .github/actions/update-user-agent/action.yaml | 26 +++++++++++++++++++ .github/release-manifest.json | 2 +- .github/workflows/ci.yaml | 16 +++++------- 3 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 .github/actions/update-user-agent/action.yaml 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/release-manifest.json b/.github/release-manifest.json index 0967ef4..3fefeb4 100644 --- a/.github/release-manifest.json +++ b/.github/release-manifest.json @@ -1 +1 @@ -{} +{".": "0.1.2"} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0a4c590..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 + uses: ./.github/actions/update-user-agent + with: + branch: ${{ fromJSON(steps.release.outputs.pr).headBranchName }} From 40516a13686464acd94f15edf0a194a6d3afa061 Mon Sep 17 00:00:00 2001 From: Daniel Morris Date: Thu, 18 Apr 2024 11:26:04 +0100 Subject: [PATCH 2/3] Reset manifest version --- .github/release-manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/release-manifest.json b/.github/release-manifest.json index 3fefeb4..0967ef4 100644 --- a/.github/release-manifest.json +++ b/.github/release-manifest.json @@ -1 +1 @@ -{".": "0.1.2"} +{} From 72e5ca876e7413ed02c4c8daed1ad794f0c36a5d Mon Sep 17 00:00:00 2001 From: Daniel Morris Date: Thu, 18 Apr 2024 11:28:33 +0100 Subject: [PATCH 3/3] eol --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 89ad410..7550494 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -52,4 +52,4 @@ jobs: if: ${{ steps.release.outputs.prs_created }} uses: ./.github/actions/update-user-agent with: - branch: ${{ fromJSON(steps.release.outputs.pr).headBranchName }} \ No newline at end of file + branch: ${{ fromJSON(steps.release.outputs.pr).headBranchName }}