Skip to content

Commit a7b752d

Browse files
authored
Merge pull request #257 from AIDotNet/copilot/fix-256
[WIP] 更新GitHub流水线版本动态获取
2 parents 1665c47 + 20fcd5a commit a7b752d

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

‎.github/workflows/docker-image.yml‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@ jobs:
4141
username: ${{ secrets.DOCKER_USERNAME }}
4242
password: ${{ secrets.DOCKER_PASSWORD }}
4343

44+
- name: Extract version from Directory.Packages.props
45+
id: get_version
46+
run: |
47+
# Extract Version and VersionSuffix from Directory.Packages.props
48+
VERSION_TEMPLATE=$(grep -oP '(?<=<Version>)[^<]*' Directory.Packages.props)
49+
VERSION_SUFFIX=$(grep -oP '(?<=<VersionSuffix>)[^<]*' Directory.Packages.props)
50+
51+
# Replace $(VersionSuffix) with actual value
52+
VERSION=$(echo "$VERSION_TEMPLATE" | sed "s/\$(VersionSuffix)/$VERSION_SUFFIX/g")
53+
54+
echo "version=$VERSION" >> $GITHUB_OUTPUT
55+
echo "Extracted version template: $VERSION_TEMPLATE"
56+
echo "Version suffix: $VERSION_SUFFIX"
57+
echo "Final version: $VERSION"
4458
4559
- name: Build and push koala-wiki
4660
uses: docker/build-push-action@v5
@@ -51,4 +65,4 @@ jobs:
5165
push: true
5266
tags: |
5367
crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki:latest
54-
crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki:0.9.0
68+
crpi-j9ha7sxwhatgtvj4.cn-shenzhen.personal.cr.aliyuncs.com/koala-ai/koala-wiki:${{ steps.get_version.outputs.version }}

‎.github/workflows/release.yml‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,12 @@ jobs:
229229
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
230230
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
231231
else
232-
# 从Directory.Packages.props文件中提取版本号
233-
version=$(powershell -Command "[xml]\$xml = Get-Content 'Directory.Packages.props'; \$xml.Project.PropertyGroup.Version")
234-
echo "version=v$version" >> $GITHUB_OUTPUT
232+
# 从Directory.Packages.props文件中提取版本号并解析MSBuild变量
233+
VERSION_TEMPLATE=$(grep -oP '(?<=<Version>)[^<]*' Directory.Packages.props)
234+
VERSION_SUFFIX=$(grep -oP '(?<=<VersionSuffix>)[^<]*' Directory.Packages.props)
235+
VERSION=$(echo "$VERSION_TEMPLATE" | sed "s/\$(VersionSuffix)/$VERSION_SUFFIX/g")
236+
echo "version=v$VERSION" >> $GITHUB_OUTPUT
237+
echo "Extracted version: $VERSION"
235238
fi
236239
shell: bash
237240

0 commit comments

Comments
 (0)