fix(controls): prevent interacting with the menu when the F8 console … #33
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: CI/CD | |
| on: | |
| push: | |
| branches: | |
| - '**' | |
| pull_request: | |
| # Least privilege by default. The release job elevates its own permissions | |
| # (contents: write for tags/releases, id-token: write for NuGet OIDC). | |
| permissions: | |
| contents: read | |
| # Cancel any in-progress run on the same branch | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| DOTNET_NOLOGO: true | |
| DOTNET_CLI_TELEMETRY_OPTOUT: true | |
| jobs: | |
| # ============================================================ | |
| # VERSION — calculates the shared version number once | |
| # ============================================================ | |
| version: | |
| name: Calculate Version | |
| runs-on: windows-latest | |
| outputs: | |
| semver: ${{ steps.version.outputs.semver }} | |
| assembly_ver: ${{ steps.version.outputs.assembly_ver }} | |
| zip_prefix: ${{ steps.version.outputs.zip_prefix }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install GitVersion | |
| if: github.ref == 'refs/heads/fivem-enhanced' | |
| uses: gittools/actions/gitversion/setup@v3.0.0 | |
| with: | |
| versionSpec: '5.x' | |
| - name: Execute GitVersion | |
| if: github.ref == 'refs/heads/fivem-enhanced' | |
| id: gitversion | |
| uses: gittools/actions/gitversion/execute@v3.0.0 | |
| # GitVersion produces auto-incrementing alpha pre-releases in the format | |
| # 0.0.1-alpha.1, 0.0.1-alpha.2, ... (see GitVersion.yml). AssemblyVersion uses | |
| # the numeric assemblySemVer, since pre-release labels aren't valid there. | |
| - name: Set version outputs | |
| id: version | |
| shell: bash | |
| run: | | |
| if [ "$GITHUB_REF" = "refs/heads/fivem-enhanced" ]; then | |
| SEMVER="${{ steps.gitversion.outputs.semVer }}" | |
| ASSEMBLY_VER="${{ steps.gitversion.outputs.assemblySemVer }}" | |
| else | |
| SEMVER="" | |
| ASSEMBLY_VER="" | |
| fi | |
| echo "Computed version: ${SEMVER:-<none, non-release build>}" | |
| ZIP_PREFIX="MenuAPI-${SEMVER:-dev-${{ github.run_number }}}" | |
| echo "semver=$SEMVER" >> "$GITHUB_OUTPUT" | |
| echo "assembly_ver=$ASSEMBLY_VER" >> "$GITHUB_OUTPUT" | |
| echo "zip_prefix=$ZIP_PREFIX" >> "$GITHUB_OUTPUT" | |
| # ============================================================ | |
| # BUILD FIVEM (Enhanced) | |
| # ============================================================ | |
| build-fivem: | |
| name: Build FiveM | |
| needs: version | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Restore NuGet (FiveM only) | |
| shell: bash | |
| run: dotnet restore "MenuAPI/MenuAPI.csproj" -p:Configuration=Release | |
| - name: Build FiveM (versioned) | |
| if: github.ref == 'refs/heads/fivem-enhanced' | |
| shell: bash | |
| run: | | |
| dotnet build MenuAPI/MenuAPI.csproj -c Release --no-restore \ | |
| -p:Version=${{ needs.version.outputs.semver }} \ | |
| -p:AssemblyVersion=${{ needs.version.outputs.assembly_ver }} \ | |
| -p:FileVersion=${{ needs.version.outputs.assembly_ver }} | |
| - name: Build FiveM | |
| if: github.ref != 'refs/heads/fivem-enhanced' | |
| run: dotnet build MenuAPI/MenuAPI.csproj -c Release --no-restore | |
| - name: Package FiveM zip | |
| shell: pwsh | |
| run: | | |
| $outDir = 'MenuAPI/bin/Release/net10.0' | |
| Copy-Item README.md "$outDir/README.md" -Force | |
| Compress-Archive -Path "$outDir/*" -DestinationPath "${{ needs.version.outputs.zip_prefix }}-FiveM-Enhanced.zip" -Force | |
| - name: Upload FiveM zip | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: zip-fivem | |
| path: ${{ needs.version.outputs.zip_prefix }}-FiveM-Enhanced.zip | |
| - name: Pack NuGet FiveM | |
| if: github.ref == 'refs/heads/fivem-enhanced' | |
| run: >- | |
| dotnet pack MenuAPI/MenuAPI.csproj | |
| -c Release | |
| --no-restore | |
| -p:PackageVersion=${{ needs.version.outputs.semver }} | |
| -o nupkgs | |
| - name: Upload NuGet FiveM | |
| if: github.ref == 'refs/heads/fivem-enhanced' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nuget-fivem | |
| path: nupkgs/*.nupkg | |
| # ============================================================ | |
| # RELEASE (fivem-enhanced only), after the build succeeds. | |
| # Publishes a DRAFT, pre-release GitHub release and a pre-release NuGet package. | |
| # ============================================================ | |
| release: | |
| name: Release | |
| needs: [version, build-fivem] | |
| if: github.ref == 'refs/heads/fivem-enhanced' | |
| runs-on: windows-latest | |
| # contents: write for the git tag + GitHub release; id-token: write so NuGet | |
| # Trusted Publishing (OIDC) can mint a short-lived key (no API-key secret). | |
| permissions: | |
| contents: write | |
| id-token: write | |
| outputs: | |
| release_url: ${{ steps.create_release.outputs.release_url }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download FiveM zip | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: zip-fivem | |
| path: release-assets | |
| - name: Download NuGet FiveM | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: nuget-fivem | |
| path: release-assets | |
| # Generate changelog BEFORE tagging so the range is correct | |
| - name: Generate changelog | |
| shell: bash | |
| run: | | |
| LAST_TAG=$(git tag --list 'enhanced-v*' --sort=-version:refname | head -n 1) | |
| if [ -n "$LAST_TAG" ]; then | |
| git log "$LAST_TAG..HEAD" --pretty=format:'- `%h` (%an) %s' > changelog.txt | |
| else | |
| git log --pretty=format:'- `%h` (%an) %s' > changelog.txt | |
| fi | |
| echo "Last tag used for changelog: ${LAST_TAG:-<none, full history>}" | |
| cat changelog.txt | |
| - name: Create and push git tag | |
| shell: bash | |
| run: | | |
| VERSION="${{ needs.version.outputs.semver }}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" | |
| # Idempotent: GitVersion is deterministic per commit, so re-running the same | |
| # commit yields the same tag. Skip creation if it already exists on origin. | |
| if git ls-remote --exit-code --tags origin "refs/tags/enhanced-v$VERSION" >/dev/null 2>&1; then | |
| echo "Tag enhanced-v$VERSION already exists on origin, skipping." | |
| else | |
| git tag "enhanced-v$VERSION" | |
| git push origin "enhanced-v$VERSION" | |
| fi | |
| - name: Create GitHub Release | |
| id: create_release | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION="${{ needs.version.outputs.semver }}" | |
| { | |
| echo "MenuAPI for FiveM Enhanced (pre-release) v${VERSION}. Download the zip below." | |
| echo "" | |
| echo "## Changes" | |
| cat changelog.txt | |
| echo "" | |
| echo "For more info, check the [docs](https://docs.vespura.com/menuapi/enhanced)." | |
| } > release_notes.md | |
| # Draft + pre-release. Tag is enhanced-v<version> to keep the Enhanced | |
| # release line separate from the legacy v<version> tags. Idempotent: a | |
| # re-run of the same version reuses the existing draft instead of failing. | |
| if gh release view "enhanced-v$VERSION" >/dev/null 2>&1; then | |
| echo "Release enhanced-v$VERSION already exists, updating its asset." | |
| gh release upload "enhanced-v$VERSION" "release-assets/MenuAPI-$VERSION-FiveM-Enhanced.zip" --clobber | |
| RELEASE_URL=$(gh release view "enhanced-v$VERSION" --json url --jq .url) | |
| else | |
| RELEASE_URL=$(gh release create "enhanced-v$VERSION" \ | |
| --title "MenuAPI for FiveM Enhanced" \ | |
| --notes-file release_notes.md \ | |
| --draft \ | |
| --prerelease \ | |
| "release-assets/MenuAPI-$VERSION-FiveM-Enhanced.zip") | |
| fi | |
| echo "release_url=$RELEASE_URL" >> "$GITHUB_OUTPUT" | |
| # NuGet Trusted Publishing (OIDC): exchange the GitHub Actions id-token for a | |
| # short-lived NuGet API key. No long-lived NUGET_API_KEY secret is needed. | |
| # Requires a matching trusted-publishing policy on nuget.org (see below). | |
| - name: NuGet login (trusted publishing) | |
| uses: NuGet/login@v1 | |
| id: nuget_login | |
| with: | |
| user: ${{ vars.NUGET_USER }} | |
| - name: Publish NuGet (FiveM Enhanced) | |
| run: >- | |
| dotnet nuget push | |
| "release-assets/MenuAPI.FiveM.Enhanced.${{ needs.version.outputs.semver }}.nupkg" | |
| --api-key ${{ steps.nuget_login.outputs.NUGET_API_KEY }} | |
| --source https://api.nuget.org/v3/index.json | |
| --skip-duplicate | |
| # ============================================================ | |
| # DISCORD NOTIFICATION — always runs | |
| # ============================================================ | |
| notify: | |
| name: Discord Notification | |
| needs: [version, build-fivem, release] | |
| if: always() | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Send Discord notification | |
| shell: bash | |
| env: | |
| DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
| run: | | |
| if [ -z "$DISCORD_WEBHOOK_URL" ]; then | |
| echo "DISCORD_WEBHOOK_URL not configured, skipping." | |
| exit 0 | |
| fi | |
| FIVEM_RESULT="${{ needs.build-fivem.result }}" | |
| RELEASE_RESULT="${{ needs.release.result }}" | |
| VERSION="${{ needs.version.outputs.semver }}" | |
| # ── Status colour & label ────────────────────────────────────────── | |
| if [ "$FIVEM_RESULT" = "cancelled" ] || [ "$RELEASE_RESULT" = "cancelled" ]; then | |
| COLOR=16776960 | |
| STATUS_TEXT="Build cancelled." | |
| elif [ "$FIVEM_RESULT" = "success" ] && \ | |
| { [ "$RELEASE_RESULT" = "success" ] || [ "$RELEASE_RESULT" = "skipped" ]; }; then | |
| COLOR=4502298 | |
| STATUS_TEXT="Build passed!" | |
| else | |
| COLOR=13632027 | |
| STATUS_TEXT="Build FAILED!" | |
| fi | |
| # ── Link field ───────────────────────────────────────────────────── | |
| RELEASE_URL="${{ needs.release.outputs.release_url }}" | |
| if [ -n "$RELEASE_URL" ] && [ "$RELEASE_RESULT" = "success" ]; then | |
| LINK_NAME="GitHub Release" | |
| LINK_URL="$RELEASE_URL" | |
| else | |
| LINK_NAME="Build Run" | |
| LINK_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
| fi | |
| DISPLAY_VERSION="${VERSION:-dev-${{ github.run_number }}}" | |
| SHA="${{ github.sha }}" | |
| SHORT_SHA="${SHA:0:7}" | |
| PAYLOAD=$(jq -n \ | |
| --arg title "MenuAPI (v${DISPLAY_VERSION})" \ | |
| --arg desc "$STATUS_TEXT" \ | |
| --argjson color "$COLOR" \ | |
| --arg actor "${{ github.actor }}" \ | |
| --arg actor_url "https://github.com/${{ github.actor }}" \ | |
| --arg branch "${{ github.ref_name }}" \ | |
| --arg link_name "$LINK_NAME" \ | |
| --arg link_url "$LINK_URL" \ | |
| --arg short_sha "$SHORT_SHA" \ | |
| --arg commit_url "https://github.com/${{ github.repository }}/commit/${{ github.sha }}" \ | |
| --arg commit_msg "${{ github.event.head_commit.message }}" \ | |
| '{ | |
| embeds: [{ | |
| title: $title, | |
| description: $desc, | |
| color: $color, | |
| author: { | |
| name: ("Committed by " + $actor), | |
| url: $actor_url | |
| }, | |
| fields: [ | |
| { name: "Branch", value: $branch, inline: true }, | |
| { name: $link_name, value: ("[Link](" + $link_url + ")"), inline: true }, | |
| { name: "Commit", value: ("[`" + $short_sha + "`](" + $commit_url + ") — " + $commit_msg), inline: false } | |
| ] | |
| }] | |
| }') | |
| curl -fsSL -H "Content-Type: application/json" -X POST -d "$PAYLOAD" "$DISCORD_WEBHOOK_URL" |