Skip to content

Commit e3be9b1

Browse files
authored
Merge pull request #401 from hookdeck/chore/go-shields-update
chore(ci): update Go SDK version retrieval from gen.yaml and improve …
2 parents 902f93c + 663feda commit e3be9b1

File tree

3 files changed

+39
-28
lines changed

3 files changed

+39
-28
lines changed

.github/workflows/sdk_publish_outpost_go.yaml

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,36 +33,47 @@ 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: Install yq
3837
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."
38+
sudo apt-get update && sudo apt-get install -y yq
39+
shell: bash
40+
41+
- name: Get Go SDK Version from gen.yaml
42+
id: get_version
43+
run: |
44+
GEN_YAML_PATH="sdks/outpost-go/.speakeasy/gen.yaml"
45+
if [ ! -f "$GEN_YAML_PATH" ]; then
46+
echo "Error: $GEN_YAML_PATH not found."
4347
exit 1
4448
fi
45-
echo "Latest Go SDK tag: $LATEST_TAG"
46-
echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT
49+
# Read the version using yq; ensure it's not empty or literal "null"
50+
SDK_VERSION_RAW=$(yq -r '.go.version' "$GEN_YAML_PATH")
51+
if [ -z "$SDK_VERSION_RAW" ] || [ "$SDK_VERSION_RAW" = "null" ]; then
52+
echo "Error: Could not read .go.version from $GEN_YAML_PATH, or version is null/empty."
53+
echo "Content of $GEN_YAML_PATH:"
54+
cat "$GEN_YAML_PATH"
55+
exit 1
56+
fi
57+
echo "Go SDK version from $GEN_YAML_PATH: $SDK_VERSION_RAW"
58+
echo "sdk_version=$SDK_VERSION_RAW" >> $GITHUB_OUTPUT
4759
shell: bash
4860

4961
- name: Debug Information
5062
env:
51-
PUBLISH_VERSION: ${{ steps.get_tag.outputs.latest_tag }}
63+
PUBLISH_VERSION: ${{ steps.get_version.outputs.sdk_version }}
5264
run: |
53-
echo "Assumed latest Go SDK version (tag): $PUBLISH_VERSION"
65+
echo "Go SDK version from gen.yaml: $PUBLISH_VERSION"
5466
5567
- name: Update shields.json
5668
env:
57-
NEW_VERSION: ${{ steps.get_tag.outputs.latest_tag }}
69+
NEW_VERSION: ${{ steps.get_version.outputs.sdk_version }} # This will be like "0.2.1"
5870
run: |
59-
echo "Updating shields.json with version: $NEW_VERSION"
71+
echo "Updating shields.json with version from gen.yaml: $NEW_VERSION"
6072
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-
73+
SHIELD_VERSION_VALUE=$NEW_VERSION # e.g., 0.2.1
74+
# Ensure it starts with 'v' for the shield
6475
if [[ ! $SHIELD_VERSION_VALUE == v* ]]; then
65-
SHIELD_VERSION_VALUE="v$SHIELD_VERSION_VALUE"
76+
SHIELD_VERSION_VALUE="v$SHIELD_VERSION_VALUE" # e.g., v0.2.1
6677
fi
6778
echo "Formatted shield version for JSON: $SHIELD_VERSION_VALUE"
6879
@@ -92,7 +103,7 @@ jobs:
92103
93104
- name: Create Pull Request for shields.json update
94105
env:
95-
NEW_VERSION: ${{ steps.get_tag.outputs.latest_tag }}
106+
NEW_VERSION: ${{ steps.get_version.outputs.sdk_version }} # This will be like "0.2.1"
96107
GH_TOKEN: ${{ github.token }}
97108
run: |
98109
git config --global user.name 'github-actions[bot]'
@@ -105,12 +116,11 @@ jobs:
105116
fi
106117
107118
# 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'
119+
# NEW_VERSION is the raw version from gen.yaml, e.g., "0.2.1"
120+
COMMIT_MSG_VERSION_PART=$NEW_VERSION
121+
# Ensure it starts with 'v' for commit messages, branch names, PR titles
112122
if [[ ! $COMMIT_MSG_VERSION_PART == v* ]]; then
113-
COMMIT_MSG_VERSION_PART="v$COMMIT_MSG_VERSION_PART"
123+
COMMIT_MSG_VERSION_PART="v$COMMIT_MSG_VERSION_PART" # e.g., v0.2.1
114124
fi
115125
116126
BRANCH_NAME="chore/update-go-shields-$COMMIT_MSG_VERSION_PART"
@@ -119,11 +129,12 @@ jobs:
119129
PR_BODY=$(cat <<EOF
120130
This PR updates the \`sdks/outpost-go/shields.json\` file to version $COMMIT_MSG_VERSION_PART.
121131
122-
This change was triggered by the automated workflow due to a new Go SDK tag: \`$NEW_VERSION\`.
132+
This change was triggered by the automated workflow based on the version in \`sdks/outpost-go/.speakeasy/gen.yaml\`: \`$NEW_VERSION\`.
123133
EOF
124134
)
125135
126-
git checkout -b "$BRANCH_NAME"
136+
# Create a new branch or reset if it already exists locally
137+
git checkout -B "$BRANCH_NAME"
127138
git add "$SHIELDS_FILE"
128139
129140
if git diff --staged --quiet; then

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
<div align="center">
2222
SDKs:
2323

24-
![Go SDK](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/hookdeck/outpost/refs/heads/main/sdks/outpost-go/shields.json)
25-
![TypeScript SDK](https://img.shields.io/npm/v/%40hookdeck%2Foutpost-sdk)
26-
![Python SDK](https://img.shields.io/pypi/v/outpost-sdk)
24+
[![Go SDK](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/hookdeck/outpost/refs/heads/main/sdks/outpost-go/shields.json)](sdks/outpost-go/README.md)
25+
[![TypeScript SDK](https://img.shields.io/npm/v/%40hookdeck%2Foutpost-sdk)](sdks/outpost-typescript/README.md)
26+
[![Python SDK](https://img.shields.io/pypi/v/outpost-sdk)](sdks/outpost-python/README.md)
2727

2828

2929
</div>

sdks/outpost-go/shields.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"schemaVersion": 1,
33
"label": "outpost-go",
4-
"message": "v0.2.0",
4+
"message": "v0.2.1",
55
"color": "blue"
66
}

0 commit comments

Comments
 (0)