Skip to content

Commit 0a2323a

Browse files
committed
Step: Read XML Version
1 parent 6873c57 commit 0a2323a

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

.github/workflows/release.yml

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,38 @@ jobs:
2424
- name: .NET Info
2525
run: dotnet --info
2626

27-
- name: Read XML with PowerShell
28-
id: getxml
27+
- name: Install libxml2
2928
run: |
30-
[xml]$xml = Get-Content ./src/Ocelot.Testing.csproj
31-
$value_Version = $xml.SelectSingleNode("//Project/PropertyGroup/Version").InnerText
32-
echo "::set-output name=Version::$value_Version"
33-
34-
- name: Use extracted value
29+
sudo apt update
30+
sudo apt install libxml2-utils
31+
sudo apt install xmlstarlet
32+
- name: Read XML
33+
id: xml
34+
run: |
35+
xml_value=$(xmllint --xpath "string(//Project/PropertyGroup/Version)" ./src/Ocelot.Testing.csproj)
36+
echo "Version: $xml_value"
37+
echo "Version=$xml_value" >> $GITHUB_OUTPUT
38+
xml_value=$(xmllint --xpath "string((//Project/ItemGroup)[2]/PackageReference[@Include='Ocelot']/@Version)" ./src/Ocelot.Testing.csproj)
39+
echo "Ocelot Ref Ver: $xml_value"
40+
echo "OcelotRefVer=$xml_value" >> $GITHUB_OUTPUT
41+
- name: Replace Version
3542
run: |
36-
echo "Extracted value: ${{ steps.getxml.outputs.Version }}"
43+
echo "Version: ${{ steps.xml.outputs.Version }}"
44+
echo "Ocelot Ref Ver: ${{ steps.xml.outputs.OcelotRefVer }}"
45+
s_Version="${{ steps.xml.outputs.Version }}"
46+
if [[ "$s_Version" == *-* ]]; then
47+
echo "String contains '-'"
48+
first_part=$(echo "$s_Version" | cut -d'-' -f1)
49+
echo "First part: $first_part"
50+
new_value=$first_part
51+
else
52+
new_value=$s_Version
53+
fi
54+
echo "Going to replace version -> $new_value"
55+
xmlstarlet ed -L -u "//Project/PropertyGroup/Version" -v "$new_value" ./src/Ocelot.Testing.csproj
56+
xml_value=$(xmllint --xpath "string(//Project/PropertyGroup/Version)" ./src/Ocelot.Testing.csproj)
57+
echo "Replaced Version: $xml_value"
58+
echo "PkgVersion=$xml_value" >> $GITHUB_OUTPUT
3759
3860
# - name: Create GitHub Release
3961
# uses: actions/create-release@v1

0 commit comments

Comments
 (0)