-
-
Notifications
You must be signed in to change notification settings - Fork 4
147 lines (131 loc) · 5.09 KB
/
Copy pathbuild-plugins.yml
File metadata and controls
147 lines (131 loc) · 5.09 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: Build plugin artifacts
# Builds every example plugin's .cgp and exposes them as downloadable
# workflow artifacts. Unlike "Update libs from CodeOnTheGo", this never
# commits refreshed libs, never publishes a GitHub release, and never
# deploys to the website — it only produces artifacts you can download
# from the run summary.
on:
workflow_dispatch:
inputs:
codeonthego_ref:
description: CodeOnTheGo branch or tag to build the libs against
required: false
default: stage
plugin:
description: Build only this plugin (folder name, e.g. random-xkcd). Leave empty to build all.
required: false
default: ''
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 45
outputs:
plugins: ${{ steps.stage.outputs.plugins }}
steps:
- name: Checkout plugin-examples
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-disabled: true
add-job-summary: 'never'
- name: Build libs and plugins
env:
CODEONTHEGO_REF: ${{ github.event.inputs.codeonthego_ref }}
ONLY_PLUGIN: ${{ github.event.inputs.plugin }}
run: |
if [ -n "$ONLY_PLUGIN" ]; then
./scripts/update-libs.sh --ref "$CODEONTHEGO_REF" --plugin "$ONLY_PLUGIN"
else
./scripts/update-libs.sh --ref "$CODEONTHEGO_REF"
fi
- name: Stage built .cgp artifacts
id: stage
env:
ONLY_PLUGIN: ${{ github.event.inputs.plugin }}
run: |
mkdir -p deploy-staging
# Discover every plugin module the same way scripts/update-libs.sh does
# (a sibling dir whose build.gradle.kts applies the plugin-builder Gradle
# plugin), then stage each plugin's built .cgp under its own name. The
# plugin-builder already names the artifact, so there is no rename map —
# new plugins are picked up automatically.
# Keep in sync with SKIP_PLUGINS in scripts/update-libs.sh.
SKIP_PLUGINS=(pebble-custom-function-template-installer)
staged=0
names=()
for build_file in */build.gradle.kts; do
[ -f "$build_file" ] || continue
grep -qF "com.itsaky.androidide.plugins.build" "$build_file" || continue
module="$(dirname "$build_file")"
# When a single plugin was requested, only that module was built —
# skip every other module so its absent .cgp is not treated as an error.
if [ -n "$ONLY_PLUGIN" ] && [ "$module" != "$ONLY_PLUGIN" ]; then
continue
fi
skip=0
for s in "${SKIP_PLUGINS[@]}"; do
[ "$s" = "$module" ] && skip=1 && break
done
if [ "$skip" -eq 1 ]; then
echo "Skipping $module (in SKIP_PLUGINS)"
continue
fi
src="$(ls "${module}/build/plugin/"*.cgp 2>/dev/null | grep -v -- '-debug\.cgp$' | head -n1)"
if [ -z "$src" ]; then
echo "ERROR: no release .cgp found under ${module}/build/plugin/ (did assemblePlugin run?)"
exit 1
fi
cp "$src" "deploy-staging/$(basename "$src")"
echo "Staged $src -> deploy-staging/$(basename "$src")"
names+=("$(basename "$src" .cgp)")
staged=$((staged + 1))
done
if [ "$staged" -eq 0 ]; then
echo "ERROR: no plugin modules discovered under */build.gradle.kts"
exit 1
fi
# Emit the staged artifact names as a JSON array so the publish job can
# fan out one downloadable artifact per plugin via a matrix.
plugins="$(printf '%s\n' "${names[@]}" | jq -R . | jq -cs .)"
echo "plugins=${plugins}" >> "$GITHUB_OUTPUT"
echo ""
echo "Staged ${staged} plugin artifact(s): ${names[*]}"
ls -la deploy-staging/
- name: Upload all .cgp as one bundle
uses: actions/upload-artifact@v4
with:
name: all-plugins-cgp
path: deploy-staging/*.cgp
retention-days: 7
if-no-files-found: error
# publish one downloadable artifact per plugin so each .cgp can be
# grabbed directly from the run summary, not only as part of the bundle.
publish:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
plugin: ${{ fromJson(needs.build.outputs.plugins) }}
steps:
- name: Download bundle
uses: actions/download-artifact@v4
with:
name: all-plugins-cgp
path: deploy-staging
- name: Upload ${{ matrix.plugin }} as its own artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.plugin }}
path: deploy-staging/${{ matrix.plugin }}.cgp
retention-days: 7
if-no-files-found: error