Skip to content

Upload assets

Upload assets #9

Workflow file for this run

# Releases non-beta versions, without 'beta*' suffix
name: Release Package
on:
push:
branches:
- main
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
# - name: Setup .NET
# uses: actions/setup-dotnet@v4
# with:
# dotnet-version: |
# 8.0.x
# 9.0.x
- name: .NET Info
run: dotnet --info
- name: Install XML tools
run: |
sudo apt update
sudo apt install libxml2-utils
sudo apt install xmlstarlet
- name: Read XML
id: xml
run: |
xml_value=$(xmllint --xpath "string(//Project/PropertyGroup/Version)" ./src/Ocelot.Testing.csproj)
echo "Version: $xml_value"
echo "Version=$xml_value" >> $GITHUB_OUTPUT
xml_value=$(xmllint --xpath "string((//Project/ItemGroup)[2]/PackageReference[@Include='Ocelot']/@Version)" ./src/Ocelot.Testing.csproj)
echo "Ocelot Ref Ver: $xml_value"
echo "OcelotRefVer=$xml_value" >> $GITHUB_OUTPUT
- name: Replace Version
id: ver
run: |
echo "Version: ${{ steps.xml.outputs.Version }}"
echo "Ocelot Ref Ver: ${{ steps.xml.outputs.OcelotRefVer }}"
s_Version="${{ steps.xml.outputs.Version }}"
if [[ "$s_Version" == *-* ]]; then
echo "Version contains '-'"
first_part=$(echo "$s_Version" | cut -d'-' -f1)
echo "First part: $first_part"
new_value=$first_part
else
new_value=$s_Version
fi
echo "Going to replace version $s_Version -> $new_value"
xmlstarlet ed -L -u "//Project/PropertyGroup/Version" -v "$new_value" ./src/Ocelot.Testing.csproj
xml_value=$(xmllint --xpath "string(//Project/PropertyGroup/Version)" ./src/Ocelot.Testing.csproj)
echo "Replaced Version: $xml_value"
echo "PkgVersion=$xml_value" >> $GITHUB_OUTPUT
- name: Find assets
id: assets
run: |
echo "ASSETS=$(find . -name '*.md' -print | tr '\n' ' ')" >> $GITHUB_OUTPUT
for file in $ASSETS; do
echo "Processing $file"
done
- name: Use files in another step
run: |
echo "Files found: ${{ steps.assets.outputs.ASSETS }}"
- name: GitHub Release
uses: softprops/action-gh-release@v2
env:
PACKAGE_VERSION: ${{ steps.ver.outputs.PkgVersion }}
OCELOT_VERSION: ${{ steps.xml.outputs.OcelotRefVer }}
with:
tag_name: 0.0.3 # Name of a tag. defaults to github.ref_name
body: |
## Version [${{ env.PACKAGE_VERSION }}](https://www.nuget.org/packages/Ocelot.Testing/${{ env.PACKAGE_VERSION }})
- Ocelot dependency package: v[${{ env.OCELOT_VERSION }}](https://www.nuget.org/packages/Ocelot/${{ env.OCELOT_VERSION }})
- For Ocelot release: [${{ env.OCELOT_VERSION }}](https://github.com/ThreeMammals/Ocelot/releases/tag/${{ env.OCELOT_VERSION }})
files: ${{ steps.assets.outputs.ASSETS }}
draft: false
prerelease: false