-
Notifications
You must be signed in to change notification settings - Fork 1
72 lines (58 loc) · 2.1 KB
/
node.js.yml
File metadata and controls
72 lines (58 loc) · 2.1 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
name: Node.js CI/CD
on:
push:
branches:
- main
pull_request:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
new_version: ${{ steps.bump_version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Enable Corepack
run: corepack enable
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Install dependencies (Yarn Berry)
run: yarn install --immutable
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Run tests (if test script exists)
run: yarn workspaces foreach --all --topological --parallel --no-private run test
continue-on-error: true
- name: Build project (if build script exists)
run: yarn workspaces foreach --all --topological --parallel --no-private run build
- name: Bump version & commit (only on main)
id: bump_version
if: github.ref == 'refs/heads/main'
run: |
yarn workspaces foreach --all version patch
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "chore(release): bump versions"
NEW_VERSION=$(jq -r .version package.json)
git tag v$NEW_VERSION
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git push --follow-tags
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Publish to npm using yarn workspaces
if: github.ref == 'refs/heads/main'
run: yarn workspaces foreach --verbose --all --topological --no-private npm publish --access public
call-publish:
needs: [build]
uses: ./.github/workflows/release.yml
permissions:
contents: write
with:
version: ${{ needs.build.outputs.new_version }}