-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (65 loc) · 2.06 KB
/
main.yml
File metadata and controls
82 lines (65 loc) · 2.06 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
name: Build and Publish
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
outputs:
should_publish: ${{ steps.version_check.outputs.should_publish }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
- name: Enable Corepack
run: corepack enable
- name: Install dependencies
run: yarn install --immutable
- name: Typecheck
run: yarn typecheck
- name: Lint
run: yarn lint
- name: Build
run: yarn prepare
- name: Check version
id: version_check
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
LOCAL_VERSION=$(node -p "require('./package.json').version")
NPM_VERSION=$(npm view "$PACKAGE_NAME" version 2>/dev/null || echo "0.0.0")
echo "Local version: $LOCAL_VERSION"
echo "npm version: $NPM_VERSION"
if [ "$LOCAL_VERSION" != "$NPM_VERSION" ]; then
echo "Version changed, will publish"
echo "should_publish=true" >> $GITHUB_OUTPUT
else
echo "Version unchanged, skipping publish"
echo "should_publish=false" >> $GITHUB_OUTPUT
fi
publish:
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.build.outputs.should_publish == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
- name: Enable Corepack
run: corepack enable
- name: Install dependencies
run: yarn install --immutable
- name: Build
run: yarn prepare
- name: Publish to npm
run: npm publish --access public --provenance