Update dependency Meziantou.Analyzer to 2.0.176 (#95) #96
This file contains 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
name: Publish to NuGet | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
publish: | |
name: publish release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: 🔨 set up .net 7 | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 7.0.x | |
- name: 👌 extract version | |
shell: pwsh | |
run: | | |
$csprojPath = "src/LazyCart/LazyCart.csproj" | |
$csproj = [xml](Get-Content -Path $csprojPath) | |
$version = $csproj.Project.PropertyGroup.Version | |
echo "Version: $version" | |
echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
- name: 🧹 Trim VERSION variable | |
run: echo "VERSION=$(echo "$VERSION" | xargs)" >> $GITHUB_ENV | |
- name: 🔎 check if version changed | |
run: | | |
git fetch origin | |
CS_PROJ_FILE="src/LazyCart/LazyCart.csproj" | |
git show HEAD^:$CS_PROJ_FILE > old_csproj.xml | |
cp $CS_PROJ_FILE new_csproj.xml | |
OLD_VERSION=$(grep -oP '<Version>\K(.*?)(?=</Version>)' old_csproj.xml) | |
NEW_VERSION=$(grep -oP '<Version>\K(.*?)(?=</Version>)' new_csproj.xml) | |
VERSION_CHANGED=0 | |
if [ "$OLD_VERSION" = "$NEW_VERSION" ]; then | |
echo "The <Version> tag has not changed." | |
else | |
echo "The <Version> tag has changed from $OLD_VERSION to $NEW_VERSION." | |
VERSION_CHANGED=1 | |
fi | |
echo "VERSION_CHANGED=$VERSION_CHANGED" >> $GITHUB_ENV | |
- name: ⚗ restore dependencies | |
if: env.VERSION_CHANGED == '1' | |
run: dotnet restore src | |
- name: 🛠 build | |
if: env.VERSION_CHANGED == '1' | |
run: dotnet build src --configuration Release --no-restore | |
- name: 🎁 pack nuget | |
if: env.VERSION_CHANGED == '1' | |
run: dotnet pack src/LazyCart/LazyCart.csproj --configuration Release --include-symbols /p:SymbolPackageFormat=snupkg /p:ContinuousIntegrationBuild=true /p:Version="${{ env.VERSION }}" --output . | |
- name: 💌 publish nuget | |
if: env.VERSION_CHANGED == '1' | |
run: dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --api-key ${NUGET_KEY} --skip-duplicate | |
env: | |
NUGET_KEY: ${{ secrets.NUGET_API_KEY }} | |
- name: 🔨 set up python | |
if: env.VERSION_CHANGED == '1' | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: 📢 extract release notes | |
if: env.VERSION_CHANGED == '1' | |
run: | | |
python scripts/extract_changelog.py CHANGELOG.md latest_release.md | |
- name: 📑 create github release | |
if: env.VERSION_CHANGED == '1' | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ env.VERSION }} | |
release_name: Release v${{ env.VERSION }} | |
draft: false | |
prerelease: false | |
body_path: latest_release.md |