Skip to content

Commit 7603022

Browse files
committed
chore: create github actions
1 parent 3e38461 commit 7603022

File tree

4 files changed

+382
-0
lines changed

4 files changed

+382
-0
lines changed

.github/changeset-version.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// ORIGINALLY FROM CLOUDFLARE WRANGLER:
2+
// https://github.com/cloudflare/wrangler2/blob/main/.github/changeset-version.js
3+
4+
const { exec } = require('child_process');
5+
// This script is used by the `release.yml` workflow to update the version of the packages being released.
6+
// The standard step is only to run `changeset version` but this does not update the pnpm-lock.yaml file.
7+
// So we also run `pnpm install`, which does this update.
8+
// This is a workaround until this is handled automatically by `changeset version`.
9+
// See https://github.com/changesets/changesets/issues/421.
10+
exec('bun run changeset version');
11+
exec('bun install --frozen-lockfile');

.github/workflows/ci.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: ci
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
lint-title:
7+
runs-on: ubuntu-latest
8+
name: 🚨 Lint Pull Request title
9+
steps:
10+
- uses: amannn/action-semantic-pull-request@v4
11+
env:
12+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+
14+
install-deps:
15+
runs-on: ubuntu-latest
16+
name: 📦 Install dependencies
17+
steps:
18+
- name: 🔑 Checkout Repository
19+
uses: actions/checkout@v3
20+
21+
- name: 🔧 Install Bun
22+
uses: oven-sh/setup-bun@v1
23+
with:
24+
version: latest
25+
26+
- name: ♻️ Cache node_modules
27+
uses: actions/cache@v3
28+
id: bun-cache
29+
with:
30+
path: "**/node_modules"
31+
key: ${{ runner.os }}-node-${{ hashFiles('**/bun.lockb') }}
32+
restore-keys: |
33+
${{ runner.os }}-node-
34+
35+
if: steps.bun-cache.outputs.cache-hit != 'true'
36+
- run: bun install --frozen-lockfile
37+
38+
lint-package:
39+
runs-on: ubuntu-latest
40+
name: 🚨 Check for errors
41+
needs: install-deps
42+
steps:
43+
- name: 🔑 Checkout Repository
44+
uses: actions/checkout@v3
45+
46+
- name: 🔧 Install Bun
47+
uses: oven-sh/setup-bun@v1
48+
with:
49+
version: latest
50+
51+
- name: ♻️ Restore node_modules
52+
uses: actions/cache@v3
53+
with:
54+
path: "**/node_modules"
55+
key: ${{ runner.os }}-node-${{ hashFiles('**/bun.lockb') }}
56+
57+
- name: ♻️ Restore ESLint Cache
58+
uses: actions/cache@v3
59+
id: eslint-cache
60+
with:
61+
path: .eslintcache
62+
key: ${{ matrix.os }}-eslint-${{ hashFiles('**/*.ts', 'package.json', 'tsconfig.json') }}
63+
64+
- name: 📦 Install dependencies
65+
if: steps.bun-cache.outputs.cache-hit != 'true'
66+
run: bun install --frozen-lockfile
67+
68+
- name: 🚨 Lint files
69+
run: bun run lint
70+
71+
tests:
72+
name: 🧪 Test package
73+
runs-on: ubuntu-latest
74+
needs: install-deps
75+
steps:
76+
- name: 🔑 Checkout Repository
77+
uses: actions/checkout@v3
78+
79+
- name: 🔧 Install Bun
80+
uses: oven-sh/setup-bun@v1
81+
with:
82+
version: latest
83+
84+
- name: ♻️ Restore node_modules
85+
uses: actions/cache@v3
86+
with:
87+
path: "**/node_modules"
88+
key: ${{ runner.os }}-node-${{ hashFiles('**/bun.lockb') }}
89+
90+
- name: 📦 Install dependencies
91+
if: steps.bun-cache.outputs.cache-hit != 'true'
92+
run: bun install --frozen-lockfile
93+
94+
- name: 🧪 Run tests
95+
run: pnpm run test:ci
96+
97+
build:
98+
name: 🏗️ Build package
99+
runs-on: ubuntu-latest
100+
needs: install-deps
101+
steps:
102+
- name: 🔑 Checkout Repository
103+
uses: actions/checkout@v3
104+
105+
- name: 🔧 Install Bun
106+
uses: oven-sh/setup-bun@v1
107+
with:
108+
version: latest
109+
110+
- name: ♻️ Load node_modules
111+
uses: actions/cache@v3
112+
with:
113+
path: "**/node_modules"
114+
key: ${{ runner.os }}-node-${{ hashFiles('**/bun.lockb') }}
115+
116+
- name: 📦 Install dependencies
117+
if: steps.bun-cache.outputs.cache-hit != 'true'
118+
run: bun install --frozen-lockfile
119+
120+
- name: 🏗️ Build package
121+
run: bun run build

