Skip to content

test

test #9

name: Build and Deploy
on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master ]
defaults:
run:
working-directory: src
jobs:
build:
runs-on: windows-latest
strategy:
matrix:
# configuration: [Debug, Release]
configuration: [Debug]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Restore dependencies
run: dotnet restore
- name: Check current directory and files
run: |
echo "Current Directory: $(pwd)"
echo "Files in current directory:"
ls -Recurse
shell: pwsh
- name: Update version
id: update_version
run: |
$version_file = "kasthack.binding.wf.csproj"
# Чтение текущей версии
$current_version = (Get-Content $version_file | Select-String -Pattern '<Version>(.*?)</Version>').Matches.Groups[1].Value
# Отладочный вывод текущей версии
Write-Host "Current version: $current_version"
if (-not $current_version) {
throw "Не удалось получить текущую версию из $version_file"
}
# Получаем номер сборки
$build_number = ${GITHUB_RUN_NUMBER}
# Создаем новую версию
$new_version = "${current_version.Split('.')[0..1] -join '.'}.${build_number}"
# Проверка формата новой версии
if ($new_version -match '^\d+\.\d+\.\d+$') {
(Get-Content $version_file) -replace '<Version>.*</Version>', "<Version>$new_version</Version>" | Set-Content $version_file
(Get-Content $version_file) -replace '<AssemblyVersion>.*</AssemblyVersion>', "<AssemblyVersion>${new_version}.0</AssemblyVersion>" | Set-Content $version_file
echo "new_version=$new_version" >> $GITHUB_ENV
} else {
throw "Некорректный формат новой версии: $new_version"
}
shell: pwsh
shell: pwsh

Check failure on line 72 in .github/workflows/build-and-deploy.yml

View workflow run for this annotation

GitHub Actions / Build and Deploy

Invalid workflow file

The workflow is not valid. .github/workflows/build-and-deploy.yml (Line: 72, Col: 9): 'shell' is already defined
- name: Build
run: dotnet build --configuration ${{ matrix.configuration }} --verbosity minimal
# - name: Publish NuGet package
# if: matrix.configuration == 'Release'
# run: dotnet pack --configuration Release --output ./nupkg
# - name: Push NuGet package
# if: matrix.configuration == 'Release'
# run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
- name: Create GitHub Release
if: matrix.configuration == 'Release'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.new_version }}
name: ${{ env.new_version }}
files: ./nupkg/*.nupkg
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}