-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (131 loc) · 4.02 KB
/
Copy pathplugin-release.yml
File metadata and controls
156 lines (131 loc) · 4.02 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
name: Codex Plugin Release
on:
push:
tags:
- "plugin-v*"
workflow_dispatch:
inputs:
version:
description: "Plugin version without the plugin-v prefix, for example 0.1.0"
required: true
type: string
permissions:
contents: read
concurrency:
group: plugin-release-${{ github.ref }}
cancel-in-progress: false
jobs:
prepare:
name: Resolve Plugin Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.meta.outputs.version }}
steps:
- name: Check out source
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
- name: Enforce main release branch
if: github.ref_type == 'tag'
shell: bash
run: |
set -euo pipefail
git fetch --no-tags --prune origin \
"+refs/heads/main:refs/remotes/origin/main"
if ! git merge-base --is-ancestor "$GITHUB_SHA" "origin/main"; then
echo "::error::Plugin release tags must point to a commit on origin/main."
exit 2
fi
- name: Resolve plugin metadata
id: meta
env:
INPUT_VERSION: ${{ github.event.inputs.version || '' }}
shell: bash
run: |
set -euo pipefail
if [[ "$GITHUB_REF_TYPE" == "tag" ]]; then
version="${GITHUB_REF_NAME#plugin-v}"
else
version="$INPUT_VERSION"
fi
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "::error::Plugin release version must be semver-like: $version."
exit 2
fi
manifest_version="$(node -p "require('./plugins/gocus/.codex-plugin/plugin.json').version")"
if [[ "$version" != "$manifest_version" ]]; then
echo "::error::Tag/input version $version does not match plugin manifest $manifest_version."
exit 2
fi
echo "version=$version" >>"$GITHUB_OUTPUT"
verify:
name: Verify Plugin (${{ matrix.os }})
needs: prepare
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-15
- windows-latest
defaults:
run:
shell: bash
steps:
- name: Check out source
uses: actions/checkout@v7
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
cache: npm
- name: Install build dependencies
run: npm ci --ignore-scripts
- name: Verify installed-copy behavior
run: npm run plugin:verify
- name: Verify committed bundle
run: |
set -euo pipefail
generated_status="$(git status --porcelain -- plugins/gocus/dist)"
if [[ -n "$generated_status" ]]; then
echo "::error::The committed plugin bundle differs from npm run plugin:build."
echo "$generated_status"
git diff -- plugins/gocus/dist
exit 2
fi
package:
name: Package Plugin
needs:
- prepare
- verify
runs-on: ubuntu-latest
env:
PLUGIN_VERSION: ${{ needs.prepare.outputs.version }}
steps:
- name: Check out source
uses: actions/checkout@v7
- name: Create plugin archive
shell: bash
run: |
set -euo pipefail
mkdir -p release/plugin
archive="release/plugin/gocus-plugin-${PLUGIN_VERSION}.zip"
git archive \
--format=zip \
--prefix=gocus/ \
--output="$archive" \
"$GITHUB_SHA:plugins/gocus"
sha256sum "$archive" >"$archive.sha256"
unzip -t "$archive"
- name: Upload plugin artifact
uses: actions/upload-artifact@v7
with:
name: gocus-plugin-${{ needs.prepare.outputs.version }}
path: |
release/plugin/gocus-plugin-*.zip
release/plugin/gocus-plugin-*.zip.sha256