-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (87 loc) · 3.03 KB
/
publish.yml
File metadata and controls
101 lines (87 loc) · 3.03 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
name: Publish @agent-native/core
on:
release:
types: [published]
push:
branches:
- main
paths:
- "packages/core/**"
workflow_dispatch:
inputs:
version_bump:
description: "Version bump type"
required: true
default: "patch"
type: choice
options:
- patch
- minor
- major
- dev
jobs:
publish:
name: Build and publish
runs-on: ubuntu-latest
environment: npm-publish
permissions:
contents: write
id-token: write
steps:
- name: Generate app token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.BUILDER_BOT_FOR_LINT_APP_ID }}
private-key: ${{ secrets.BUILDER_BOT_FOR_LINT_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "pnpm"
- name: Install latest npm
run: npm install -g npm@latest
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build core package
run: pnpm --filter @agent-native/core build
- name: Run tests
run: pnpm --filter @agent-native/core test
- name: Bump version (manual dispatch only)
if: github.event_name == 'workflow_dispatch' && github.event.inputs.version_bump != 'dev'
working-directory: packages/core
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
npm version ${{ github.event.inputs.version_bump }} --no-git-tag-version
VERSION=$(node -p "require('./package.json').version")
git add package.json
git commit -m "chore: bump @agent-native/core to v${VERSION}"
git tag "v${VERSION}"
git push origin HEAD:main --tags
- name: Set dev version (manual dispatch only)
if: github.event_name == 'workflow_dispatch' && github.event.inputs.version_bump == 'dev'
working-directory: packages/core
run: |
CURRENT=$(node -p "require('./package.json').version")
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
DEV_VERSION="${CURRENT}-dev.${SHORT_SHA}"
npm version "$DEV_VERSION" --no-git-tag-version
echo "DEV_VERSION=$DEV_VERSION" >> $GITHUB_ENV
- name: Publish to npm
if: github.event.inputs.version_bump != 'dev'
working-directory: packages/core
run: npm publish --access public --provenance
- name: Publish dev version to npm
if: github.event_name == 'workflow_dispatch' && github.event.inputs.version_bump == 'dev'
working-directory: packages/core
run: npm publish --access public --provenance --tag dev