|
| 1 | +name: .NET Build + Publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + build-windows: |
| 11 | + runs-on: windows-2022 |
| 12 | + |
| 13 | + permissions: |
| 14 | + contents: write |
| 15 | + |
| 16 | + outputs: |
| 17 | + version-number: ${{ steps.version.outputs.number}} |
| 18 | + |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + - name: Setup .NET |
| 22 | + uses: actions/setup-dotnet@v4 |
| 23 | + with: |
| 24 | + dotnet-version: 9.0.x |
| 25 | + - name: Restore dependencies |
| 26 | + run: dotnet restore |
| 27 | + - name: Build |
| 28 | + run: dotnet build --no-restore -p:PostBuildEvent= |
| 29 | + - name: Publish Windows 64bit |
| 30 | + if: ${{ github.event_name != 'pull_request' }} |
| 31 | + run: dotnet publish --os win --arch x64 -c Release --self-contained false MSUScripter/MSUScripter.csproj |
| 32 | + - name: Publish Windows 32bit |
| 33 | + if: ${{ github.event_name != 'pull_request' }} |
| 34 | + run: dotnet publish --os win --arch x86 -c Release --self-contained false MSUScripter/MSUScripter.csproj |
| 35 | + - name: Get version number |
| 36 | + if: ${{ github.event_name != 'pull_request' }} |
| 37 | + id: version |
| 38 | + run: | |
| 39 | + $version = (Get-Item "MSUScripter\bin\Release\net9.0\win-x86\publish\MSUScripter.exe").VersionInfo.ProductVersion |
| 40 | + $version = $version.Split("+")[0] |
| 41 | + Write-Host $version |
| 42 | + Write-Output "number=$version" >> $env:GITHUB_OUTPUT |
| 43 | + shell: pwsh |
| 44 | + - name: Building the Windows installer |
| 45 | + if: ${{ github.event_name != 'pull_request' }} |
| 46 | + run: '"%programfiles(x86)%/Inno Setup 6/iscc.exe" "Setup/MSUScripter.iss"' |
| 47 | + shell: cmd |
| 48 | + - name: Upload artifact |
| 49 | + uses: actions/upload-artifact@v4 |
| 50 | + if: ${{ github.event_name != 'pull_request' }} |
| 51 | + with: |
| 52 | + path: "setup/Output/*" |
| 53 | + name: MSUScripterWindows |
| 54 | + |
| 55 | + build-linux: |
| 56 | + runs-on: ubuntu-22.04 |
| 57 | + if: ${{ github.event_name != 'pull_request' }} |
| 58 | + needs: [build-windows] |
| 59 | + |
| 60 | + permissions: |
| 61 | + contents: write |
| 62 | + |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v4 |
| 65 | + - name: Setup .NET |
| 66 | + uses: actions/setup-dotnet@v4 |
| 67 | + with: |
| 68 | + dotnet-version: 9.0.x |
| 69 | + - name: Update VersionOverride in source file |
| 70 | + run: | |
| 71 | + pwd |
| 72 | + VERSION="${{ needs.build-windows.outputs.version-number }}" |
| 73 | + BASE_VERSION="${VERSION%%-*}" |
| 74 | + FILE="MSUScripter/App.axaml.cs" |
| 75 | + sed -i -E "s|^[[:space:]]*private static readonly string\?[[:space:]]+VersionOverride[[:space:]]*=[[:space:]]*null;|private static readonly string? VersionOverride = \"${VERSION}\";|" "$FILE" |
| 76 | + sed -i "s/^AppVersionRelease *= *.*/AppVersionRelease = ${BASE_VERSION}/" Setup/AppImage.pupnet.conf |
| 77 | + echo "Updated VersionOverride to: ${VERSION}" |
| 78 | + - name: Install PupNet |
| 79 | + run: dotnet tool install -g KuiperZone.PupNet |
| 80 | + - name: Download AppImageTool |
| 81 | + run: | |
| 82 | + wget -P "$HOME/.local/bin" "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage" |
| 83 | + chmod +x "$HOME/.local/bin/appimagetool-x86_64.AppImage" |
| 84 | + appimagetool-x86_64.AppImage --version |
| 85 | + - name: Run PupNet |
| 86 | + run: pupnet Setup/AppImage.pupnet.conf --kind appimage -y |
| 87 | + - name: Upload artifact |
| 88 | + uses: actions/upload-artifact@v4 |
| 89 | + if: ${{ github.event_name != 'pull_request' }} |
| 90 | + with: |
| 91 | + path: "Setup/Output/MSUScripter*" |
| 92 | + name: MSUScripterLinux |
| 93 | + |
| 94 | + package: |
| 95 | + runs-on: ubuntu-22.04 |
| 96 | + needs: [build-windows, build-linux] |
| 97 | + if: ${{ github.event_name != 'pull_request' }} |
| 98 | + |
| 99 | + permissions: |
| 100 | + contents: write |
| 101 | + |
| 102 | + steps: |
| 103 | + - uses: actions/download-artifact@v5 |
| 104 | + with: |
| 105 | + name: MSUScripterWindows |
| 106 | + path: out |
| 107 | + - uses: actions/download-artifact@v5 |
| 108 | + with: |
| 109 | + name: MSUScripterLinux |
| 110 | + path: out |
| 111 | + - name: Extract some files |
| 112 | + run: | |
| 113 | + ls -alR |
| 114 | + - name: Upload artifact |
| 115 | + uses: actions/upload-artifact@v4 |
| 116 | + if: ${{ github.event_name != 'pull_request' }} |
| 117 | + with: |
| 118 | + path: "out/*" |
| 119 | + name: MSUScripter_${{ needs.build-windows.outputs.version-number }} |
| 120 | + - name: Delete old artifacts |
| 121 | + uses: geekyeggo/delete-artifact@v5 |
| 122 | + with: |
| 123 | + name: | |
| 124 | + MSUScripterWindows |
| 125 | + MSUScripterLinux |
0 commit comments