-
Notifications
You must be signed in to change notification settings - Fork 2
164 lines (162 loc) · 6.09 KB
/
Copy pathplugins.yml
File metadata and controls
164 lines (162 loc) · 6.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: plugins
on:
# Allow to run this workflow manually from the Actions tab
workflow_dispatch:
push:
branches: [main]
paths:
- 'crates/plugins/**'
- 'crates/internal/build-registry/**'
- 'docs/registry/**'
- '.github/workflows/plugins.yml'
env:
CARGO_TERM_COLOR: always
JUST_TIMESTAMP: true
JUST_COLOR: always
JUST_EXPLAIN: true
JUST_VERBOSE: 4
permissions:
contents: write
# Required for the publish job to dispatch the docs workflow via the API.
actions: write
jobs:
build:
strategy:
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
name_suffix: " (macos arm64)"
- target: x86_64-apple-darwin
os: macos-latest
name_suffix: " (macos x86_64)"
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name_suffix: " (linux x86_64)"
- target: x86_64-pc-windows-msvc
os: windows-latest
name_suffix: " (windows x86_64)"
runs-on: ${{ matrix.os }}
name: plugins ${{ matrix.name_suffix }}
steps:
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v6
- uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5
id: restore-cache
with:
path: |
~/.rustup
key: plugins-${{ matrix.target }}
- uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v2
- uses: Swatinem/rust-cache@7e1e2d0a10862b34e5df481373b2b0f295d1a2ef # v2
with:
key: plugins-${{ matrix.target }}
cache-bin: false
cache-workspace-crates: true
save-if: ${{ github.ref == 'refs/heads/main' }}
- run: rustup target add ${{ matrix.target }}
- run: just plugin-build ${{ matrix.target }}
# Rename binaries to include target triple for the release.
- name: Stage binaries
shell: bash
run: |
mkdir -p staged
for bin in target/${{ matrix.target }}/release/jp-*; do
[ -f "$bin" ] || continue
# Skip .d (dep-info) and .pdb files.
case "$bin" in *.d|*.pdb) continue;; esac
name=$(basename "$bin")
# Strip the .exe extension so asset names are uniform across
# platforms (jp-<id>-<target>). The installer re-adds .exe on
# Windows, and build-registry builds extension-less download URLs.
name="${name%.exe}"
cp "$bin" "staged/${name}-${{ matrix.target }}"
done
ls -la staged/
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v4
with:
name: plugins-${{ matrix.target }}
path: staged/
publish:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v6
- uses: Swatinem/rust-cache@7e1e2d0a10862b34e5df481373b2b0f295d1a2ef # v2
with:
key: plugins-publish
cache-bin: false
cache-workspace-crates: true
save-if: ${{ github.ref == 'refs/heads/main' }}
- uses: actions/download-artifact@484a0b528fb4d7bd804637ccb632e47a0e638317 # v4
with:
path: artifacts/
# Build checksums file from all platform artifacts.
- name: Compute checksums
run: |
for dir in artifacts/plugins-*/; do
target=$(basename "$dir" | sed 's/^plugins-//')
for binary in "$dir"/jp-*; do
[ -f "$binary" ] || continue
# Extract plugin id: jp-<id>-<target> -> <id>
name=$(basename "$binary")
id=$(echo "$name" | sed "s/^jp-//; s/-${target}$//")
sha=$(shasum -a 256 "$binary" | cut -d' ' -f1)
echo "$id $target $sha" >> checksums.txt
done
done
echo "=== checksums.txt ==="
cat checksums.txt
# Generate plugins.json with checksums and download URLs.
- name: Build registry
run: |
cargo run --quiet -p build-registry -- \
--groups docs/registry/groups.toml \
--checksums checksums.txt \
> plugins.json
echo "=== plugins.json ==="
cat plugins.json
# Upload binaries to the rolling "plugins" GitHub Release.
- name: Upload binaries to release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release view plugins >/dev/null 2>&1 \
|| gh release create plugins --prerelease \
--title "Plugin Binaries" \
--notes "Auto-updated plugin binaries. Do not delete this release."
for binary in artifacts/*/jp-*; do
gh release upload plugins "$binary" --clobber
done
# Push plugins.json to the orphan branch (with history).
- name: Publish registry to orphan branch
id: publish-registry
run: |
git fetch origin plugin-registry || true
if git rev-parse --verify origin/plugin-registry >/dev/null 2>&1; then
git worktree add /tmp/registry plugin-registry
else
echo "plugin-registry branch does not exist yet, creating it."
mkdir /tmp/registry
cd /tmp/registry
git init -b plugin-registry
cd -
fi
cp plugins.json /tmp/registry/plugins.json
cd /tmp/registry
git add plugins.json
if git diff --cached --quiet; then
echo "Registry unchanged, skipping commit."
echo "changed=false" >> "$GITHUB_OUTPUT"
else
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -m "Update plugin registry"
git push origin plugin-registry
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
# Trigger docs rebuild to pick up the new registry.
- name: Trigger docs deploy
if: steps.publish-registry.outputs.changed == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: gh workflow run docs.yml