-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (91 loc) · 3.75 KB
/
sync-editor.yml
File metadata and controls
103 lines (91 loc) · 3.75 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
name: Sync Editor on Editor Release
on:
repository_dispatch:
types: [editor-release]
permissions:
contents: write
packages: read
jobs:
sync:
name: Update schema and editor dependency
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
- uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://npm.pkg.github.com'
scope: '@gocodealone'
cache: 'npm'
- name: Install wfctl
run: |
LATEST_TAG=$(curl -fsSL https://api.github.com/repos/GoCodeAlone/workflow/releases/latest | jq -r .tag_name)
echo "WORKFLOW_ENGINE_VERSION=${LATEST_TAG}" >> "$GITHUB_ENV"
curl -fsSL "https://github.com/GoCodeAlone/workflow/releases/download/${LATEST_TAG}/wfctl-linux-amd64" -o /usr/local/bin/wfctl
chmod +x /usr/local/bin/wfctl
- name: Regenerate schema
run: wfctl schema --output schemas/workflow-config.schema.json
- name: Render templates
run: |
export WORKFLOW_VERSION="${WORKFLOW_ENGINE_VERSION}"
envsubst '${WORKFLOW_VERSION}' < README.md.tmpl > README.md
- name: Update editor package
run: |
EDITOR_VERSION="${{ github.event.client_payload.version }}"
npm install "@gocodealone/workflow-editor@${EDITOR_VERSION#v}"
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Compute plugin version
id: version
run: |
WORKFLOW_VERSION="${{ github.event.client_payload.version }}"
VERSION="${WORKFLOW_VERSION#v}"
MAJOR=$(echo "$VERSION" | cut -d. -f1)
MINOR=$(echo "$VERSION" | cut -d. -f2)
PATCH=$(echo "$VERSION" | cut -d. -f3)
BASE=$((PATCH * 100))
CURRENT_VERSION=$(node -p "require('./package.json').version")
CURRENT_PATCH=$(echo "$CURRENT_VERSION" | cut -d. -f3)
if [ "$CURRENT_PATCH" -ge "$BASE" ] && [ "$CURRENT_PATCH" -lt "$((BASE + 100))" ]; then
PLUGIN_PATCH=$((CURRENT_PATCH + 1))
else
PLUGIN_PATCH=$BASE
fi
PLUGIN_VERSION="${MAJOR}.${MINOR}.${PLUGIN_PATCH}"
echo "PLUGIN_VERSION=${PLUGIN_VERSION}" >> "$GITHUB_OUTPUT"
echo "Engine ${WORKFLOW_VERSION} → plugin v${PLUGIN_VERSION}"
- name: Bump extension version
run: |
PLUGIN_VERSION="${{ steps.version.outputs.PLUGIN_VERSION }}"
CURRENT_VERSION=$(node -p "require('./package.json').version")
if [ "${CURRENT_VERSION}" = "${PLUGIN_VERSION}" ]; then
echo "Version already at ${PLUGIN_VERSION}, skipping"
else
npm version "${PLUGIN_VERSION}" --no-git-tag-version
fi
- name: Install and build
run: |
npm ci
npx tsc --noEmit
npm run build
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit and tag
run: |
WORKFLOW_VERSION="${{ github.event.client_payload.version }}"
PLUGIN_VERSION="v${{ steps.version.outputs.PLUGIN_VERSION }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git diff --cached --quiet && echo "No changes" && exit 0
git commit -m "chore: sync schema, editor, and version to workflow ${WORKFLOW_VERSION} (plugin ${PLUGIN_VERSION})"
git pull --rebase
git push
if git rev-parse "${PLUGIN_VERSION}" >/dev/null 2>&1; then
echo "Tag ${PLUGIN_VERSION} already exists, skipping"
else
git tag "${PLUGIN_VERSION}"
git push origin "${PLUGIN_VERSION}"
fi