11name : Release
22
3- # Déclenché quand on pousse un tag de version (ex: git tag v1.0.1 && git push origin v1.0.1)
3+ # Builds mss32.dll and attaches the assets to the release automatically.
4+ # - fires when you PUBLISH a release on GitHub (uses that release's tag), or
5+ # - run it by hand (Actions tab -> Release -> Run workflow) for an existing tag.
46on :
5- push :
6- tags : ['v*' ]
7+ release :
8+ types : [published ]
79 workflow_dispatch :
810 inputs :
9- version :
10- description : ' Version sans le v (ex: 1.0.1) '
11+ tag :
12+ description : " Existing release tag to build + attach assets to (e.g. 1.6.0) "
1113 required : true
1214
1315permissions :
14- contents : write # requis pour créer la Release via GITHUB_TOKEN
16+ contents : write # required for gh release upload via GITHUB_TOKEN
1517
1618jobs :
17- release :
19+ build-and-upload :
1820 runs-on : windows-latest
1921 steps :
2022 - uses : actions/checkout@v4
2123
22- # Toolchain MinGW 32-bit (identique au build local C:\msys64\mingw32)
24+ - name : Resolve version tag
25+ shell : bash
26+ run : |
27+ TAG="${{ github.event.release.tag_name }}"
28+ [ -z "$TAG" ] && TAG="${{ github.event.inputs.tag }}"
29+ TAG="${TAG#v}" # strip a leading 'v' if present
30+ echo "TAG=$TAG" >> "$GITHUB_ENV"
31+ echo "Building cod1reloaded $TAG"
32+
33+ # Same toolchain as the local build (msys2 mingw32, 32-bit).
2334 - uses : msys2/setup-msys2@v2
2435 with :
2536 msystem : MINGW32
@@ -30,35 +41,35 @@ jobs:
3041 mingw-w64-i686-make
3142 zip
3243
33- - name : Build & package
44+ - name : Build mss32.dll
3445 shell : msys2 {0}
3546 run : |
3647 set -e
37- if [ -n "${{ github.event.inputs.version }}" ]; then VER="${{ github.event.inputs.version }}"; else VER="${GITHUB_REF_NAME#v}"; fi
38- echo "VERSION=$VER" >> "$GITHUB_ENV"
39- echo "=== cod1reloaded $VER ==="
40-
41- # Stampe la version (depuis le tag) dans le binaire
42- sed -i "s/COD1RELOADED_VERSION = \"[0-9.]*\"/COD1RELOADED_VERSION = \"$VER\"/" src/updater.h
43-
44- cmake -S . -B build -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release
45- cmake --build build
48+ # keep the compiled version in sync with the release tag
49+ sed -i "s/COD1RELOADED_VERSION = \"[^\"]*\"/COD1RELOADED_VERSION = \"$TAG\"/" src/features/updater.h
50+ cmake -S . -B build -G "MinGW Makefiles"
51+ cmake --build build --target mss32
4652 test -f build/mss32.dll
4753
54+ - name : Package assets
55+ shell : msys2 {0}
56+ run : |
57+ set -e
4858 mkdir -p dist
49- cp build/mss32.dll dist/
50- cp cod1reloaded.ini dist/
51- printf '{\n "version": "%s",\n "download_url": "https://github.com/cod1plus/client/releases/latest/download/mss32.dll",\n "notes": "cod1reloaded %s"\n}\n' "$VER" "$VER" > dist/manifest.json
52- (cd dist && zip -q "cod1reloaded-$VER.zip" mss32.dll cod1reloaded.ini)
59+ cp build/mss32.dll cod1reloaded.ini dist/
60+ printf '{\n "version": "%s",\n "download_url": "https://github.com/%s/releases/latest/download/mss32.dll",\n "notes": "cod1reloaded %s - see CHANGELOG"\n}\n' \
61+ "$TAG" "$GITHUB_REPOSITORY" "$TAG" > dist/manifest.json
62+ ( cd dist && zip -q "cod1reloaded-$TAG.zip" mss32.dll cod1reloaded.ini )
63+ ls -l dist
5364
54- - name : Create GitHub Release
55- shell : pwsh
65+ - name : Upload assets to the release
66+ shell : bash
5667 env :
5768 GH_TOKEN : ${{ github.token }}
5869 run : |
59- gh release create "v$env:VERSION" `
60- " dist/mss32.dll" `
61- " dist/manifest.json" `
62- " dist/cod1reloaded-$env:VERSION.zip" `
63- --title " cod1reloaded $env:VERSION" `
64- --generate-notes
70+ gh release upload "$TAG" \
71+ dist/mss32.dll \
72+ dist/cod1reloaded.ini \
73+ dist/manifest.json \
74+ "dist/ cod1reloaded-$TAG.zip" \
75+ --clobber
0 commit comments