CI: build every push, release only on tag #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build | |
| on: | |
| push: | |
| branches: ['**'] | |
| tags: ['v*'] | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| # Stamp the addon's TOC version from the tag (drops the leading `v`) | |
| # BEFORE CMake configure, so the embed step picks up the stamped TOC. | |
| # The DLL bundles AddOns/!!!ClassicAPI/ at build time — see the | |
| # `embed_addon` custom command in CMakeLists.txt and the file-read | |
| # hook in src/addons/Embedded.cpp. | |
| # | |
| # Branch builds skip this — leaves the TOC's literal `## Version: DEV` | |
| # in place so the DLL identifies as a dev build at runtime. | |
| - name: Stamp embedded TOC version | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| shell: pwsh | |
| run: | | |
| $version = '${{ github.ref_name }}' -replace '^v','' | |
| $toc = 'AddOns/!!!ClassicAPI/!!!ClassicAPI.toc' | |
| (Get-Content $toc) -replace '^## Version:.*', "## Version: $version" | | |
| Set-Content $toc | |
| - name: Configure | |
| run: cmake -B build -A Win32 "-DCLASSICAPI_TAG=${{ github.ref_name }}" | |
| - name: Build | |
| run: cmake --build build --config Release | |
| # Every commit uploads the built DLL as a workflow artifact — | |
| # downloadable from the run page for ~90 days. Lets you grab a | |
| # pre-release DLL without cutting a tag. The `name` includes the | |
| # short SHA so multiple runs in the same branch don't overwrite. | |
| - name: Upload artifact | |
| if: "!startsWith(github.ref, 'refs/tags/v')" | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ClassicAPI-${{ github.sha }} | |
| path: build/Release/ClassicAPI.dll | |
| - name: Release | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: build/Release/ClassicAPI.dll | |
| generate_release_notes: true |