.github/workflows/release.yml

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
name: release to package managers
2+
3+
concurrency: ${{ github.workflow }}-${{ github.ref }}
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
# workflow_dispatch:
10+
# inputs:
11+
# forceGPR:
12+
# description: Force GPR release
13+
# type: boolean
14+
# required: false
15+
# default: false
16+
17+
jobs:
18+
install-deps:
19+
name: 📦 Install dependencies
20+
if: github.repository == 'lukemorales/next-safe-navigation' && github.event_name != 'pull_request'
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: 🔑 Checkout Repository
24+
uses: actions/checkout@v3
25+
26+
- name: 🔧 Install Bun
27+
uses: oven-sh/setup-bun@v1
28+
with:
29+
version: latest
30+
31+
- name: ♻️ Cache node_modules
32+
uses: actions/cache@v3
33+
id: bun-cache
34+
with:
35+
path: "**/node_modules"
36+
key: ${{ runner.os }}-node-${{ hashFiles('**/bun.lockb') }}
37+
restore-keys: |
38+
${{ runner.os }}-node-
39+
40+
if: steps.bun-cache.outputs.cache-hit != 'true'
41+
- run: bun install --frozen-lockfile
42+
43+
build:
44+
name: 🏗️ Build package
45+
runs-on: ubuntu-latest
46+
needs: install-deps
47+
steps:
48+
- name: 🔑 Checkout Repository
49+
uses: actions/checkout@v3
50+
51+
- name: 🔧 Install Bun
52+
uses: oven-sh/setup-bun@v1
53+
with:
54+
version: latest
55+
56+
- name: 📦 Install dependencies
57+
if: steps.bun-cache.outputs.cache-hit != 'true'
58+
run: bun install --frozen-lockfile
59+
60+
- name: 🚨 Check for errors
61+
run: bun run lint
62+
63+
- name: 🧪 Run tests
64+
run: bun run test:ci
65+
66+
- name: ⚒️ Build package
67+
run: bun run build
68+
69+
release:
70+
name: 🚀 Release to NPM
71+
if: github.event.inputs.forceGPR != 'true'
72+
runs-on: ubuntu-latest
73+
needs: build
74+
outputs:
75+
published: ${{ steps.changesets.outputs.published }}
76+
steps:
77+
- name: 🔑 Checkout Repository
78+
uses: actions/checkout@v3
79+
with:
80+
fetch-depth: 0
81+
82+
- name: 🔧 Install Bun
83+
uses: oven-sh/setup-bun@v1
84+
with:
85+
version: latest
86+
87+
- name: ♻️ Load node_modules
88+
uses: actions/cache@v3
89+
with:
90+
path: "**/node_modules"
91+
key: ${{ runner.os }}-node-${{ hashFiles('**/bun.lockb') }}
92+
93+
- name: ♻️ Load build files
94+
uses: actions/cache@v3
95+
with:
96+
path: "**/dist"
97+
key: ${{ runner.os }}-build-${{ hashFiles('**/bun.lockb') }}
98+
99+
- name: 🛠️ Setup Node for NPM
100+
uses: actions/setup-node@v3
101+
with:
102+
node-version: latest
103+
check-latest: true
104+
cache: 'pnpm'
105+
registry-url: 'https://registry.npmjs.org'
106+
107+
- name: 👤 Set git user
108+
run: |
109+
git config --global user.email "lukemorales@live.com"
110+
git config --global user.name "Luke Morales"
111+
112+
- name: 🚀 Create Changesets Pull Request or Publish to NPM
113+
id: changesets
114+
uses: changesets/action@v1
115+
with:
116+
setupGitUser: false
117+
title: "chore(changesets): bump package version"
118+
commit: "chore: bump package version"
119+
version: node .github/changeset-version.js
120+
publish: bun run release
121+
env:
122+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
124+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
125+
126+
# gpr-release:
127+
# name: 🚀 Release to GitHub Package Manager
128+
# if: github.event.inputs.forceGPR == 'true' || needs.release.outputs.published == 'true'
129+
# runs-on: ubuntu-latest
130+
# needs: [build, release]
131+
# permissions:
132+
# contents: read
133+
# packages: write
134+
# steps:
135+
# - name: 🔑 Checkout Repository
136+
# uses: actions/checkout@v3
137+
138+
# - name: 🔧 Install PNPM
139+
# uses: pnpm/action-setup@v2.2.4
140+
# with:
141+
# version: 7
142+
143+
# - name: ♻️ Load node_modules
144+
# uses: actions/cache@v3
145+
# with:
146+
# path: "**/node_modules"
147+
# key: ${{ runner.os }}-node-${{ hashFiles('**/bun.lockb') }}
148+
149+
# - name: 🛠️ Setup Node for GPR
150+
# uses: actions/setup-node@v3
151+
# with:
152+
# node-version: '16.14.2'
153+
# check-latest: true
154+
# cache: 'pnpm'
155+
# registry-url: 'https://npm.pkg.github.com'
156+
157+
# - name: 📦 Install dependencies
158+
# if: steps.bun-cache.outputs.cache-hit != 'true'
159+
# run: bun install --frozen-lockfile
160+
161+
# - name: ⚒️ Build package
162+
# run: bun run build
163+
164+
# - name: 🚀 Publish to GPR
165+
# run: pnpm publish
166+
# env:
167+
# NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/tests.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
install-deps:
10+
runs-on: ubuntu-latest
11+
name: 📦 Install dependencies
12+
steps:
13+
- name: 🔑 Checkout Repository
14+
uses: actions/checkout@v3
15+
16+
- name: 🔧 Install Bun
17+
uses: oven-sh/setup-bun@v1
18+
with:
19+
version: latest
20+
21+
- name: ♻️ Cache node_modules
22+
uses: actions/cache@v3
23+
id: bun-cache
24+
with:
25+
path: "**/node_modules"
26+
key: ${{ runner.os }}-node-${{ hashFiles('**/bun.lockb') }}
27+
restore-keys: |
28+
${{ runner.os }}-node-
29+
30+
if: steps.bun-cache.outputs.cache-hit != 'true'
31+
- run: bun install --frozen-lockfile
32+
33+
tests:
34+
name: 🧪 Test package
35+
runs-on: ubuntu-latest
36+
needs: install-deps
37+
steps:
38+
- name: 🔑 Checkout Repository
39+
uses: actions/checkout@v3
40+
41+
- name: 🔧 Install Bun
42+
uses: oven-sh/setup-bun@v1
43+
with:
44+
version: latest
45+
46+
- name: ♻️ Load node_modules
47+
uses: actions/cache@v3
48+
with:
49+
path: "**/node_modules"
50+
key: ${{ runner.os }}-node-${{ hashFiles('**/bun.lockb') }}
51+
52+
- name: 📦 Install dependencies
53+
if: steps.bun-cache.outputs.cache-hit != 'true'
54+
run: bun install --frozen-lockfile
55+
56+
- name: 🧪 Run tests
57+
run: bun run test:ci
58+
59+
build:
60+
name: 🏗️ Build package
61+
runs-on: ubuntu-latest
62+
needs: install-deps
63+
steps:
64+
- name: 🔑 Checkout Repository
65+
uses: actions/checkout@v3
66+
67+
- name: 🔧 Install Bun
68+
uses: oven-sh/setup-bun@v1
69+
with:
70+
version: latest
71+
72+
- name: ♻️ Load node_modules
73+
uses: actions/cache@v3
74+
with:
75+
path: "**/node_modules"
76+
key: ${{ runner.os }}-node-${{ hashFiles('**/bun.lockb') }}
77+
78+
- name: 📦 Install dependencies
79+
if: steps.bun-cache.outputs.cache-hit != 'true'
80+
run: bun install --frozen-lockfile
81+
82+
- name: 🏗️ Build package
83+
run: bun run build

0 commit comments

Comments
 (0)