-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathpublish-matterbridge-plugin-dev-daily-from-dev.yml
More file actions
122 lines (102 loc) · 4.05 KB
/
publish-matterbridge-plugin-dev-daily-from-dev.yml
File metadata and controls
122 lines (102 loc) · 4.05 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# .github\workflows\publish-matterbridge-plugin-dev-daily-from-dev.yml
name: Plugin daily dev publish to npm from dev branch
on:
# Daily at midnight UTC
schedule:
- cron: '0 0 * * *'
# Allow manual dispatch
workflow_dispatch:
jobs:
publish-dev:
runs-on: ubuntu-latest
steps:
# Always check out the dev branch, even for scheduled runs
- name: Checkout dev
uses: actions/checkout@v4
with:
ref: dev
- name: Set up Node.js & registry
uses: actions/setup-node@v4
with:
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'
- name: Clean npm cache
run: npm cache clean --force
- name: Clone matterbridge repo branch dev
run: git clone --depth 1 --single-branch --no-tags -b dev https://github.com/Luligu/matterbridge.git ../matterbridge
- name: Install matterbridge dependencies
working-directory: ../matterbridge
run: npm ci --no-fund --no-audit
- name: Build matterbridge
working-directory: ../matterbridge
run: npm run build
- name: Link matterbridge globally
working-directory: ../matterbridge
run: npm link --no-fund --no-audit
- name: Lint & test & build the plugin
run: |
npm ci
npm link matterbridge
npm run buildProduction
npm run lint
npm install -g .
npm run test -- --forceExit
npm pkg delete devDependencies scripts types
npx shx rm -rf ./node_modules
npm install --omit=dev
npm shrinkwrap
- name: Extract base version and date
id: vars
run: |
BASE=$(jq -r '.version' package.json)
DATE=$(date -u +'%Y%m%d')
SHA=$(git rev-parse --short=7 HEAD)
DEV_TAG="${BASE}-dev-${DATE}-${SHA}"
echo "DEV_TAG=$DEV_TAG" >> $GITHUB_ENV
echo "ORIG_SHA=$SHA" >> $GITHUB_ENV
- name: Bump to date-commit-stamped version --no-git-tag-version tag ${{ env.DEV_TAG }} sha ${{ env.ORIG_SHA }}
run: npm version "${{ env.DEV_TAG }}" --no-git-tag-version
- name: Check if a new dev-publish is needed
id: check_new
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
# ensure npm can read the private or public registry
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
# 1) grab the package name
PKG=$(node -p "require('./package.json').name")
# 2) fetch the currently-published 'dev' dist-tag (e.g. "3.0.0-dev-20250430-1a2b3c4")
PUBLISHED=$(npm view "$PKG" dist-tags.dev 2>/dev/null || echo "")
# 3) extract the SHA suffix (after the last dash)
PUBLISHED_SHA=${PUBLISHED##*-}
# 4) get the current commit short-SHA
CURRENT_SHA=${ORIG_SHA}
echo "Published dev tag: $PUBLISHED"
echo "Published SHA: $PUBLISHED_SHA"
echo "Current SHA: $CURRENT_SHA"
if [ "$PUBLISHED_SHA" = "$CURRENT_SHA" ]; then
# nothing new → skip
echo "✅ No new commits since last dev publish - skipping"
echo "should_publish=false" >> $GITHUB_OUTPUT
else
# new commit → proceed
echo "🚀 New commits detected - proceeding with dev publish"
echo "should_publish=true" >> $GITHUB_OUTPUT
fi
- name: Publish the plugin to npm under ‘dev’ tag
if: steps.check_new.outputs.should_publish == 'true'
run: npm publish --tag dev
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Trigger Matterbridge Docker Build Dev
if: steps.check_new.outputs.should_publish == 'true'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.PAT_TOKEN }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: 'Luligu',
repo: 'matterbridge',
workflow_id: 'docker-buildx-dev.yml',
ref: 'dev'
})