Skip to content

Commit 4b44963

Browse files
authored
Merge pull request #1 from jsdotlua/setup-npm-package
Setup npm package 🚀
2 parents 2b7e6fd + a316f09 commit 4b44963

25 files changed

Lines changed: 848 additions & 17 deletions

.darklua-bundle-dev.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"bundle": {
3+
"require_mode": {
4+
"name": "path",
5+
"sources": {
6+
"@pkg": "node_modules/.luau-aliases"
7+
}
8+
}
9+
},
10+
"generator": "dense",
11+
"process": [
12+
{
13+
"rule": "inject_global_value",
14+
"identifier": "__DEV__",
15+
"value": true
16+
},
17+
"remove_types",
18+
"remove_comments",
19+
"remove_spaces",
20+
"compute_expression",
21+
"remove_unused_if_branch",
22+
"remove_unused_while",
23+
"filter_after_early_return",
24+
"remove_nil_declaration",
25+
"remove_empty_do"
26+
]
27+
}

.darklua-bundle.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"bundle": {
3+
"require_mode": {
4+
"name": "path",
5+
"sources": {
6+
"@pkg": "node_modules/.luau-aliases"
7+
}
8+
}
9+
},
10+
"generator": "dense",
11+
"process": [
12+
{
13+
"rule": "inject_global_value",
14+
"identifier": "__DEV__",
15+
"value": false
16+
},
17+
"remove_types",
18+
"remove_comments",
19+
"remove_spaces",
20+
"compute_expression",
21+
"remove_unused_if_branch",
22+
"remove_unused_while",
23+
"filter_after_early_return",
24+
"remove_nil_declaration",
25+
"remove_empty_do"
26+
]
27+
}

.darklua-dev.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"process": [
3+
{
4+
"rule": "convert_require",
5+
"current": {
6+
"name": "path",
7+
"sources": {
8+
"@pkg": "node_modules/.luau-aliases"
9+
}
10+
},
11+
"target": {
12+
"name": "roblox",
13+
"indexing_style": "wait_for_child",
14+
"rojo_sourcemap": "sourcemap.json"
15+
}
16+
},
17+
{
18+
"rule": "inject_global_value",
19+
"identifier": "__DEV__",
20+
"value": true
21+
},
22+
"compute_expression",
23+
"remove_unused_if_branch",
24+
"remove_unused_while",
25+
"filter_after_early_return",
26+
"remove_nil_declaration",
27+
"remove_empty_do"
28+
]
29+
}

.darklua-wally.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"process": [
3+
{
4+
"rule": "convert_require",
5+
"current": {
6+
"name": "path",
7+
"sources": {
8+
"@pkg": "."
9+
}
10+
},
11+
"target": {
12+
"name": "roblox",
13+
"indexing_style": "wait_for_child",
14+
"rojo_sourcemap": "./sourcemap.json"
15+
}
16+
},
17+
"compute_expression",
18+
"remove_unused_if_branch",
19+
"remove_unused_while",
20+
"filter_after_early_return",
21+
"remove_nil_declaration",
22+
"remove_empty_do"
23+
]
24+
}

.darklua.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"process": [
3+
{
4+
"rule": "convert_require",
5+
"current": {
6+
"name": "path",
7+
"sources": {
8+
"@pkg": "node_modules/.luau-aliases"
9+
}
10+
},
11+
"target": {
12+
"name": "roblox",
13+
"indexing_style": "wait_for_child",
14+
"rojo_sourcemap": "sourcemap.json"
15+
}
16+
},
17+
{
18+
"rule": "inject_global_value",
19+
"identifier": "__DEV__",
20+
"value": false
21+
},
22+
"compute_expression",
23+
"remove_unused_if_branch",
24+
"remove_unused_while",
25+
"filter_after_early_return",
26+
"remove_nil_declaration",
27+
"remove_empty_do"
28+
]
29+
}

