Update fivem-release.yml #2
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: FiveM Auto Version & Release | ||
| on: | ||
| workflow_call: | ||
| jobs: | ||
| build-release: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Bump version | ||
| - name: Bump version | ||
| id: bump_version | ||
| run: | | ||
| # Check if fxmanifest.lua exists | ||
| if [ ! -f "fxmanifest.lua" ]; then | ||
| echo "❌ fxmanifest.lua not found!" | ||
| exit 1 | ||
| fi | ||
| # Get the old version | ||
| OLD_VERSION=$(grep -E "version ['\"][0-9]+\.[0-9]+\.[0-9]+['\"]" fxmanifest.lua | head -n 1 | sed -E "s/.*version ['\"]([0-9]+\.[0-9]+\.[0-9]+)['\"].*/\1/") | ||
| if [ -z "$OLD_VERSION" ]; then | ||
| echo "❌ Version not found in fxmanifest.lua!" | ||
| exit 1 | ||
| fi | ||
| echo "✅ Old version: $OLD_VERSION" | ||
| # Get custom version from commit message if it exists | ||
| CUSTOM_VERSION="$(git log -1 --pretty=%B | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')" | ||
| echo "Debug: Custom version from commit = '$CUSTOM_VERSION'" | ||
| if [ -n "$CUSTOM_VERSION" ]; then | ||
| NEW_VERSION=$CUSTOM_VERSION | ||
| echo "Debug: Using custom version from commit message" | ||
| else | ||
| # Parse and increment version | ||
| IFS='.' read -r major minor patch <<< "$OLD_VERSION" | ||
| echo "Debug: Parsed version - major=$major, minor=$minor, patch=$patch" | ||
| patch=$((patch + 1)) | ||
| if [ "$patch" -gt 9 ]; then | ||
| patch=0 | ||
| minor=$((minor + 1)) | ||
| fi | ||
| if [ "$minor" -gt 9 ]; then | ||
| minor=0 | ||
| major=$((major + 1)) | ||
| fi | ||
| NEW_VERSION="${major}.${minor}.${patch}" | ||
| echo "Debug: Calculated new version = $NEW_VERSION" | ||
| fi | ||
| # Update the version in the file | ||
| echo "Debug: Attempting to update version in fxmanifest.lua" | ||
| if ! sed -i -E "s/version ['\"][0-9]+\.[0-9]+\.[0-9]+['\"]/version '$NEW_VERSION'/" fxmanifest.lua; then | ||
| echo "❌ Failed to update version in fxmanifest.lua" | ||
| exit 1 | ||
| fi | ||
| # Verify the update worked | ||
| if ! grep -q "version '$NEW_VERSION'" fxmanifest.lua; then | ||
| echo "❌ Version update verification failed" | ||
| exit 1 | ||
| fi | ||
| # Set output | ||
| echo "Debug: Setting GitHub output" | ||
| echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT | ||
| echo "✅ New version: $NEW_VERSION" | ||
| - name: Commit updated manifest | ||
| uses: stefanzweifel/git-auto-commit-action@v5 | ||
| with: | ||
| commit_message: "chore: Bump version to ${{ steps.bump_version.outputs.new_version }}" | ||
| - name: Prepare Escrow Version | ||
| run: | | ||
| mkdir -p escrow_version | ||
| rsync -av --exclude='.git' --exclude='escrow_version' --exclude='open_source_version' ./ escrow_version/ | ||
| - name: Prepare Open Source Version | ||
| run: | | ||
| mkdir -p open_source_version | ||
| rsync -av --exclude='.git' --exclude='escrow_version' --exclude='open_source_version' ./ open_source_version/ | ||
| sed -i '/escrow_ignore {/,/}/ s/^/--/' open_source_version/fxmanifest.lua | ||
| echo -e "escrow_ignore {\n '**.**',\n '**/**',\n '**/**/**'\n}" >> open_source_version/fxmanifest.lua | ||
| - name: Create ZIP archives | ||
| run: | | ||
| zip -r escrow_version.zip escrow_version | ||
| zip -r open_source_version.zip open_source_version | ||
| - name: Create Release | ||
| uses: softprops/action-gh-release@v1 | ||
| with: | ||
| tag_name: "v${{ steps.bump_version.outputs.new_version }}" | ||
| files: | | ||
| escrow_version.zip | ||
| open_source_version.zip | ||