-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (87 loc) · 2.68 KB
/
ci.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
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
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Install bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install packages
run: bun i
- name: Check code coverage
run: bun run coverage
bump_version:
# DO NOT RUN ON PR
if: github.event_name != 'pull_request'
needs: coverage
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
current_tag: ${{ steps.current_tag.outputs.current_tag }}
previous_tag: ${{ steps.previous_tag.outputs.previous_tag }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set git email
run: git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Set git name
run: git config --global user.name "github-actions[bot]"
- name: Install bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install packages
run: bun i
- name: Build library and CLI
run: bun run build
- name: Get previous tag
id: previous_tag
run: |
echo "previous_tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT
- name: Bump package version
run: npx standard-version
- name: Get current tag
id: current_tag
run: |
echo "current_tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT
- name: Push changes
run: git push --follow-tags origin main
release:
# DO NOT RUN ON PR
if: github.event_name != 'pull_request'
needs: bump_version
runs-on: ubuntu-latest
steps:
- name: Generate CHANGELOG for Github release
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ github.token }}
fromTag: ${{ needs.bump_version.outputs.current_tag }}
toTag: ${{ needs.bump_version.outputs.previous_tag }}
writeToFile: false
- name: Create Github release
uses: ncipollo/[email protected]
with:
allowUpdates: true
draft: false
makeLatest: true
tag: ${{ needs.bump_version.outputs.current_tag }}
name: ${{ needs.bump_version.outputs.current_tag }}
body: ${{ steps.changelog.outputs.changes }}
token: ${{ github.token }}
artifacts: '*.tgz'
- name: Publish to NPM
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}