Skip to content

Commit 17f38df

Browse files
committed
ci(create-release): restructure and update versions
1 parent 9c9cb7e commit 17f38df

File tree

3 files changed

+55
-56
lines changed

3 files changed

+55
-56
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const fs = require('fs')
1+
const fs = require('fs');
22

3-
const version = process.env.TGT_RELEASE_VERSION
4-
const newVersion = version.replace('v', '')
3+
const version = process.env.TGT_RELEASE_VERSION;
4+
const newVersion = version.replace('v', '');
55

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

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

10-
fs.writeFileSync('fxmanifest.lua', newFileContent)
10+
fs.writeFileSync('fxmanifest.lua', newFileContent);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const fs = require('fs');
2+
3+
const version = process.env.TGT_RELEASE_VERSION;
4+
const newVersion = version.replace('v', '');
5+
6+
const packageFile = fs.readFileSync('package/package.json', { encoding: 'utf8' });
7+
8+
const newFileContent = packageFile.replace(/"version":\s+"(.*)",$/gm, `"version": "${newVersion}",`);
9+
10+
fs.writeFileSync('package/package.json', newFileContent);

.github/workflows/release.yml

Lines changed: 39 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release
1+
name: Create release
22

33
on:
44
push:
@@ -7,68 +7,66 @@ on:
77

88
jobs:
99
create-release:
10-
name: Build and Create Tagged Release
1110
runs-on: ubuntu-latest
1211
steps:
13-
- name: Install archive tools
14-
run: sudo apt install zip
15-
16-
- name: Checkout source code
17-
uses: actions/checkout@v2
12+
- name: Get latest code
13+
uses: actions/checkout@v4
1814
with:
1915
fetch-depth: 0
2016
ref: ${{ github.event.repository.default_branch }}
2117

22-
- uses: pnpm/action-setup@v2.0.1
23-
with:
24-
version: 8.6.1
25-
26-
- name: Setup node
27-
uses: actions/setup-node@v2
18+
- name: Setup Bun
19+
uses: oven-sh/setup-bun@v2
2820
with:
29-
node-version: 16.x
30-
cache: 'pnpm'
31-
cache-dependency-path: 'web/pnpm-lock.yaml'
32-
33-
- name: Set env
34-
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
21+
bun-version: latest
3522

36-
- name: Install dependencies
37-
run: pnpm install
38-
working-directory: web
3923

4024
- name: Install package dependencies
41-
run: pnpm install
25+
run: bun install
4226
working-directory: package
4327

44-
- name: Bump package version
45-
run: pnpm version ${{ github.ref_name }}
46-
working-directory: package
28+
- name: Install web dependencies
29+
run: bun install
30+
working-directory: web
4731

48-
- name: Run build
49-
run: pnpm build
32+
- name: Run web build script
33+
run: bun run build
5034
working-directory: web
35+
36+
37+
- name: Bump package version
38+
run: bun .github/actions/bump-package-version.js
5139
env:
52-
CI: false
40+
TGT_RELEASE_VERSION: ${{ github.ref_name }}
5341

5442
- name: Bump manifest version
55-
run: node .github/actions/bump-manifest-version.js
43+
run: bun .github/actions/bump-manifest-version.js
5644
env:
5745
TGT_RELEASE_VERSION: ${{ github.ref_name }}
5846

59-
- name: Push manifest change
60-
uses: EndBug/add-and-commit@v8
47+
48+
- name: Push version bump change
49+
uses: EndBug/add-and-commit@v9
6150
with:
62-
add: fxmanifest.lua
51+
add: '["fxmanifest.lua", "package/package.json"]'
6352
push: true
64-
author_name: Manifest Bumper
65-
author_email: 41898282+github-actions[bot]@users.noreply.github.com
66-
message: 'chore: bump manifest version to ${{ github.ref_name }}'
53+
default_author: github_actions
54+
message: 'chore: bump version to ${{ github.ref_name }}'
6755

68-
- name: Update tag ref
69-
uses: EndBug/latest-tag@latest
56+
- name: Update tag
57+
uses: EndBug/latest-tag@v1
7058
with:
71-
tag-name: ${{ github.ref_name }}
59+
ref: ${{ github.ref_name }}
60+
61+
62+
- name: Publish package to npm registry
63+
run: bun publish --access public
64+
working-directory: package
65+
env:
66+
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
67+
68+
- name: Install zip
69+
run: sudo apt install zip
7270

7371
- name: Bundle files
7472
run: |
@@ -79,22 +77,13 @@ jobs:
7977
cp -r ./web/build ./temp/ox_lib/web/
8078
cd ./temp && zip -r ../ox_lib.zip ./ox_lib
8179
82-
- name: Create Release
80+
- name: Create release
8381
uses: 'marvinpinto/action-automatic-releases@v1.2.1'
8482
id: auto_release
8583
with:
86-
repo_token: '${{ secrets.GITHUB_TOKEN }}'
87-
title: ${{ env.RELEASE_VERSION }}
84+
repo_token: ${{ secrets.GITHUB_TOKEN }}
8885
prerelease: false
8986
files: ox_lib.zip
90-
9187
env:
9288
CI: false
9389
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94-
95-
- name: Publish npm package
96-
uses: JS-DevTools/npm-publish@v1
97-
with:
98-
token: ${{ secrets.NPM_TOKEN }}
99-
package: './package/package.json'
100-
access: 'public'

0 commit comments

Comments
 (0)