Skip to content

Commit 9733160

Browse files
committed
feat: add workflows
1 parent 457a2be commit 9733160

File tree

2 files changed

+172
-0
lines changed

2 files changed

+172
-0
lines changed

.github/workflows/code-quality.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Code checks
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- master
7+
paths:
8+
- src/**
9+
- bun.lock
10+
- package.json
11+
- .github/workflows/code-quality.yml
12+
pull_request:
13+
branches-ignore:
14+
- master
15+
paths:
16+
- src/**
17+
- bun.lock
18+
- package.json
19+
- .github/workflows/code-quality.yml
20+
21+
# Allows you to run this workflow manually from the Actions tab
22+
workflow_dispatch:
23+
24+
env:
25+
BUN_VERSION: 1.2.5
26+
27+
defaults:
28+
run:
29+
shell: bash
30+
working-directory: ./ # Ensure bun install runs in the correct working directory
31+
32+
jobs:
33+
setup:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
39+
- name: Setup bun
40+
uses: oven-sh/setup-bun@v2
41+
42+
with:
43+
bun-version: ${{ env.BUN_VERSION }}
44+
45+
# Install dependencies using Bun
46+
- name: Install dependencies
47+
run: bun install --frozen-lockfile
48+
49+
# Cache node_modules
50+
- name: Cache node_modules
51+
uses: actions/cache@v3
52+
with:
53+
path: node_modules
54+
key: ${{ hashFiles('**/bun.lock') }}
55+
56+
lint:
57+
runs-on: ubuntu-latest
58+
needs: setup
59+
steps:
60+
- uses: actions/checkout@v4
61+
62+
- name: Setup bun
63+
uses: oven-sh/setup-bun@v2
64+
with:
65+
bun-version: ${{ env.BUN_VERSION }}
66+
67+
- name: Restore cache
68+
uses: actions/cache@v3
69+
with:
70+
path: node_modules
71+
key: ${{ hashFiles('**/bun.lock') }}
72+
73+
- name: Lint
74+
run: bun run lint

.github/workflows/publish.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Publish package
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Code checks"]
6+
branches:
7+
- dev
8+
- master
9+
types:
10+
- completed
11+
12+
# Allows you to run this workflow manually from the Actions tab
13+
workflow_dispatch:
14+
15+
env:
16+
BUN_VERSION: 1.2.5
17+
18+
defaults:
19+
run:
20+
shell: bash
21+
working-directory: ./ # Ensure bun install runs in the correct working directory
22+
23+
jobs:
24+
on-failure:
25+
runs-on: ubuntu-latest
26+
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
27+
steps:
28+
- name: Failed workflow
29+
run: |
30+
echo "Code checks workflow failed"
31+
exit 1
32+
33+
setup:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
39+
- name: Setup bun
40+
uses: oven-sh/setup-bun@v2
41+
42+
with:
43+
bun-version: ${{ env.BUN_VERSION }}
44+
45+
# Install dependencies using Bun
46+
- name: Install dependencies
47+
run: bun install --frozen-lockfile
48+
49+
# Cache node_modules
50+
- name: Cache node_modules
51+
uses: actions/cache@v3
52+
with:
53+
path: node_modules
54+
key: ${{ hashFiles('**/bun.lock') }}
55+
56+
publish:
57+
runs-on: ubuntu-latest
58+
needs:
59+
- setup
60+
61+
permissions:
62+
contents: write # allow GITHUB_TOKEN to create release
63+
packages: write # allow GITHUB_TOKEN to publish packages
64+
id-token: write
65+
66+
steps:
67+
- uses: actions/checkout@v4
68+
69+
- name: Setup bun
70+
uses: oven-sh/setup-bun@v2
71+
with:
72+
bun-version: ${{ env.BUN_VERSION }}
73+
74+
- name: Restore cache
75+
uses: actions/cache@v3
76+
with:
77+
path: node_modules
78+
key: ${{ hashFiles('**/bun.lock') }}
79+
80+
- name: Set git user
81+
env:
82+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
83+
run: |
84+
git config --global user.name "GitHub Actions"
85+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
86+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
87+
88+
- name: Publish RC
89+
if: github.ref == 'refs/heads/dev'
90+
env:
91+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
run: bunx changelogen --publishTag rc --prerelease --nameSuffix rc --push
93+
94+
- name: Publish
95+
if: github.ref == 'refs/heads/master'
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98+
run: bunx changelogen --release --publish --push

0 commit comments

Comments
 (0)