|
1 | | -name: FiveM Release |
2 | | -on: |
3 | | - workflow_call: |
| 1 | +workflow_call: |
4 | 2 | permissions: |
5 | | - contents: write |
6 | | - |
| 3 | +contents: write |
7 | 4 | jobs: |
8 | | - build-release: |
9 | | - runs-on: ubuntu-latest |
10 | | - env: |
11 | | - EXCLUDES: "--exclude='.git/' --exclude='.github/' --exclude='.vscode/' --exclude='*.zip' --exclude='temp_build_dir/'" |
12 | | - steps: |
13 | | - - uses: actions/checkout@v4 |
14 | | - with: |
15 | | - fetch-depth: 0 |
16 | | - |
17 | | - - name: Get Repository Name |
18 | | - id: repo_name |
19 | | - run: echo "repo_name=${GITHUB_REPOSITORY#*/}" >> "$GITHUB_OUTPUT" |
20 | | - |
21 | | - - name: Get Version from fxmanifest |
22 | | - id: get_version |
23 | | - shell: bash |
| 5 | +build-release: |
| 6 | +runs-on: ubuntu-latest |
| 7 | +steps: |
| 8 | +- uses: actions/checkout@v4 |
| 9 | +with: |
| 10 | +fetch-depth: 0 |
| 11 | +- name: Get Repository Name |
| 12 | +id: repo_name |
| 13 | + run: echo "repo_name=${GITHUB_REPOSITORY#*/}" >> $GITHUB_OUTPUT |
| 14 | +- name: Get Version from fxmanifest |
| 15 | +id: get_version |
| 16 | +run: | |
| 17 | + VERSION=$(grep -E "version ['\"][0-9]+\.[0-9]+\.[0-9]+['\"]" fxmanifest.lua | sed -E "s/.*version ['\"]([0-9]+\.[0-9]+\.[0-9]+)['\"].*/\1/") |
| 18 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 19 | + - name: Create Escrow Version |
| 20 | +run: | |
| 21 | + # Create a temp directory for building the zip |
| 22 | + TEMP_DIR="$(pwd)/temp_build_dir" |
| 23 | + mkdir -p "$TEMP_DIR/${{ steps.repo_name.outputs.repo_name }}" |
| 24 | + |
| 25 | + # Copy files to the folder structure |
| 26 | + rsync -av --exclude='.git/' --exclude='.github/' --exclude='.vscode/' --exclude='*.zip' --exclude='temp_build_dir/' ./ "$TEMP_DIR/${{ steps.repo_name.outputs.repo_name }}/" |
| 27 | + |
| 28 | + # Create zip |
| 29 | + cd "$TEMP_DIR" |
| 30 | + zip -r "${{ steps.repo_name.outputs.repo_name }}_escrow.zip" "${{ steps.repo_name.outputs.repo_name }}" |
| 31 | + |
| 32 | + # Move the zip back to workspace |
| 33 | + mv "${{ steps.repo_name.outputs.repo_name }}_escrow.zip" "$GITHUB_WORKSPACE/" |
| 34 | + |
| 35 | + # Clean up |
| 36 | + cd "$GITHUB_WORKSPACE" |
| 37 | + rm -rf "$TEMP_DIR" |
| 38 | + - name: Create Open Source Version |
24 | 39 | run: | |
25 | | - set -euo pipefail |
26 | | - test -f fxmanifest.lua || { echo "fxmanifest.lua missing"; exit 1; } |
27 | | - VERSION=$(grep -Eo "version ['\"][0-9]+\.[0-9]+\.[0-9]+['\"]" fxmanifest.lua | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+") |
28 | | - [ -n "${VERSION:-}" ] || { echo "version not found in fxmanifest.lua"; exit 1; } |
29 | | - echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
30 | | -
|
31 | | - - name: Package variant |
32 | | - id: package |
33 | | - shell: bash |
34 | | - run: | |
35 | | - set -euo pipefail |
36 | | - build_one () { |
37 | | - local variant="$1" # escrow | opensource |
38 | | - local tmp="$PWD/temp_build_dir_$variant" |
39 | | - mkdir -p "$tmp/${{ steps.repo_name.outputs.repo_name }}" |
40 | | - rsync -a --delete $EXCLUDES ./ "$tmp/${{ steps.repo_name.outputs.repo_name }}/" |
41 | | - (cd "$tmp" && zip -rq -X "${{ steps.repo_name.outputs.repo_name }}_${variant}.zip" "${{ steps.repo_name.outputs.repo_name }}") |
42 | | - mv "$tmp/${{ steps.repo_name.outputs.repo_name }}_${variant}.zip" "$GITHUB_WORKSPACE/" |
43 | | - rm -rf "$tmp" |
44 | | - } |
45 | | - build_one escrow |
46 | | - build_one opensource |
47 | | - echo "escrow_asset=${{ steps.repo_name.outputs.repo_name }}_escrow.zip" >> "$GITHUB_OUTPUT" |
48 | | - echo "oss_asset=${{ steps.repo_name.outputs.repo_name }}_opensource.zip" >> "$GITHUB_OUTPUT" |
49 | | -
|
50 | | - - name: Generate Release Tag |
51 | | - id: tag |
52 | | - run: echo "release_tag=v${{ steps.get_version.outputs.version }}" >> "$GITHUB_OUTPUT" |
53 | | - |
54 | | - - name: Create Release (single tag, two assets, stamped) |
55 | | - uses: softprops/action-gh-release@v2 |
56 | | - with: |
57 | | - tag_name: ${{ steps.tag.outputs.release_tag }} |
58 | | - name: "${{ steps.repo_name.outputs.repo_name }} v${{ steps.get_version.outputs.version }} [escrow] [opensource]" |
59 | | - body: | |
60 | | - **Release variants** |
61 | | - - `escrow`: ${{ steps.package.outputs.escrow_asset }} |
62 | | - - `opensource`: ${{ steps.package.outputs.oss_asset }} |
63 | | - files: | |
64 | | - ${{ steps.package.outputs.escrow_asset }} |
65 | | - ${{ steps.package.outputs.oss_asset }} |
66 | | - make_latest: true |
| 40 | + # Create a temp directory for building the zip |
| 41 | + TEMP_DIR="$(pwd)/temp_build_dir" |
| 42 | + mkdir -p "$TEMP_DIR/${{ steps.repo_name.outputs.repo_name }}" |
| 43 | + |
| 44 | + # Copy files to the folder structure |
| 45 | + rsync -av --exclude='.git/' --exclude='.github/' --exclude='.vscode/' --exclude='*.zip' --exclude='temp_build_dir/' ./ "$TEMP_DIR/${{ steps.repo_name.outputs.repo_name }}/" |
| 46 | + |
| 47 | + # Create zip |
| 48 | + cd "$TEMP_DIR" |
| 49 | + zip -r "${{ steps.repo_name.outputs.repo_name }}_opensource.zip" "${{ steps.repo_name.outputs.repo_name }}" |
| 50 | + |
| 51 | + # Move the zip back to workspace |
| 52 | + mv "${{ steps.repo_name.outputs.repo_name }}_opensource.zip" "$GITHUB_WORKSPACE/" |
| 53 | + |
| 54 | + # Clean up |
| 55 | + cd "$GITHUB_WORKSPACE" |
| 56 | + rm -rf "$TEMP_DIR" |
| 57 | + - name: Generate Release Tag |
| 58 | +id: tag |
| 59 | + run: echo "release_tag=v${{ steps.get_version.outputs.version }}" >> $GITHUB_OUTPUT |
| 60 | + - name: Create Release |
| 61 | + uses: softprops/action-gh-release@v1 |
| 62 | +with: |
| 63 | +tag_name: ${{ steps.tag.outputs.release_tag }} |
| 64 | + files: | |
| 65 | + ${{ steps.repo_name.outputs.repo_name }}_escrow.zip |
| 66 | + ${{ steps.repo_name.outputs.repo_name }}_opensource.zip |
0 commit comments