ci(create-release): restructure and update versions

This commit is contained in:
ANTOND.
2025-05-02 16:21:55 +02:00
parent 9c9cb7e4e4
commit 17f38dfd31
3 changed files with 61 additions and 62 deletions

View File

@@ -1,10 +1,10 @@
const fs = require('fs') const fs = require('fs');
const version = process.env.TGT_RELEASE_VERSION const version = process.env.TGT_RELEASE_VERSION;
const newVersion = version.replace('v', '') 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
.github/actions/bump-package-version.js vendored Normal file
View File

@@ -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);

View File

@@ -1,4 +1,4 @@
name: Release name: Create release
on: on:
push: push:
@@ -7,68 +7,66 @@ on:
jobs: jobs:
create-release: create-release:
name: Build and Create Tagged Release
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Install archive tools - name: Get latest code
run: sudo apt install zip uses: actions/checkout@v4
- name: Checkout source code
uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0
ref: ${{ github.event.repository.default_branch }} ref: ${{ github.event.repository.default_branch }}
- uses: pnpm/action-setup@v2.0.1 - name: Setup Bun
uses: oven-sh/setup-bun@v2
with: with:
version: 8.6.1 bun-version: latest
- 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 - name: Install package dependencies
run: pnpm install run: bun install
working-directory: package 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 - name: Bump package version
run: pnpm version ${{ github.ref_name }} run: bun .github/actions/bump-package-version.js
working-directory: package
- 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: env:
TGT_RELEASE_VERSION: ${{ github.ref_name }} TGT_RELEASE_VERSION: ${{ github.ref_name }}
- name: Push manifest change - name: Bump manifest version
uses: EndBug/add-and-commit@v8 run: bun .github/actions/bump-manifest-version.js
with: env:
add: fxmanifest.lua TGT_RELEASE_VERSION: ${{ github.ref_name }}
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 - name: Push version bump change
uses: EndBug/add-and-commit@v9
with: with:
tag-name: ${{ github.ref_name }} add: '["fxmanifest.lua", "package/package.json"]'
push: true
default_author: github_actions
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: |
@@ -79,22 +77,13 @@ jobs:
cp -r ./web/build ./temp/ox_lib/web/ cp -r ./web/build ./temp/ox_lib/web/
cd ./temp && zip -r ../ox_lib.zip ./ox_lib cd ./temp && zip -r ../ox_lib.zip ./ox_lib
- 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 id: auto_release
with: with:
repo_token: '${{ secrets.GITHUB_TOKEN }}' repo_token: ${{ secrets.GITHUB_TOKEN }}
title: ${{ env.RELEASE_VERSION }}
prerelease: false prerelease: false
files: ox_lib.zip files: ox_lib.zip
env: env:
CI: false CI: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 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'