@@ -33,36 +33,45 @@ jobs:
3333 token : ${{ secrets.GITHUB_TOKEN }}
3434 fetch-depth : 0 # Ensure all tags are fetched
3535
36- - name : Get Latest Tag for Go SDK
37- id : get_tag
36+ - name : Get Go SDK Version from gen.yaml
37+ id : get_version
3838 run : |
39- # Match tags like sdks/go/v0.1.0
40- LATEST_TAG=$(git describe --tags --match="sdks/go/v*" --abbrev=0)
41- if [ -z "$LATEST_TAG" ]; then
42- echo "Error: No matching Go SDK tag (sdks/go/v*) found."
39+ # This step assumes 'yq' is available on the runner.
40+ # If not, you might need to add a setup step for yq, e.g.:
41+ # sudo apt-get update && sudo apt-get install -y yq
42+ GEN_YAML_PATH="sdks/outpost-go/.speakeasy/gen.yaml"
43+ if [ ! -f "$GEN_YAML_PATH" ]; then
44+ echo "Error: $GEN_YAML_PATH not found."
4345 exit 1
4446 fi
45- echo "Latest Go SDK tag: $LATEST_TAG"
46- echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT
47+ # Read the version using yq; ensure it's not empty or literal "null"
48+ SDK_VERSION_RAW=$(yq -r '.go.version' "$GEN_YAML_PATH")
49+ if [ -z "$SDK_VERSION_RAW" ] || [ "$SDK_VERSION_RAW" == "null" ]; then
50+ echo "Error: Could not read .go.version from $GEN_YAML_PATH, or version is null/empty."
51+ echo "Content of $GEN_YAML_PATH:"
52+ cat "$GEN_YAML_PATH"
53+ exit 1
54+ fi
55+ echo "Go SDK version from $GEN_YAML_PATH: $SDK_VERSION_RAW"
56+ echo "sdk_version=$SDK_VERSION_RAW" >> $GITHUB_OUTPUT
4757 shell : bash
4858
4959 - name : Debug Information
5060 env :
51- PUBLISH_VERSION : ${{ steps.get_tag .outputs.latest_tag }}
61+ PUBLISH_VERSION : ${{ steps.get_version .outputs.sdk_version }}
5262 run : |
53- echo "Assumed latest Go SDK version (tag) : $PUBLISH_VERSION"
63+ echo "Go SDK version from gen.yaml : $PUBLISH_VERSION"
5464
5565 - name : Update shields.json
5666 env :
57- NEW_VERSION : ${{ steps.get_tag .outputs.latest_tag }}
67+ NEW_VERSION : ${{ steps.get_version .outputs.sdk_version }} # This will be like "0.2.1"
5868 run : |
59- echo "Updating shields.json with version: $NEW_VERSION"
69+ echo "Updating shields.json with version from gen.yaml : $NEW_VERSION"
6070
61- # Extract the version part if the tag is like sdks/go/v1.0.0
62- SHIELD_VERSION_VALUE=$(echo "$NEW_VERSION" | sed 's#^sdks/go/##')
63-
71+ SHIELD_VERSION_VALUE=$NEW_VERSION # e.g., 0.2.1
72+ # Ensure it starts with 'v' for the shield
6473 if [[ ! $SHIELD_VERSION_VALUE == v* ]]; then
65- SHIELD_VERSION_VALUE="v$SHIELD_VERSION_VALUE"
74+ SHIELD_VERSION_VALUE="v$SHIELD_VERSION_VALUE" # e.g., v0.2.1
6675 fi
6776 echo "Formatted shield version for JSON: $SHIELD_VERSION_VALUE"
6877
92101
93102 - name : Create Pull Request for shields.json update
94103 env :
95- NEW_VERSION : ${{ steps.get_tag .outputs.latest_tag }}
104+ NEW_VERSION : ${{ steps.get_version .outputs.sdk_version }} # This will be like "0.2.1"
96105 GH_TOKEN : ${{ github.token }}
97106 run : |
98107 git config --global user.name 'github-actions[bot]'
@@ -105,12 +114,11 @@ jobs:
105114 fi
106115
107116 # Determine version for commit message and branch name
108- COMMIT_MSG_VERSION_FULL=$NEW_VERSION
109- # Extract version part like "v0.1.0" from "sdks/go/v0.1.0"
110- COMMIT_MSG_VERSION_PART=$(echo "$COMMIT_MSG_VERSION_FULL" | sed 's#^sdks/go/##')
111- # Ensure it starts with 'v'
117+ # NEW_VERSION is the raw version from gen.yaml, e.g., "0.2.1"
118+ COMMIT_MSG_VERSION_PART=$NEW_VERSION
119+ # Ensure it starts with 'v' for commit messages, branch names, PR titles
112120 if [[ ! $COMMIT_MSG_VERSION_PART == v* ]]; then
113- COMMIT_MSG_VERSION_PART="v$COMMIT_MSG_VERSION_PART"
121+ COMMIT_MSG_VERSION_PART="v$COMMIT_MSG_VERSION_PART" # e.g., v0.2.1
114122 fi
115123
116124 BRANCH_NAME="chore/update-go-shields-$COMMIT_MSG_VERSION_PART"
@@ -119,11 +127,12 @@ jobs:
119127 PR_BODY=$(cat <<EOF
120128 This PR updates the \`sdks/outpost-go/shields.json\` file to version $COMMIT_MSG_VERSION_PART.
121129
122- This change was triggered by the automated workflow due to a new Go SDK tag : \`$NEW_VERSION\`.
130+ This change was triggered by the automated workflow based on the version in \`sdks/outpost-go/.speakeasy/gen.yaml\` : \`$NEW_VERSION\`.
123131 EOF
124132 )
125133
126- git checkout -b "$BRANCH_NAME"
134+ # Create a new branch or reset if it already exists locally
135+ git checkout -B "$BRANCH_NAME"
127136 git add "$SHIELDS_FILE"
128137
129138 if git diff --staged --quiet; then
0 commit comments