|
| 1 | +name: Build Test Installer Release |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + tags: |
| 11 | + - 'v*' |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: write |
| 16 | + id-token: write |
| 17 | + |
| 18 | +env: |
| 19 | + Configuration: Release |
| 20 | + |
| 21 | +jobs: |
| 22 | + build_test: |
| 23 | + name: Build and test |
| 24 | + runs-on: windows-latest |
| 25 | + outputs: |
| 26 | + version: ${{ steps.compute_version.outputs.version }} |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Checkout |
| 30 | + uses: actions/checkout@v5 |
| 31 | + with: |
| 32 | + fetch-depth: 0 |
| 33 | + |
| 34 | + - name: Compute version |
| 35 | + id: compute_version |
| 36 | + shell: pwsh |
| 37 | + env: |
| 38 | + IS_TAG: ${{ startsWith(github.ref, 'refs/tags/v') }} |
| 39 | + REF_NAME: ${{ github.ref_name }} |
| 40 | + HEAD_COMMIT_TIMESTAMP: ${{ github.event.head_commit && github.event.head_commit.timestamp || '' }} |
| 41 | + GITHUB_SHA: ${{ github.sha }} |
| 42 | + run: | |
| 43 | + if ($env:IS_TAG -eq 'true') { |
| 44 | + $version = $env:REF_NAME |
| 45 | + } elseif (-not [string]::IsNullOrEmpty($env:HEAD_COMMIT_TIMESTAMP)) { |
| 46 | + $timestamp = [DateTime]::Parse($env:HEAD_COMMIT_TIMESTAMP).ToUniversalTime().ToString("yyyyMMddHHmm") |
| 47 | + $version = "$timestamp-$($env:GITHUB_SHA)" |
| 48 | + } else { |
| 49 | + $timestamp = [DateTime]::UtcNow.ToString("yyyyMMddHHmm") |
| 50 | + $version = "$timestamp-$($env:GITHUB_SHA)" |
| 51 | + } |
| 52 | +
|
| 53 | + "Version=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 54 | + "version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append |
| 55 | +
|
| 56 | + - name: Setup NuGet |
| 57 | + uses: NuGet/setup-nuget@v2 |
| 58 | + |
| 59 | + - name: Restore NuGet packages |
| 60 | + run: nuget restore SayMore.sln |
| 61 | + |
| 62 | + - name: Setup MSBuild |
| 63 | + uses: microsoft/setup-msbuild@v2 |
| 64 | + with: |
| 65 | + vs-version: '[17.0,18.0)' |
| 66 | + |
| 67 | + - name: Build solution |
| 68 | + run: msbuild build\SayMore.proj /t:Build /p:Configuration=$env:Configuration /p:Version=$env:Version /m |
| 69 | + |
| 70 | + - name: Run tests |
| 71 | + run: msbuild build\SayMore.proj /t:Test /p:Configuration=$env:Configuration /p:excludedCategories=SkipOnTeamCity /m |
| 72 | + |
| 73 | + - name: Upload test results |
| 74 | + if: always() |
| 75 | + uses: actions/upload-artifact@v4 |
| 76 | + with: |
| 77 | + name: saymore-test-results |
| 78 | + if-no-files-found: warn |
| 79 | + path: output/${{ env.Configuration }}/TestResults.xml |
| 80 | + |
| 81 | + build_installer: |
| 82 | + name: Build installer, sign, and publish artifacts |
| 83 | + needs: build_test |
| 84 | + if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))) }} |
| 85 | + runs-on: windows-latest |
| 86 | + env: |
| 87 | + Version: ${{ needs.build_test.outputs.version }} |
| 88 | + |
| 89 | + steps: |
| 90 | + - name: Checkout |
| 91 | + uses: actions/checkout@v5 |
| 92 | + with: |
| 93 | + fetch-depth: 0 |
| 94 | + |
| 95 | + - name: Setup NuGet |
| 96 | + uses: NuGet/setup-nuget@v2 |
| 97 | + |
| 98 | + - name: Restore NuGet packages |
| 99 | + run: nuget restore SayMore.sln |
| 100 | + |
| 101 | + - name: Fetch documentation artifacts |
| 102 | + shell: bash |
| 103 | + run: build/getDependencies-windows.sh |
| 104 | + |
| 105 | + - name: Setup MSBuild |
| 106 | + uses: microsoft/setup-msbuild@v2 |
| 107 | + with: |
| 108 | + vs-version: '[17.0,18.0)' |
| 109 | + |
| 110 | + - name: Build installer |
| 111 | + run: msbuild build\SayMore.proj /t:Installer /p:Configuration=$env:Configuration /p:useNUnit-x86=true /p:Version=$env:Version /m |
| 112 | + |
| 113 | + - name: Sign installer |
| 114 | + if: ${{ github.event_name != 'pull_request' }} |
| 115 | + uses: sillsdev/codesign/trusted-signing-action@v3 |
| 116 | + with: |
| 117 | + credentials: ${{ secrets.TRUSTED_SIGNING_CREDENTIALS }} |
| 118 | + files-folder: output/installer |
| 119 | + files-folder-filter: SayMoreInstaller*.msi |
| 120 | + |
| 121 | + - name: Upload installer artifacts |
| 122 | + uses: actions/upload-artifact@v4 |
| 123 | + with: |
| 124 | + name: saymore-installer |
| 125 | + if-no-files-found: error |
| 126 | + path: | |
| 127 | + output/installer/SayMoreInstaller*.msi |
| 128 | + output/installer/*.download_info |
| 129 | + output/installer/appcast.xml |
| 130 | + output/releasenotes.download_info |
| 131 | +
|
| 132 | + - name: Create release |
| 133 | + if: ${{ startsWith(github.ref, 'refs/tags/v') }} |
| 134 | + uses: softprops/action-gh-release@v2 |
| 135 | + with: |
| 136 | + files: | |
| 137 | + output/installer/SayMoreInstaller*.msi |
| 138 | + output/installer/*.download_info |
| 139 | + output/installer/appcast.xml |
| 140 | + output/releasenotes.download_info |
| 141 | + draft: false |
| 142 | + generate_release_notes: true |
0 commit comments