-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (54 loc) · 2.16 KB
/
Copy pathrelease.yml
File metadata and controls
63 lines (54 loc) · 2.16 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
name: Release
# Publishes citecue-ai-auto-fix.zip — an archive that unpacks to
# citecue-ai-auto-fix/ (the WordPress.org slug, so the two install channels
# share one directory) and contains only the runtime files — as a release
# asset, so that installing the plugin is "Plugins → Add New → Upload" rather
# than "download the source, rename the folder, delete the tests".
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
release:
name: Build and publish the plugin zip
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# The build reads .gitattributes and the version strings out of the ref
# itself, so it needs the tag object, not just a shallow snapshot.
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build the plugin zip
run: bin/build-plugin-zip.sh "$GITHUB_SHA"
# A tag that disagrees with the plugin header would ship an update
# WordPress cannot reason about; catch it before the asset is public.
- name: Check the tag matches the plugin version
if: startsWith(github.ref, 'refs/tags/v')
run: |
tag="${GITHUB_REF_NAME#v}"
header=$(sed -n 's/^[[:space:]]*\*[[:space:]]*Version:[[:space:]]*\([^[:space:]]*\).*/\1/p' citecue.php | head -n 1)
if [ "$tag" != "$header" ]; then
echo "::error::tag $GITHUB_REF_NAME does not match plugin version $header"
exit 1
fi
- name: Upload the zip as a workflow artifact
uses: actions/upload-artifact@v4
with:
name: citecue-plugin-zip
path: dist/citecue-ai-auto-fix.zip
if-no-files-found: error
- name: Attach the zip to the release
if: startsWith(github.ref, 'refs/tags/v')
env:
GH_TOKEN: ${{ github.token }}
run: |
if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then
gh release upload "$GITHUB_REF_NAME" dist/citecue-ai-auto-fix.zip --clobber
else
gh release create "$GITHUB_REF_NAME" dist/citecue-ai-auto-fix.zip \
--title "$GITHUB_REF_NAME" \
--generate-notes
fi