mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-16 22:46:03 +01:00
ci(create-release): use github app token
This commit is contained in:
12
.github/actions/bump-manifest-version.js
vendored
12
.github/actions/bump-manifest-version.js
vendored
@@ -1,10 +1,8 @@
|
|||||||
const fs = require('fs');
|
const fxManifest = await Bun.file('./fxmanifest.lua').text();
|
||||||
|
|
||||||
const version = process.env.TGT_RELEASE_VERSION;
|
let newVersion = process.env.TGT_RELEASE_VERSION;
|
||||||
const newVersion = version.replace('v', '');
|
newVersion = newVersion.replace('v', '')
|
||||||
|
|
||||||
const manifestFile = fs.readFileSync('fxmanifest.lua', { encoding: 'utf8' });
|
const newFileContent = fxManifest.replace(/\bversion\s+(.*)$/gm, `version '${newVersion}'`);
|
||||||
|
|
||||||
const newFileContent = manifestFile.replace(/\bversion\s+(.*)$/gm, `version '${newVersion}'`);
|
await Bun.write('./fxmanifest.lua', newFileContent);
|
||||||
|
|
||||||
fs.writeFileSync('fxmanifest.lua', newFileContent);
|
|
||||||
|
|||||||
12
.github/actions/bump-package-version.js
vendored
12
.github/actions/bump-package-version.js
vendored
@@ -1,10 +1,6 @@
|
|||||||
const fs = require('fs');
|
const packageJson = await Bun.file('./package/package.json').json();
|
||||||
|
|
||||||
const version = process.env.TGT_RELEASE_VERSION;
|
const newVersion = process.env.TGT_RELEASE_VERSION;
|
||||||
const newVersion = version.replace('v', '');
|
packageJson.version = newVersion.replace('v', '');
|
||||||
|
|
||||||
const packageFile = fs.readFileSync('package/package.json', { encoding: 'utf8' });
|
await Bun.write('./package/package.json', JSON.stringify(packageJson, null, 2));
|
||||||
|
|
||||||
const newFileContent = packageFile.replace(/"version":\s+"(.*)",$/gm, `"version": "${newVersion}",`);
|
|
||||||
|
|
||||||
fs.writeFileSync('package/package.json', newFileContent);
|
|
||||||
|
|||||||
64
.github/workflows/release.yml
vendored
64
.github/workflows/release.yml
vendored
@@ -7,26 +7,39 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
create-release:
|
create-release:
|
||||||
|
if: github.actor_id != 210085057
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Get latest code
|
- name: Install zip
|
||||||
uses: actions/checkout@v4
|
run: sudo apt install zip
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
ref: ${{ github.event.repository.default_branch }}
|
|
||||||
|
|
||||||
- name: Setup Bun
|
- name: Install Bun
|
||||||
uses: oven-sh/setup-bun@v2
|
uses: oven-sh/setup-bun@v2
|
||||||
with:
|
with:
|
||||||
bun-version: latest
|
bun-version: latest
|
||||||
|
|
||||||
|
|
||||||
|
- name: Generate GitHub App token
|
||||||
|
id: app_token
|
||||||
|
uses: tibdex/github-app-token@v2
|
||||||
|
with:
|
||||||
|
app_id: ${{ secrets.APP_ID }}
|
||||||
|
private_key: ${{ secrets.APP_PRIVATE_KEY }}
|
||||||
|
|
||||||
|
- name: Get latest code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
ref: ${{ github.event.repository.default_branch }}
|
||||||
|
token: ${{ steps.app_token.outputs.token }}
|
||||||
|
|
||||||
|
|
||||||
- name: Install package dependencies
|
- name: Install package dependencies
|
||||||
run: bun install
|
run: bun install --frozen-lockfile
|
||||||
working-directory: package
|
working-directory: package
|
||||||
|
|
||||||
- name: Install web dependencies
|
- name: Install web dependencies
|
||||||
run: bun install
|
run: bun install --frozen-lockfile
|
||||||
working-directory: web
|
working-directory: web
|
||||||
|
|
||||||
- name: Run web build script
|
- name: Run web build script
|
||||||
@@ -35,16 +48,15 @@ jobs:
|
|||||||
|
|
||||||
|
|
||||||
- name: Bump package version
|
- name: Bump package version
|
||||||
run: bun .github/actions/bump-package-version.js
|
run: bun run .github/actions/bump-package-version.js
|
||||||
env:
|
env:
|
||||||
TGT_RELEASE_VERSION: ${{ github.ref_name }}
|
TGT_RELEASE_VERSION: ${{ github.ref_name }}
|
||||||
|
|
||||||
- name: Bump manifest version
|
- name: Bump manifest version
|
||||||
run: bun .github/actions/bump-manifest-version.js
|
run: bun run .github/actions/bump-manifest-version.js
|
||||||
env:
|
env:
|
||||||
TGT_RELEASE_VERSION: ${{ github.ref_name }}
|
TGT_RELEASE_VERSION: ${{ github.ref_name }}
|
||||||
|
|
||||||
|
|
||||||
- name: Push version bump change
|
- name: Push version bump change
|
||||||
uses: EndBug/add-and-commit@v9
|
uses: EndBug/add-and-commit@v9
|
||||||
with:
|
with:
|
||||||
@@ -53,25 +65,10 @@ jobs:
|
|||||||
default_author: github_actions
|
default_author: github_actions
|
||||||
message: 'chore: bump version to ${{ github.ref_name }}'
|
message: 'chore: bump version to ${{ github.ref_name }}'
|
||||||
|
|
||||||
- name: Update tag
|
|
||||||
uses: EndBug/latest-tag@v1
|
|
||||||
with:
|
|
||||||
ref: ${{ github.ref_name }}
|
|
||||||
|
|
||||||
|
|
||||||
- name: Publish package to npm registry
|
|
||||||
run: bun publish --access public
|
|
||||||
working-directory: package
|
|
||||||
env:
|
|
||||||
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
||||||
|
|
||||||
- name: Install zip
|
|
||||||
run: sudo apt install zip
|
|
||||||
|
|
||||||
- name: Bundle files
|
- name: Bundle files
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ./temp/ox_lib
|
mkdir -p ./temp/ox_lib/web
|
||||||
mkdir -p ./temp/ox_lib/web/
|
|
||||||
cp ./{LICENSE,README.md,fxmanifest.lua,init.lua} ./temp/ox_lib
|
cp ./{LICENSE,README.md,fxmanifest.lua,init.lua} ./temp/ox_lib
|
||||||
cp -r ./{imports,resource,locales} ./temp/ox_lib
|
cp -r ./{imports,resource,locales} ./temp/ox_lib
|
||||||
cp -r ./web/build ./temp/ox_lib/web/
|
cp -r ./web/build ./temp/ox_lib/web/
|
||||||
@@ -79,11 +76,18 @@ jobs:
|
|||||||
|
|
||||||
- name: Create release
|
- name: Create release
|
||||||
uses: 'marvinpinto/action-automatic-releases@v1.2.1'
|
uses: 'marvinpinto/action-automatic-releases@v1.2.1'
|
||||||
id: auto_release
|
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
prerelease: false
|
prerelease: false
|
||||||
files: ox_lib.zip
|
files: ox_lib.zip
|
||||||
|
|
||||||
|
- name: Update tag
|
||||||
|
uses: EndBug/latest-tag@v1
|
||||||
|
with:
|
||||||
|
ref: ${{ github.ref_name }}
|
||||||
|
|
||||||
|
- name: Publish package to npm registry
|
||||||
|
run: bun publish --access public
|
||||||
|
working-directory: package
|
||||||
env:
|
env:
|
||||||
CI: false
|
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user