Skip to content
This repository was archived by the owner on Apr 29, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/actions/bump-manifest-version.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const fs = require('fs')
const fs = require('fs');

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

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

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

fs.writeFileSync('fxmanifest.lua', newFileContent)
fs.writeFileSync('fxmanifest.lua', newFileContent);
10 changes: 10 additions & 0 deletions .github/actions/bump-package-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const fs = require('fs');

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

const packageFile = fs.readFileSync('package/package.json', { encoding: 'utf8' });

const newFileContent = packageFile.replace(/"version":\s+"(.*)",$/gm, `"version": "${newVersion}",`);

fs.writeFileSync('package/package.json', newFileContent);
88 changes: 88 additions & 0 deletions .github/workflows/build-reusable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build (Reusable)

on:
workflow_call:
inputs:
bump_version:
required: false
default: false
type: boolean
version:
required: false
type: string
default: ''

jobs:
build:
name: Build ox_lib
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Set env
if: inputs.version != ''
run: echo "RELEASE_VERSION=${{ inputs.version }}" >> $GITHUB_ENV

- name: Install package dependencies
run: bun install
working-directory: package

- name: Install web dependencies
run: bun install
working-directory: web

- name: Run web build script
run: bun run build
working-directory: web

- name: Bump package version
if: inputs.bump_version
run: bun .github/actions/bump-package-version.js
env:
TGT_RELEASE_VERSION: ${{ inputs.version }}

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

- name: Push version bump change
if: inputs.bump_version
uses: EndBug/add-and-commit@v9
with:
add: '["fxmanifest.lua", "package/package.json"]'
push: true
default_author: github_actions
message: 'chore: bump version to ${{ inputs.version }}'

- name: Bundle files
run: |
mkdir -p ./temp/ox_lib
mkdir -p ./temp/ox_lib/web/
cp ./{LICENSE,README.md,fxmanifest.lua,init.lua} ./temp/ox_lib
cp -r ./{imports,resource,locales} ./temp/ox_lib
cp -r ./web/build ./temp/ox_lib/web/

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ox_lib_build
path: ./temp/ox_lib

- name: Publish package to npm registry
if: inputs.bump_version
run: bun publish --access public
working-directory: package
env:
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}


14 changes: 14 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Build

on:
push:
branches: master
pull_request:
branches: master

jobs:
build:
name: Build ox_lib
uses: ./.github/workflows/build-reusable.yml
with:
bump_version: false
94 changes: 17 additions & 77 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,100 +1,40 @@
name: Release
name: Create release

on:
push:
tags:
- 'v*.*.*'

jobs:
build:
name: Build Release
uses: ./.github/workflows/build-reusable.yml
with:
bump_version: true
version: ${{ github.ref_name }}

create-release:
name: Build and Create Tagged Release
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Install archive tools
run: sudo apt install zip

- name: Checkout source code
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.repository.default_branch }}

- uses: pnpm/[email protected]
with:
version: 8.6.1

- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 16.x
cache: 'pnpm'
cache-dependency-path: 'web/pnpm-lock.yaml'

- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Install dependencies
run: pnpm install
working-directory: web

- name: Install package dependencies
run: pnpm install
working-directory: package

- name: Bump package version
run: pnpm version ${{ github.ref_name }}
working-directory: package
uses: actions/checkout@v4

- name: Run build
run: pnpm build
working-directory: web
env:
CI: false

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

- name: Push manifest change
uses: EndBug/add-and-commit@v8
- name: Download build artifact
uses: actions/download-artifact@v4 # Updated action version
with:
add: fxmanifest.lua
push: true
author_name: Manifest Bumper
author_email: 41898282+github-actions[bot]@users.noreply.github.com
message: 'chore: bump manifest version to ${{ github.ref_name }}'

- name: Update tag ref
uses: EndBug/latest-tag@latest
with:
tag-name: ${{ github.ref_name }}

- name: Bundle files
run: |
mkdir -p ./temp/ox_lib
mkdir -p ./temp/ox_lib/web/
cp ./{LICENSE,README.md,fxmanifest.lua,init.lua} ./temp/ox_lib
cp -r ./{imports,resource,locales} ./temp/ox_lib
cp -r ./web/build ./temp/ox_lib/web/
cd ./temp && zip -r ../ox_lib.zip ./ox_lib
name: ox_lib_build # Updated artifact name

# This dependency is archived, possibly replace it with a maintained one
- name: Create Release
uses: 'marvinpinto/[email protected]'
uses: marvinpinto/[email protected]
id: auto_release
with:
repo_token: '${{ secrets.GITHUB_TOKEN }}'
title: ${{ env.RELEASE_VERSION }}
title: ${{ github.ref_name }}
prerelease: false
files: ox_lib.zip

env:
CI: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish npm package
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
package: './package/package.json'
access: 'public'
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ We welcome you to contribute to our projects, whether reporting a bug, suggestin

