Skip to content

Commit

Permalink
chore(github): create release and lint actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Manason committed Sep 9, 2024
1 parent 10be473 commit 37eb6a2
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/actions/bump-manifest-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Based off of https://github.com/overextended/ox_lib/blob/master/.github/actions/bump-manifest-version.js
const fs = require('fs')

const version = process.env.TGT_RELEASE_VERSION
const newVersion = version.replace('v', '')

const manifestFile = fs.readFileSync('fxmanifest.lua', {encoding: 'utf8'})

const newFileContent = manifestFile.replace(/\bversion\s+(.*)$/gm, `version '${newVersion}'`)

fs.writeFileSync('fxmanifest.lua', newFileContent)
23 changes: 23 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Lint
on: [push, pull_request_target]
jobs:
lint:
name: Lint Resource
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Lint
uses: iLLeniumStudios/fivem-lua-lint-action@v2
with:
capture: "junit.xml"
args: "-t --formatter JUnit"
extra_libs: ox_lib+mysql+qblocales+qbox+qbox_playerdata+qbox_lib
- name: Generate Lint Report
if: always()
uses: mikepenz/action-junit-report@v4
with:
report_paths: "**/junit.xml"
check_name: Linting Report
fail_on_failure: false
55 changes: 55 additions & 0 deletions .github/workflows/release-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: "Release Action"

on:
workflow_run:
workflows: [Create New Release]
types:
- completed

jobs:
release-action:
name: "Create Release"
runs-on: "ubuntu-latest"
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.repository.default_branch }}

- name: Get the latest tag
id: get_tag
run: |
echo "LATEST_TAG=$(git tag --sort=-creatordate | head -n 1)" >> $GITHUB_ENV
- name: Install ZIP
run: sudo apt install zip

- name: Bundle files
run: |
shopt -s extglob
mkdir -p ./temp/${{ github.event.repository.name }}
cp ./{README.md,fxmanifest.lua} ./temp/${{ github.event.repository.name }}
cp -r ./{client,bridge,configs,modules,servers} ./temp/${{ github.event.repository.name }}
cd ./temp && zip -r ../${{ github.event.repository.name }}.zip ./${{ github.event.repository.name }}
- name: Update CHANGELOG
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.LATEST_TAG }}
includeInvalidCommits: true
writeToFile: false

- name: Create Release
uses: ncipollo/[email protected]
with:
allowUpdates: true
draft: false
makeLatest: true
name: ${{ env.LATEST_TAG }}
tag: ${{ env.LATEST_TAG }}
body: ${{ steps.changelog.outputs.changes }}
artifacts: ${{ github.event.repository.name }}.zip
token: ${{ secrets.GITHUB_TOKEN }}
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Create New Release

on:
workflow_dispatch:
inputs:
version:
required: true

jobs:
create-release:
name: Create New Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Bump manifest version
run: node .github/actions/bump-manifest-version.js
env:
TGT_RELEASE_VERSION: ${{ inputs.version }}

- name: Push manifest change
uses: EndBug/add-and-commit@v9
with:
add: fxmanifest.lua
push: true
message: 'chore: bump manifest version to ${{ inputs.version }}'
tag: ${{ inputs.version }}

0 comments on commit 37eb6a2

Please sign in to comment.