Skip to content

Commit

Permalink
dynamic version
Browse files Browse the repository at this point in the history
  • Loading branch information
dwertent committed Feb 14, 2025
1 parent 3eb9d53 commit 25dc835
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 4 deletions.
31 changes: 31 additions & 0 deletions .github/actions/update-json/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: 'Update JSON File'
description: 'Update values in a JSON file'
inputs:
file:
description: 'The path to the JSON file to update'
required: true
key:
description: 'The JSON key to update'
required: true
value:
description: 'The new value to set for the key'
required: true
runs:
using: 'composite'
steps:
- name: Install jq
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y jq
- name: Update JSON file
shell: bash
run: |
set -e
echo "Updating ${{ inputs.file }}"
jq --arg value "${{ inputs.value }}" '.[$key] = $value' "${{ inputs.file }}" > temp.json && mv temp.json "${{ inputs.file }}"
echo "Updated ${{ inputs.file }}:"
cat "${{ inputs.file }}"
23 changes: 20 additions & 3 deletions .github/workflows/release-typescript-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@ on:
NPM_TOKEN:
description: 'NPM token'
required: true
inputs:
sdk_version:
description: 'The version to publish'
required: true
type: string
workflow_dispatch:
inputs:
sdk_version:
description: 'The version to publish'
required: true
type: string


jobs:
publish:
permissions:
Expand All @@ -28,7 +37,15 @@ jobs:

- name: Install pre-requisites
uses: ./.github/actions/setup


# Override package.json version
- name: Override SDK version
uses: ./.github/actions/update-json
with:
file: 'sdk/typescript/package.json'
key: 'version'
value: ${{ inputs.sdk_version }}

- name: Publish to npm
continue-on-error: true # this can fail if the version is already published
working-directory: sdk/typescript
Expand All @@ -39,4 +56,4 @@ jobs:
npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

4 changes: 3 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ jobs:
CR_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release-typescript-sdk:
needs: release-charts
needs: [set-variables, release-charts]
uses: ./.github/workflows/release-typescript-sdk.yaml
with:
sdk_version: ${{ needs.set-variables.outputs.tag }}
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit 25dc835

Please sign in to comment.