### Search for existing issues

Before creating a new issue, please search existing [issues](https://github.com/overextended/ox_lib/issues) to see if it has already been reported.
Before creating a new issue, please search existing [issues](https://github.com/communityox/ox_lib/issues) to see if it has already been reported.

### Add details to existing issues

Expand Down Expand Up @@ -51,7 +51,7 @@ Pull requests that do not contribute meaningful improvements to the project's st
- Fork the repository and, optionally, create a new branch for your changes.
- If applicable, include example code to demonstrate your changes.
- Ensure your code's style is consistent with the project, e.g. uses the same indentation and string quotations.
- If you have modified or introduced new APIs, open a pull request to our [documentation](https://github.com/overextended/overextended.github.io). We will not accept undocumented code.
- If you have modified or introduced new APIs, open a pull request to our [documentation](https://github.com/communityox/docs). We will not accept undocumented code.

## Contributor License Agreement

Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

A FiveM library and resource implementing reusable modules, methods, and UI elements.

![](https://img.shields.io/github/downloads/overextended/ox_lib/total?logo=github)
![](https://img.shields.io/github/downloads/overextended/ox_lib/latest/total?logo=github)
![](https://img.shields.io/github/contributors/overextended/ox_lib?logo=github)
![](https://img.shields.io/github/v/release/overextended/ox_lib?logo=github)
![](https://img.shields.io/github/downloads/communityox/ox_lib/total?logo=github)
![](https://img.shields.io/github/downloads/communityox/ox_lib/latest/total?logo=github)
![](https://img.shields.io/github/contributors/communityox/ox_lib?logo=github)
![](https://img.shields.io/github/v/release/communityox/ox_lib?logo=github)

For guidelines to contributing to the project, and to see our Contributor License Agreement, see [CONTRIBUTING.md](./CONTRIBUTING.md)

Expand All @@ -14,19 +14,19 @@ For additional legal notices, refer to [NOTICE.md](./NOTICE.md).

## 📚 Documentation

https://overextended.dev/ox_lib
https://coxdocs.dev/ox_lib

## 💾 Download

https://github.com/overextended/ox_lib/releases/latest/download/ox_lib.zip
https://github.com/communityox/ox_lib/releases/latest/download/ox_lib.zip

## 📦 npm package

https://www.npmjs.com/package/@overextended/ox_lib
https://www.npmjs.com/package/@communityox/ox_lib

## 🖥️ Lua Language Server

- Install [Lua Language Server](https://marketplace.visualstudio.com/items?itemName=sumneko.lua) to ease development with annotations, type checking, diagnostics, and more.
- Install [cfxlua-vscode](https://marketplace.visualstudio.com/items?itemName=overextended.cfxlua-vscode) to add natives and cfxlua runtime declarations to LLS.
- Install [cfxlua-vscode](https://marketplace.visualstudio.com/items?itemName=communityox.cfxlua-vscode) to add natives and cfxlua runtime declarations to LLS.
- You can load ox_lib into your global development environment by modifying workspace/user settings "Lua.workspace.library" with the resource path.
- e.g. "c:/fxserver/resources/ox_lib"
4 changes: 2 additions & 2 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aw

name 'ox_lib'
author 'Overextended'
version '3.30.6'
version '3.30.7'
license 'LGPL-3.0-or-later'
repository 'https://github.com/overextended/ox_lib'
repository 'https://github.com/communityox/ox_lib'
description 'A library of shared functions to utilise in other resources.'

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion imports/locale/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ end

local table = lib.table

---Loads the ox_lib locale module. Prefer using fxmanifest instead (see [docs](https://overextended.dev/ox_lib#usage)).
---Loads the ox_lib locale module. Prefer using fxmanifest instead (see [docs](https://coxdocs.dev/ox_lib#usage)).
---@param key? string
function lib.locale(key)
local lang = key or lib.getLocaleKey()
Expand Down
14 changes: 7 additions & 7 deletions package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,30 @@ You still need to use and have the ox_lib resource included into the resource yo

```yaml
# With pnpm
pnpm add @overextended/ox_lib
pnpm add @communityox/ox_lib

# With Yarn
yarn add @overextended/ox_lib
yarn add @communityox/ox_lib

# With npm
npm install @overextended/ox_lib
npm install @communityox/ox_lib
```

## Usage
You can either import the lib from client or server files or deconstruct the object and import only certain functions
you may require.

```ts
import lib from '@overextended/ox_lib/client'
import lib from '@communityox/ox_lib/client'
```

```ts
import lib from '@overextended/ox_lib/server'
import lib from '@communityox/ox_lib/server'
```

```ts
import { checkDependency } from '@overextended/ox_lib/shared';
import { checkDependency } from '@communityox/ox_lib/shared';
```

## Documentation
[View documentation](https://overextended.github.io/docs/ox_lib)
[View documentation](https://coxdocs.dev/ox_lib)
Loading