Skip to content

Commit bc1de3d

Browse files
committed
added 2 new workflows, testing and publishing to npm
1 parent 461a756 commit bc1de3d

4 files changed

Lines changed: 117 additions & 0 deletions

File tree

.github/workflows/npm-publish.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: NPM Publish
2+
run-name: ${{ inputs.description }} (${{ inputs.release_type }}) release by @${{ github.actor }}
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
description:
8+
description: 'Description for the release'
9+
required: false
10+
type: string
11+
release_type:
12+
description: 'Release Type'
13+
required: true
14+
default: 'patch'
15+
type: choice
16+
options:
17+
- 'patch'
18+
- 'minor'
19+
- 'major'
20+
21+
jobs:
22+
test:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v3
27+
28+
- name: Set up Node.js
29+
uses: actions/setup-node@v3
30+
with:
31+
node-version: '20'
32+
cache: 'npm'
33+
34+
- name: Install dependencies
35+
run: npm install
36+
37+
- name: Run linting
38+
run: npm run lint
39+
40+
- name: Run typechecking
41+
run: npm run typecheck
42+
43+
publish-to-npm:
44+
needs: test
45+
runs-on: ubuntu-latest
46+
steps:
47+
- name: Checkout code
48+
uses: actions/checkout@v3
49+
50+
- name: Set up Node.js
51+
uses: actions/setup-node@v3
52+
with:
53+
node-version: '20'
54+
cache: 'npm'
55+
registry-url: https://registry.npmjs.org/
56+
57+
- name: Set Git config
58+
run: |
59+
git config user.name "$(git log -n 1 --pretty=format:%an)"
60+
git config user.email "$(git log -n 1 --pretty=format:%ae)"
61+
62+
- name: Update version
63+
id: update_version
64+
run: echo "VERSION=$(npm version ${{ github.event.inputs.release_type }} -m \"%s ${{ github.event.inputs.description }}\")" >> $GITHUB_ENV
65+
66+
- name: Install dependencies
67+
run: npm install
68+
69+
- name: Publish to NPM
70+
run: npm publish
71+
env:
72+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
73+
74+
- name: Push tags
75+
run: git push --follow-tags
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
79+
- name: Create GitHub Release
80+
uses: softprops/action-gh-release@v1
81+
with:
82+
name: ${{ env.VERSION }} ${{ github.event.inputs.description }}
83+
tag_name: ${{ env.VERSION }}
84+
generate_release_notes: true

.github/workflows/test.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: '20'
21+
cache: 'npm'
22+
23+
- name: Install dependencies
24+
run: npm install
25+
26+
- name: Run lint
27+
run: npm run lint
28+
29+
- name: Run typecheck
30+
run: npm run typecheck

.husky/pre-push

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm run-prepush

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"clean": "expo-module clean",
1010
"lint": "expo-module lint",
1111
"test": "expo-module test",
12+
"pre-push": "npm run typecheck && npm run lint",
13+
"typecheck": "tsc --noEmit",
1214
"prepare": "expo-module prepare",
1315
"prepublishOnly": "expo-module prepublishOnly",
1416
"expo-module": "expo-module",

0 commit comments

Comments
 (0)