|
| 1 | +name: Build App |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - ".github/workflows/**" |
| 7 | + - "App/**" |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + name: Build Windows executable |
| 15 | + runs-on: windows-latest |
| 16 | + |
| 17 | + defaults: |
| 18 | + run: |
| 19 | + working-directory: App |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Setup Node.js |
| 26 | + uses: actions/setup-node@v4 |
| 27 | + with: |
| 28 | + node-version: 22 |
| 29 | + cache: npm |
| 30 | + cache-dependency-path: App/package-lock.json |
| 31 | + |
| 32 | + - name: Install dependencies |
| 33 | + run: npm ci |
| 34 | + |
| 35 | + - name: Build app |
| 36 | + run: npm run build |
| 37 | + |
| 38 | + - name: Find executable |
| 39 | + id: exe |
| 40 | + shell: pwsh |
| 41 | + run: | |
| 42 | + $exe = Get-ChildItem -Path "build/dist" -Filter "*.exe" -File | |
| 43 | + Sort-Object LastWriteTime -Descending | |
| 44 | + Select-Object -First 1 |
| 45 | +
|
| 46 | + if (-not $exe) { |
| 47 | + throw "No .exe file found in App/build/dist" |
| 48 | + } |
| 49 | +
|
| 50 | + "path=$($exe.FullName)" >> $env:GITHUB_OUTPUT |
| 51 | + "name=$($exe.Name)" >> $env:GITHUB_OUTPUT |
| 52 | +
|
| 53 | + - name: Read app version |
| 54 | + id: app |
| 55 | + shell: pwsh |
| 56 | + run: | |
| 57 | + $version = node -p "require('./package.json').version" |
| 58 | + "version=$version" >> $env:GITHUB_OUTPUT |
| 59 | +
|
| 60 | + - name: Create draft release |
| 61 | + shell: pwsh |
| 62 | + env: |
| 63 | + GH_TOKEN: ${{ github.token }} |
| 64 | + EXE_PATH: ${{ steps.exe.outputs.path }} |
| 65 | + APP_VERSION: ${{ steps.app.outputs.version }} |
| 66 | + COMMIT_SHA: ${{ github.sha }} |
| 67 | + run: | |
| 68 | + $tag = "v$env:APP_VERSION" |
| 69 | + if (gh release view $tag --repo $env:GITHUB_REPOSITORY *> $null) { |
| 70 | + $tag = "v$env:APP_VERSION-beta" |
| 71 | + } |
| 72 | +
|
| 73 | + $title = "Simple Office Installer v$env:APP_VERSION" |
| 74 | + $notes = "Draft build from commit $env:COMMIT_SHA." |
| 75 | +
|
| 76 | + gh release create $tag $env:EXE_PATH ` |
| 77 | + --draft ` |
| 78 | + --target $env:COMMIT_SHA ` |
| 79 | + --title $title ` |
| 80 | + --notes $notes ` |
| 81 | + --repo $env:GITHUB_REPOSITORY |
0 commit comments