-
Notifications
You must be signed in to change notification settings - Fork 6
74 lines (64 loc) · 2.1 KB
/
Copy pathrelease.yml
File metadata and controls
74 lines (64 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
72
73
74
name: Release
on:
push:
tags:
- 'v*'
pull_request:
# Manual trigger for dev: lint, test, and package only; no GitHub Release or npm publish
workflow_dispatch:
inputs:
ref:
description: 'Branch, tag, or PR ref (e.g. refs/pull/123/merge). Leave empty to run on default branch.'
required: false
type: string
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref || github.ref }}
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Test
run: npm run test
- name: Create release package
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
PKG_VER="${GITHUB_REF#refs/tags/}"
else
PKG_VER="dev-$(date +%Y%m%d)-${GITHUB_SHA::7}"
fi
mkdir -p release
git archive --format=zip --prefix=openclaw-extension-powermem/ HEAD -o release/openclaw-extension-powermem-$PKG_VER.zip
# Create GitHub Release only when run on a tag
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: release/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Publish to npm only on tag; set NPM_TOKEN in Settings → Secrets and NPM_PUBLISH=true in Variables
- name: Publish to npm
if: startsWith(github.ref, 'refs/tags/') && vars.NPM_PUBLISH == 'true'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
TAG="${GITHUB_REF#refs/tags/}"
VERSION="${TAG#v}"
npm version "$VERSION" --no-git-tag-version --allow-same-version
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > .npmrc
npm publish