.github/workflows/release.yml

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_tag:
7+
description: "The version to release starting with `v`"
8+
required: true
9+
type: string
10+
11+
release_ref:
12+
description: "The branch, tag or SHA to checkout (default to latest)"
13+
default: ""
14+
type: string
15+
16+
permissions:
17+
contents: write
18+
19+
jobs:
20+
publish-package:
21+
name: Publish package
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- uses: actions/setup-node@v3
28+
with:
29+
node-version: "latest"
30+
cache: "yarn"
31+
cache-dependency-path: "yarn.lock"
32+
33+
- name: Update yarn
34+
run: yarn set version stable
35+
36+
- name: Install packages
37+
run: yarn install --immutable
38+
39+
- name: Run npmluau
40+
run: yarn run prepare
41+
42+
- name: Authenticate yarn
43+
run: |
44+
yarn config set npmAlwaysAuth true
45+
yarn config set npmScopes.jsdotlua.npmAuthToken $NPM_AUTH_TOKEN
46+
env:
47+
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
48+
49+
- run: yarn npm publish --access public
50+
51+
publish-wally-package:
52+
needs: publish-package
53+
54+
name: Publish wally package
55+
runs-on: ubuntu-latest
56+
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- uses: Roblox/setup-foreman@v1
61+
with:
62+
token: ${{ secrets.GITHUB_TOKEN }}
63+
64+
- uses: actions/setup-node@v3
65+
with:
66+
node-version: "latest"
67+
cache: "yarn"
68+
cache-dependency-path: "yarn.lock"
69+
70+
- name: Update yarn
71+
run: yarn set version stable
72+
73+
- name: Install packages
74+
run: yarn install --immutable
75+
76+
- name: Run npmluau
77+
run: yarn run prepare
78+
79+
- name: Build assets
80+
run: yarn run build-assets
81+
82+
- name: Login to wally
83+
run: wally login --project-path build/wally --token ${{ secrets.WALLY_ACCESS_TOKEN }}
84+
85+
- name: Publish to wally
86+
run: wally publish --project-path build/wally
87+
88+
create-release:
89+
needs: publish-package
90+
91+
name: Create release
92+
runs-on: ubuntu-latest
93+
94+
outputs:
95+
upload_url: ${{ steps.create_release.outputs.upload_url }}
96+
97+
steps:
98+
- uses: actions/checkout@v4
99+
100+
- name: Create tag
101+
run: |
102+
git fetch --tags --no-recurse-submodules
103+
if [ ! $(git tag -l ${{ inputs.release_tag }}) ]; then
104+
git tag ${{ inputs.release_tag }}
105+
git push origin ${{ inputs.release_tag }}
106+
fi
107+
108+
- name: Create release
109+
id: create_release
110+
uses: softprops/action-gh-release@v1
111+
env:
112+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113+
with:
114+
tag_name: ${{ inputs.release_tag }}
115+
name: ${{ inputs.release_tag }}
116+
draft: false
117+
118+
build-assets:
119+
needs: create-release
120+
121+
name: Add assets
122+
runs-on: ubuntu-latest
123+
124+
strategy:
125+
fail-fast: false
126+
matrix:
127+
include:
128+
- artifact-name: zen-observable.rbxm
129+
path: build/zen-observable.rbxm
130+
asset-type: application/octet-stream
131+
132+
- artifact-name: zen-observable-dev.rbxm
133+
path: build/debug/zen-observable.rbxm
134+
asset-type: application/octet-stream
135+
136+
- artifact-name: zen-observable.lua
137+
path: build/zen-observable.lua
138+
asset-type: text/plain
139+
140+
- artifact-name: zen-observable-dev.lua
141+
path: build/debug/zen-observable.lua
142+
asset-type: text/plain
143+
144+
steps:
145+
- uses: actions/checkout@v4
146+
147+
- uses: Roblox/setup-foreman@v1
148+
with:
149+
token: ${{ secrets.GITHUB_TOKEN }}
150+
151+
- uses: actions/setup-node@v3
152+
with:
153+
node-version: "latest"
154+
cache: "yarn"
155+
cache-dependency-path: "yarn.lock"
156+
157+
- name: Update yarn
158+
run: yarn set version stable
159+
160+
- name: Install packages
161+
run: yarn install --immutable
162+
163+
- name: Run npmluau
164+
run: yarn run prepare
165+
166+
- name: Build assets
167+
run: yarn run build-assets
168+
169+
- name: Upload asset
170+
uses: actions/upload-artifact@v3
171+
with:
172+
name: ${{ matrix.artifact-name }}
173+
path: ${{ matrix.path }}
174+
175+
- name: Add asset to Release
176+
uses: actions/upload-release-asset@v1
177+
env:
178+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
179+
with:
180+
upload_url: ${{ needs.create-release.outputs.upload_url }}
181+
asset_path: ${{ matrix.path }}
182+
asset_name: ${{ matrix.artifact-name }}
183+
asset_content_type: ${{ matrix.asset-type }}

.github/workflows/test.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
test:
13+
name: Run tests
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: Roblox/setup-foreman@v1
20+
with:
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- uses: actions/setup-node@v3
24+
with:
25+
node-version: "latest"
26+
cache: "yarn"
27+
cache-dependency-path: "yarn.lock"
28+
29+
- name: Update yarn
30+
run: yarn set version stable
31+
32+
- name: Install packages
33+
run: yarn install --immutable
34+
35+
- name: Run npmluau
36+
run: yarn run prepare
37+
38+
- name: Run linter
39+
run: yarn run lint
40+
41+
- name: Verify code style
42+
run: yarn run style-check
43+
44+
- name: Build assets
45+
run: yarn run build-assets

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@ sourcemap.json
44
rotriever.lock
55
*.rbxmx
66
*.rbxm
7+
8+
**/sourcemap.json
9+
**/node_modules
10+
/build
11+
/roblox
12+
.yarn

0 commit comments

Comments
 (0)