-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (58 loc) · 1.74 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Build
on:
push:
branches:
- main
pull_request:
branches:
- main
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
# Environment setup
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- name: Install pnpm
run: npm i -g pnpm
- name: Replace version in package.json to be semver compatible
if: github.event_name == 'release'
run: sed -i "s/IN-DEV/$(echo $GITHUB_REF | sed 's/refs\/tags\///')/" package.json
# Install dependencies
- name: Install dependencies with pnpm
run: pnpm install
# Build and generate code
- name: Build
run: pnpm build
# Upload artifacts to GitHub and NPM
- name: Upload build to artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v4
with:
name: build
path: dist
- name: Get repository slug
if: github.event_name == 'release'
id: repo_slug
run: echo "REPO_SLUG=$(basename $GITHUB_REPOSITORY)" >> $GITHUB_OUTPUT
- name: Upload build to release
if: github.event_name == 'release'
uses: svenstaro/upload-release-action@v2
with:
overwrite: true
file: dist/index.cjs
repo_token: ${{ secrets.GITHUB_TOKEN }}
asset_name: server.cjs
tag: ${{ github.ref }}
- name: Publish package on NPM
if: github.event_name == 'release'
run: pnpm publish . --access public --no-git-checks
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_SECRET}}