Skip to content

Commit ca0364c

Browse files
authored
Merge pull request #2 from jsdotlua/setup-npm-package
Add github workflows
2 parents 7a22f5b + a436352 commit ca0364c

File tree

2 files changed

+228
-0
lines changed

2 files changed

+228
-0
lines changed

.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: graphql.rbxm
129+
path: build/graphql.rbxm
130+
asset-type: application/octet-stream
131+
132+
- artifact-name: graphql-dev.rbxm
133+
path: build/debug/graphql.rbxm
134+
asset-type: application/octet-stream
135+
136+
- artifact-name: graphql.lua
137+
path: build/graphql.lua
138+
asset-type: text/plain
139+
140+
- artifact-name: graphql-dev.lua
141+
path: build/debug/graphql.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

0 commit comments

Comments
 (0)