-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (128 loc) · 5.54 KB
/
publish.yml
File metadata and controls
147 lines (128 loc) · 5.54 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Publish
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Release
runs-on: ubuntu-latest
environment: production
permissions:
contents: write
pull-requests: write
id-token: write
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
always-auth: true
cache: "pnpm"
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Upgrade npm for OIDC support
run: npm install -g npm@latest
- name: Build
run: pnpm -r run build
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: pnpm run ci:publish
commit: "chore: version packages"
title: "chore: version packages"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check for specific package releases
id: check_releases
if: steps.changesets.outputs.published == 'true'
run: |
node -e '
const published = JSON.parse(process.env.PUBLISHED_PACKAGES || "[]");
const nodeRed = published.find(p => p.name === "@teslemetry/node-red-contrib-teslemetry");
const n8n = published.find(p => p.name === "@teslemetry/n8n-nodes-teslemetry");
if (nodeRed) {
console.log("Found Node-RED release: " + nodeRed.version);
require("fs").appendFileSync(process.env.GITHUB_OUTPUT, "node_red_version=" + nodeRed.version + "\n");
}
if (n8n) {
console.log("Found n8n release: " + n8n.version);
require("fs").appendFileSync(process.env.GITHUB_OUTPUT, "n8n_version=" + n8n.version + "\n");
}
'
env:
PUBLISHED_PACKAGES: ${{ steps.changesets.outputs.publishedPackages }}
- name: Discord Notification (Node-RED)
if: steps.check_releases.outputs.node_red_version
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_NODERED }}
VERSION: ${{ steps.check_releases.outputs.node_red_version }}
run: |
curl -H "Content-Type: application/json" \
-d "{\"username\": \"Teslemetry Release\", \"content\": \"🚀 **New Release**\n**@teslemetry/node-red-contrib-teslemetry** version **$VERSION** is now available!\"}" \
$DISCORD_WEBHOOK
- name: Discord Notification (n8n)
if: steps.check_releases.outputs.n8n_version
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_N8N }}
VERSION: ${{ steps.check_releases.outputs.n8n_version }}
run: |
curl -H "Content-Type: application/json" \
-d "{\"username\": \"Teslemetry Release\", \"content\": \"🚀 **New Release**\n**@teslemetry/n8n-nodes-teslemetry** version **$VERSION** is now available!\"}" \
$DISCORD_WEBHOOK
- name: Check for Homey package release
id: check_homey
if: steps.changesets.outputs.published == 'true'
run: |
node -e '
const published = JSON.parse(process.env.PUBLISHED_PACKAGES || "[]");
const homey = published.find(p => p.name === "com.teslemetry");
if (homey) {
console.log("Found Homey package release: " + homey.version);
require("fs").appendFileSync(process.env.GITHUB_OUTPUT, "homey_version=" + homey.version + "\n");
require("fs").appendFileSync(process.env.GITHUB_OUTPUT, "should_publish_homey=true\n");
}
'
env:
PUBLISHED_PACKAGES: ${{ steps.changesets.outputs.publishedPackages }}
- name: Update Homey App Version
if: steps.check_homey.outputs.should_publish_homey == 'true'
working-directory: ./packages/homey
run: |
# Update .homeycompose/app.json version to match package.json
node -e '
const fs = require("fs");
const packageJson = JSON.parse(fs.readFileSync("package.json", "utf8"));
const appJson = JSON.parse(fs.readFileSync(".homeycompose/app.json", "utf8"));
appJson.version = packageJson.version;
fs.writeFileSync(".homeycompose/app.json", JSON.stringify(appJson, null, 2));
'
- name: Validate Homey App
if: steps.check_homey.outputs.should_publish_homey == 'true'
uses: athombv/github-action-homey-app-validate@master
with:
level: verified
- name: Publish Homey App
if: steps.check_homey.outputs.should_publish_homey == 'true'
uses: athombv/github-action-homey-app-publish@master
id: publish_homey
with:
personal_access_token: ${{ secrets.HOMEY_PAT }}
- name: Discord Notification (Homey)
if: steps.check_homey.outputs.homey_version
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_HOMEY }} # You'd need to add this secret
VERSION: ${{ steps.check_homey.outputs.homey_version }}
run: |
curl -H "Content-Type: application/json" \
-d "{\"username\": \"Teslemetry Release\", \"content\": \"🏠 **New Homey App Release**\n**Teslemetry for Homey** version **$VERSION** is now available!\"}" \
$DISCORD_WEBHOOK || echo "Discord webhook not configured for Homey"