-
Notifications
You must be signed in to change notification settings - Fork 2
71 lines (61 loc) · 2.24 KB
/
Copy pathrelease.yml
File metadata and controls
71 lines (61 loc) · 2.24 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: Release to NPM
on:
push:
branches: [main]
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Setup Node.js with npm registry
uses: actions/setup-node@v4
with:
node-version: "24"
registry-url: "https://registry.npmjs.org"
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Build
run: bun run build
- name: Check whether local version was already published
id: check
run: |
LOCAL=$(node -p "require('./packages/cli/package.json').version")
LATEST=$(npm view @metabase/cli version 2>/dev/null || echo "none")
ALREADY_PUBLISHED=$(npm view @metabase/cli versions --json 2>/dev/null | node -e "
let raw = '';
process.stdin.on('data', (chunk) => { raw += chunk; });
process.stdin.on('end', () => {
if (raw.trim().length === 0) { console.log('false'); return; }
const versions = JSON.parse(raw);
const list = Array.isArray(versions) ? versions : [versions];
console.log(list.includes(process.argv[1]) ? 'true' : 'false');
});
" "$LOCAL")
echo "local=$LOCAL" >> $GITHUB_OUTPUT
echo "latest=$LATEST" >> $GITHUB_OUTPUT
if [ "$ALREADY_PUBLISHED" = "true" ]; then
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Publish to NPM
if: steps.check.outputs.changed == 'true'
working-directory: packages/cli
run: npm publish --tag latest --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_RELEASE_TOKEN }}
- name: Generate workflow summary
run: |
tee -a $GITHUB_STEP_SUMMARY << EOF
## @metabase/cli
- **Local version**: ${{ steps.check.outputs.local }}
- **Current \`latest\` on npm**: ${{ steps.check.outputs.latest }}
- **Published this run**: ${{ steps.check.outputs.changed }}
EOF