Every Monday at 2 am (UTC) (cron) or manually

↓
  windows-build.yml
  ├── build-windows  →  generates an exe file + zip + portable artefact
  └── deploy-pages   →  clears old files, uploads the exe file + zip to the ‘release nightly’ repository
        ↓ (workflow_run: completed + successful)
  windows-msi.yml
  ├── uploads the portable artefact
  ├── builds the MSI with WiX v7
  ├── deletes the old .msi, uploads the MSI to the nightly version
  └── generates and deploys GitHub Pages  ← the 3 URLs are known here
The GitHub Pages page is no longer generated by windows-build.yml but by windows-msi.yml once the MSI is in the release
This commit is contained in:
Laurent Trinques
2026-05-14 09:53:29 +02:00
parent 93baa00d00
commit 7bf395afab
2 changed files with 99 additions and 51 deletions

View File

@@ -1,11 +1,9 @@
name: Windows Build name: Windows Build
on: on:
push: schedule:
branches: [ master ] - cron: '0 2 * * 1' # Every Monday at 2:00 UTC
pull_request: workflow_dispatch: # Manual trigger available at any time
branches: [ master ]
workflow_dispatch:
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
@@ -366,8 +364,6 @@ jobs:
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'
permissions: permissions:
contents: write contents: write
pages: write
id-token: write
steps: steps:
- name: Checkout master (for build-aux scripts) - name: Checkout master (for build-aux scripts)
@@ -391,6 +387,20 @@ jobs:
path: downloaded/portable/ path: downloaded/portable/
merge-multiple: true merge-multiple: true
- name: Delete old nightly assets (.exe and .zip)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
run: |
# Fetch existing .exe and .zip asset names and delete them
gh release view nightly --repo "$REPO" --json assets \
--jq '.assets[] | select(.name | test("\\.(exe|zip)$")) | .name' \
| while read -r name; do
echo "Deleting old asset: $name"
gh release delete-asset nightly "$name" --repo "$REPO" --yes
done
echo "Old .exe and .zip assets deleted."
- name: Update nightly release - name: Update nightly release
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
with: with:
@@ -414,39 +424,5 @@ jobs:
downloaded/portable/*.zip downloaded/portable/*.zip
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
- name: Generate download page (index.html) # GitHub Pages is generated and deployed by windows-msi.yml
env: # after the MSI upload, so that all 3 URLs (exe, zip, msi) are known.
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DATE: "placeholder"
run: |
DATE=$(date -u '+%Y-%m-%d %H:%M UTC')
SHORT="${{ github.sha }}"
SHORT="${SHORT:0:7}"
REPO="${{ github.repository }}"
RUN_URL="https://github.com/$REPO/actions/runs/${{ github.run_id }}"
EXE_NAME=$(ls downloaded/installer/*.exe | xargs -I{} basename {})
INSTALLER_URL="https://github.com/$REPO/releases/download/nightly/$EXE_NAME"
ZIP_NAME=$(ls downloaded/portable/*.zip | xargs -I{} basename {})
PORTABLE_URL="https://github.com/$REPO/releases/download/nightly/$ZIP_NAME"
MSI_NAME=$(gh release view nightly --json assets --jq '.assets[].name' 2>/dev/null \
| grep '\.msi$' | head -1 || echo "")
MSI_URL=""
[ -n "$MSI_NAME" ] && MSI_URL="https://github.com/$REPO/releases/download/nightly/$MSI_NAME"
DATE=$(date -u '+%Y-%m-%d %H:%M UTC')
export DATE SHORT REPO SHA="${{ github.sha }}" RUN_URL
export RUN_NUMBER="${{ github.run_number }}"
export INSTALLER_URL PORTABLE_URL MSI_URL
# Write the page generator script to /tmp (build-aux/ not available
# in deploy-pages job which only checks out gh-pages branch)
python3 source/build-aux/generate-page.py
- name: Add .nojekyll to disable Jekyll processing
run: touch gh-pages/.nojekyll
- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: gh-pages/
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4

View File

@@ -1,12 +1,12 @@
name: Windows MSI (WiX v7) name: Windows MSI (WiX v7)
on: on:
# Déclenché automatiquement après un build Windows réussi sur master # Triggered automatically after a successful Windows build on master
workflow_run: workflow_run:
workflows: ["Windows Build"] workflows: ["Windows Build"]
types: [completed] types: [completed]
branches: [master] branches: [master]
# Toujours possible de lancer manuellement (ex: pour un run_id spécifique) # Manual trigger still available (e.g. for a specific run_id)
workflow_dispatch: workflow_dispatch:
inputs: inputs:
run_id: run_id:
@@ -18,10 +18,14 @@ jobs:
build-msi: build-msi:
name: Build MSI with WiX v7 name: Build MSI with WiX v7
runs-on: windows-latest runs-on: windows-latest
# Ne tourne que si le workflow Windows Build a réussi (ou si c'est manuel) # Only runs if Windows Build succeeded (or triggered manually)
if: > if: >
github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_dispatch' ||
github.event.workflow_run.conclusion == 'success' github.event.workflow_run.conclusion == 'success'
permissions:
contents: write
pages: write
id-token: write
steps: steps:
# ---------------------------------------------------------------- # ----------------------------------------------------------------
@@ -42,8 +46,8 @@ jobs:
with: with:
name: qelectrotech-windows-portable name: qelectrotech-windows-portable
path: artifact\files path: artifact\files
# workflow_run => utilise l'ID du run déclencheur # workflow_run => use the triggering run's ID
# workflow_dispatch => utilise l'input run_id si fourni, sinon le run courant # workflow_dispatch => use input run_id if provided, otherwise current run
run-id: ${{ github.event.workflow_run.id || github.event.inputs.run_id || github.run_id }} run-id: ${{ github.event.workflow_run.id || github.event.inputs.run_id || github.run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }} repository: ${{ github.repository }}
@@ -259,10 +263,22 @@ jobs:
if-no-files-found: error if-no-files-found: error
# ---------------------------------------------------------------- # ----------------------------------------------------------------
# 11. Upload MSI to nightly release # 11. Delete old .msi asset then upload new MSI to nightly release
# The nightly release is created/updated by windows-build.yml.
# The MSI is added here so the GitHub Pages can link to it.
# ---------------------------------------------------------------- # ----------------------------------------------------------------
- name: Delete old nightly .msi asset
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
run: |
gh release view nightly --repo "$REPO" --json assets \
--jq '.assets[] | select(.name | test("\\.msi$")) | .name' \
| while read -r name; do
echo "Deleting old asset: $name"
gh release delete-asset nightly "$name" --repo "$REPO" --yes
done
echo "Old .msi assets deleted."
shell: bash
- name: Upload MSI to nightly release - name: Upload MSI to nightly release
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
with: with:
@@ -289,3 +305,59 @@ jobs:
} else { } else {
Write-Host "MSI : FAILED ✗" Write-Host "MSI : FAILED ✗"
} }
# ----------------------------------------------------------------
# 13. Generate and deploy the GitHub Pages download page
# Toutes les URLs sont connues ici (exe, zip, msi).
# ----------------------------------------------------------------
- name: Checkout (for generate-page.py)
uses: actions/checkout@v4
with:
ref: master
path: source
sparse-checkout: build-aux/generate-page.py
sparse-checkout-cone-mode: false
- name: Generate download page (index.html)
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
REPO="${{ github.repository }}"
# Fetch asset names from the nightly release (source of truth)
ASSETS=$(gh release view nightly --repo "$REPO" --json assets --jq '.assets[].name')
EXE_NAME=$(echo "$ASSETS" | grep '\.exe$' | head -1)
ZIP_NAME=$(echo "$ASSETS" | grep '\.zip$' | head -1)
MSI_NAME=$(echo "$ASSETS" | grep '\.msi$' | head -1 || echo "")
BASE="https://github.com/$REPO/releases/download/nightly"
INSTALLER_URL="$BASE/$EXE_NAME"
PORTABLE_URL="$BASE/$ZIP_NAME"
MSI_URL=""
[ -n "$MSI_NAME" ] && MSI_URL="$BASE/$MSI_NAME"
SHA="${{ github.event.workflow_run.head_sha || github.sha }}"
SHORT="${SHA:0:7}"
DATE=$(date -u '+%Y-%m-%d %H:%M UTC')
RUN_URL="https://github.com/$REPO/actions/runs/${{ github.run_id }}"
RUN_NUMBER="${{ github.run_number }}"
export DATE SHORT REPO SHA RUN_URL RUN_NUMBER
export INSTALLER_URL PORTABLE_URL MSI_URL
python3 source/build-aux/generate-page.py
- name: Add .nojekyll
shell: bash
run: touch gh-pages/.nojekyll
- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: gh-pages/
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4