Skip to content

Commit

Permalink
release process and tagging updated
Browse files Browse the repository at this point in the history
  • Loading branch information
morisil committed Dec 9, 2024
1 parent 6387706 commit 0f6a510
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# These are supported funding model platforms

github:xemantic
github: xemantic
74 changes: 74 additions & 0 deletions .github/scripts/update-readme-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

#
# Copyright 2024 Kazimierz Pogoda / Xemantic
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# Ensure VERSION environment variable is set
if [ -z "$VERSION" ]; then
echo "Error: VERSION environment variable is not set"
exit 1
fi

# Check if settings.gradle.kts exists
if [ ! -f "settings.gradle.kts" ]; then
echo "Error: settings.gradle.kts not found"
exit 1
fi

# Extract groupId and name from settings.gradle.kts
GROUP_ID=$(grep "val groupId = " settings.gradle.kts | sed -n 's/.*groupId = "\(.*\)".*/\1/p')
ARTIFACT_ID=$(grep "val name = " settings.gradle.kts | sed -n 's/.*name = "\(.*\)".*/\1/p')

if [ -z "$GROUP_ID" ] || [ -z "$ARTIFACT_ID" ]; then
echo "Error: Could not extract groupId or name from settings.gradle.kts"
exit 1
fi

# Check if README.md exists
if [ ! -f "README.md" ]; then
echo "Error: README.md not found"
exit 1
fi

# Escape special characters in the group ID for sed
ESCAPED_GROUP_ID=$(echo "$GROUP_ID" | sed 's/\./\\./g')

# Create the pattern to match
PATTERN="\"$ESCAPED_GROUP_ID:$ARTIFACT_ID:[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\""

# Create the replacement string
REPLACEMENT="\"$GROUP_ID:$ARTIFACT_ID:$VERSION\""

# Check if the pattern exists in the file
if ! grep -q "$GROUP_ID:$ARTIFACT_ID:[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*" README.md; then
echo "Error: Dependency pattern not found in README.md"
exit 1
fi

# Perform the replacement and save to a temporary file
sed "s|$PATTERN|$REPLACEMENT|g" README.md > README.md.tmp

# Check if sed made any changes
if cmp -s README.md README.md.tmp; then
echo "No version updates were needed"
rm README.md.tmp
exit 0
fi

# Move the temporary file back to the original
mv README.md.tmp README.md

echo "Successfully updated version to $VERSION in README.md"
12 changes: 6 additions & 6 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- name: Checkout sources
uses: actions/[email protected]
with:
ref: ${{ github.head_ref }}
fetch-depth: 0

- name: Setup Java
Expand Down Expand Up @@ -57,12 +58,11 @@ jobs:
- name: Checkout branch HEAD
run: git checkout ${BRANCH}

# - name: Update README
# run: sed -i "s/com\.xemantic\.anthropic:anthropic-sdk-kotlin:[0-9]\+\(\.[0-9]\+\)*\>/com.xemantic.anthropic:anthropic-sdk-kotlin:$VERSION/g" README.md
- name: Update README
run: sh .github/scripts/update-readme-version.sh

- name: Create Pull Request
uses: peter-evans/create-pull-request@v7.0.5
uses: stefanzweifel/git-auto-commit-action@v5.0.1
with:
token: ${{ secrets.WORKFLOW_SECRET }}
commit-message: README.md gradle dependencies update to ${{ env.VERSION }}
title: PR Action - README.md gradle dependencies update to ${{ env.VERSION }}
commit_message: Dependency version in README.md updated to ${{ env.VERSION }}
file_pattern: 'README.md'
2 changes: 0 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ kotlin.native.enableKlibsCrossCompilation=true
kotlin.incremental.wasm=true
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
group=com.xemantic.ai
version=0.1-SNAPSHOT
10 changes: 9 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
rootProject.name = "xemantic-ai-tool-schema"
val groupId = "com.xemantic.ai"
val name = "xemantic-ai-tool-schema"
val versionId = "0.1-SNAPSHOT"

rootProject.name = name
gradle.beforeProject {
group = groupId
version = versionId
}

0 comments on commit 0f6a510

Please sign in to comment.