Step: Create GitHub Release #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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: Create GitHub Release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | |
| PACKAGE_VERSION: ${{ steps.ver.outputs.PkgVersion }} | |
| OCELOT_VERSION: ${{ steps.xml.outputs.OcelotRefVer }} | |
| with: | |
| tag_name: ${{ github.ref }} | |
| release_name: Release ${{ github.ref }} | |
| #body_path: ReleaseNotes.md | |
| 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 }}) | |
| draft: false | |
| prerelease: false |