Version Release #8
This file contains 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: Version Release | |
on: | |
schedule: | |
- cron: '0 4 * * *' # Runs at 04:00 UTC every day | |
workflow_dispatch: # Allows manual triggering | |
inputs: | |
skip_release: | |
description: 'Skip release attachment' | |
required: true | |
default: 'false' | |
type: choice | |
options: | |
- 'true' | |
- 'false' | |
jobs: | |
bump-semver: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: master | |
fetch-depth: 0 # Ensure full history for diff comparisons | |
- name: Run bump semver script | |
run: | | |
chmod +x ./.github/bump_version.sh | |
./.github/bump_version.sh | |
- name: Commit version bump | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "actions@github.com" | |
git add VERSION || true | |
git diff-index --quiet HEAD || git commit -m "Bump version to $(cat VERSION) [skip ci]" || true | |
git push origin HEAD:master --follow-tags || true | |
evaluate-release: | |
runs-on: ubuntu-latest | |
needs: bump-semver | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: master | |
fetch-depth: 0 # Get full history for tag comparison | |
- name: Read raw version | |
id: version | |
run: | | |
VERSION=$(cat VERSION) | |
echo "raw_version=${VERSION}" >> $GITHUB_OUTPUT | |
- name: Get previous tag | |
id: previous-tag | |
run: | | |
git fetch --tags | |
# Default to v0.0.0 if no tags exist | |
PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") | |
echo "prev_tag=${PREV_TAG}" >> $GITHUB_OUTPUT | |
echo "prev_version=${PREV_TAG#v}" >> $GITHUB_OUTPUT | |
- name: Compare versions | |
id: version-check | |
run: | | |
NEW_VERSION=${{ steps.version.outputs.raw_version }} | |
PREV_VERSION=${{ steps.previous-tag.outputs.prev_version }} | |
IFS='.' read -ra NEW <<< "$NEW_VERSION" | |
IFS='.' read -ra PREV <<< "$PREV_VERSION" | |
# Major/minor check (ignore patch) | |
#if [[ ${NEW[0]} -gt ${PREV[0]} || (${NEW[0]} -eq ${PREV[0]} && ${NEW[1]} -gt ${PREV[1]}) ]]; | |
#then | |
echo "RELEASE_NEEDED=true" >> $GITHUB_ENV | |
echo "new_tag=v${NEW_VERSION}" >> $GITHUB_ENV | |
#fi | |
- name: Create semver tag and release | |
if: env.RELEASE_NEEDED == 'true' | |
uses: actions/create-release@v1 | |
with: | |
tag_name: ${{ env.new_tag }} | |
release_name: ${{ env.new_tag }} | |
draft: false | |
prerelease: false | |
generate_release_notes: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
build: | |
runs-on: windows-latest | |
needs: evaluate-release | |
env: | |
SKIP_RELEASE: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.skip_release || 'false' }} | |
steps: | |
- name: Setup VS Dev Environment | |
uses: microsoft/setup-msbuild@v1.1 | |
- name: Install Visual C++ components | |
uses: ilammy/msvc-dev-cmd@v1 | |
- name: Checkout Framework | |
uses: actions/checkout@v4 | |
with: | |
repository: 'MafiaHub/Framework' | |
path: 'fwk' | |
- name: Checkout Current Repository | |
uses: actions/checkout@v4 | |
with: | |
path: 'temp_repo' | |
- name: Setup Project Structure | |
shell: cmd | |
run: | | |
cd fwk | |
mkdir code\projects | |
xcopy /E /I ..\temp_repo code\projects\mafiamp | |
- name: Configure CMake | |
shell: cmd | |
working-directory: fwk | |
run: | | |
cmake -B build -DCMAKE_BUILD_TYPE=Release -G "Ninja" | |
- name: Build Project | |
shell: cmd | |
working-directory: fwk | |
run: cmake --build build --config Release | |
- name: Prepare Release Package | |
shell: cmd | |
working-directory: fwk | |
run: | | |
xcopy /E /I code\projects\mafiamp\gamemode build\bin\gamemode | |
copy code\projects\mafiamp\LICENSE.txt build\bin\ | |
copy code\projects\mafiamp\NOTICE.txt build\bin\ | |
- name: Create Archive | |
shell: cmd | |
working-directory: fwk | |
run: | | |
powershell Compress-Archive -Path build\bin\* -DestinationPath mafiamp_release.zip | |
- name: Upload Build Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: mafiamp-release | |
path: fwk/mafiamp_release.zip | |
- name: Read Version | |
if: ${{ env.SKIP_RELEASE == 'false' }} | |
id: version | |
working-directory: temp_repo | |
shell: cmd | |
run: | | |
set /p VERSION=<VERSION | |
echo VERSION=%VERSION% >> %GITHUB_OUTPUT% | |
- name: Attach to Release | |
if: ${{ env.SKIP_RELEASE == 'false' }} | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: fwk/mafiamp_release.zip | |
tag_name: ${{ steps.version.outputs.VERSION }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Send Discord Notification | |
if: ${{ success() && env.SKIP_RELEASE == 'false' }} | |
uses: sarisia/actions-status-discord@v1 | |
with: | |
webhook: ${{ secrets.DISCORD_WEBHOOK }} | |
title: "New Release Published! 🎉" | |
description: | | |
**Version:** ${{ steps.version.outputs.VERSION }} | |
**Download:** https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.VERSION }}/mafiamp_release.zip | |
color: 0x00ff00 | |
username: MafiaMP Release Bot |