Update yml #17
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
# This workflow will build a .NET project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
name: .NET Deployment | |
# Only deploy when a new tag is pushed | |
#on: | |
# push: | |
# tags: | |
# - "v*.*.*" | |
# - "v*.*-alpha" | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
# Allow this workflow to write back to the repository | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 7.0.x | |
- name: Update VersionInfo.cs with associated tag if it exists | |
run: | | |
# Extract the tag name that triggered the event and remove the 'refs/tags/' prefix | |
cd PicoNesLoader/PicoNesLoader | |
input_string=${{ github.ref }} | |
prefix="refs/tags/" | |
tag="Not found" | |
if [[ $input_string == $prefix* ]]; then | |
echo "The string starts with 'refs/tags/'." | |
tag="${input_string#$prefix}" | |
else | |
echo "The string does not start with 'refs/tags/'." | |
fi | |
echo "Tag is ${tag}" | |
sed -i "s/DEVVERSION/${tag}/g" VersionInfo.cs | |
cat VersionInfo.cs | |
- name: Restore dependencies | |
run: dotnet restore /p:EnableWindowsTargeting=true | |
working-directory: PicoNesLoader | |
- name: Build | |
run: dotnet build --no-restore /p:EnableWindowsTargeting=true | |
working-directory: PicoNesLoader | |
- name: Test | |
run: dotnet test --no-build --verbosity normal /p:EnableWindowsTargeting=true | |
working-directory: PicoNesLoader | |
- name: Publish | |
run: dotnet publish -c Release -r win-x86 --self-contained true /p:EnableWindowsTargeting=true -p:PublishSingleFile=true -p:PublishReadyToRun=true | |
working-directory: PicoNesLoader | |
- name: Create asset direcory | |
run: mkdir -p assets/PicoSystemInfoNesLoader | |
- name: copy published files | |
run: cp -r PicoNesLoader/PicoNesLoader/bin/Release/net7.0-windows/win-x86/publish/* assets/PicoSystemInfoNesLoader | |
- name: Install zip | |
uses: montudor/action-zip@v1 | |
- name: Zip output | |
run: zip -r PicoSystemInfoNesLoader.zip PicoSystemInfoNesLoader | |
working-directory: assets | |
- name: List | |
run: ls -l | |
working-directory: assets | |
- name: Push to release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: assets/PicoSystemInfoNesLoader.zip | |
body_path: CHANGELOG.md |