-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (127 loc) · 4.61 KB
/
Copy pathbuild.yaml
File metadata and controls
147 lines (127 loc) · 4.61 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Build, Test & Publish
on:
push:
branches:
- main
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches:
- main
jobs:
build-and-test:
runs-on: ubuntu-latest
permissions:
contents: read
actions: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
run: bun install
continue-on-error: true
id: install
- name: Comment on PR if installation failed
if: ${{ failure() && steps.install.outcome == 'failure' && github.event_name == 'pull_request' }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '❌ **Package installation failed**\nPlease check the dependency issues in your PR.'
})
- name: Lint code
run: bun run lint
continue-on-error: true
id: lint
- name: Comment on PR if linting failed
if: ${{ steps.lint.outcome == 'failure' && github.event_name == 'pull_request' }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '❌ **Linting failed**\nYour code has linting errors. Please fix them before merging.'
})
- name: Run tests
run: bun run test
continue-on-error: true
id: test
- name: Comment on PR if tests failed
if: ${{ steps.test.outcome == 'failure' && github.event_name == 'pull_request' }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '❌ **Tests failed**\nSome tests are failing in your PR. Please fix them before merging.'
})
- name: Build package
run: bun run build
continue-on-error: true
id: build
- name: Comment on PR if build failed
if: ${{ steps.build.outcome == 'failure' && github.event_name == 'pull_request' }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '❌ **Build failed**\nThe package failed to build. Please fix build errors before merging.'
})
- name: Check if any steps failed
id: check-failed-steps
if: ${{ steps.install.outcome == 'failure' || steps.lint.outcome == 'failure' || steps.test.outcome == 'failure' || steps.build.outcome == 'failure' }}
run: exit 1
- name: Comment on PR if all checks passed
if: ${{ success() && github.event_name == 'pull_request' }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '✅ **All checks passed**\nLinting, tests, and build have all completed successfully.'
})
publish-npm:
needs: build-and-test
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
name: Publish to NPM
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Build package
run: bun run build || echo "No build script, skipping"
- name: Publish to GitHub Packages
run: bun publish --access=public
env:
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}