-
Notifications
You must be signed in to change notification settings - Fork 1
181 lines (152 loc) · 6.36 KB
/
plugin-release.yml
File metadata and controls
181 lines (152 loc) · 6.36 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# .github/workflows/plugin-release.yml
# CI/CD pipeline for the DocTest validation plugin
#
# This workflow demonstrates best practices for Unraid plugin releases:
# - Builds TXZ package with proper line endings
# - Calculates SHA256 for integrity verification
# - Generates PLG file from template with correct URLs
# - Creates GitHub releases with all artifacts
#
# Triggers:
# - Push to main (validation only, no release)
# - Manual workflow_dispatch (for testing)
# - New tag matching v* pattern (creates release)
name: Build & Release Plugin
on:
push:
branches: [main]
paths:
- 'validation/plugin/**'
- '.github/workflows/plugin-release.yml'
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to build (e.g., 2026.02.01)'
required: false
default: ''
permissions:
contents: write
env:
PLUGIN_NAME: doctest
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.VERSION }}
sha256: ${{ steps.package.outputs.SHA256 }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine version
id: version
run: |
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == refs/tags/v* ]]; then
# Release tag - extract version from tag (remove 'v' prefix)
VERSION="${GITHUB_REF#refs/tags/v}"
elif [[ -n "${{ github.event.inputs.version }}" ]]; then
# Manual input
VERSION="${{ github.event.inputs.version }}"
else
# Default: date-based version
VERSION="$(date +%Y.%m.%d)"
fi
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "Building version: ${VERSION}"
- name: Build TXZ package
id: package
run: |
VERSION="${{ steps.version.outputs.VERSION }}"
cd validation/plugin
# Create build directory structure
rm -rf build dist
mkdir -p build/usr/local/emhttp/plugins/${{ env.PLUGIN_NAME }}
mkdir -p dist
# Copy source files
cp -R source/emhttp/* build/usr/local/emhttp/plugins/${{ env.PLUGIN_NAME }}/
# CRITICAL: Convert Windows line endings to Unix (CRLF → LF)
find build -type f \( -name "*.sh" -o -name "*.page" -o -name "*.cfg" \) -exec sed -i 's/\r$//' {} \;
find build -path "*/event/*" -type f -exec sed -i 's/\r$//' {} \;
# Set permissions
find build -type d -exec chmod 755 {} \;
find build -type f -exec chmod 644 {} \;
find build -path "*/event/*" -type f -exec chmod 755 {} \;
# Create TXZ package
cd build
tar -cJf "../dist/${{ env.PLUGIN_NAME }}-${VERSION}.txz" .
cd ..
# Calculate SHA256
SHA256=$(sha256sum "dist/${{ env.PLUGIN_NAME }}-${VERSION}.txz" | cut -d' ' -f1)
echo "SHA256=${SHA256}" >> $GITHUB_OUTPUT
echo "Package SHA256: ${SHA256}"
- name: Generate PLG file
run: |
VERSION="${{ steps.version.outputs.VERSION }}"
SHA256="${{ steps.package.outputs.SHA256 }}"
cd validation/plugin
# Generate PLG from template with substitutions
sed -e "s|<!ENTITY version.*|<!ENTITY version \"${VERSION}\">|" \
-e "s|<!ENTITY txzName.*|<!ENTITY txzName \"${{ env.PLUGIN_NAME }}-${VERSION}.txz\">|" \
-e "s|<!ENTITY txzURL.*|<!ENTITY txzURL \"https://github.com/${{ github.repository }}/releases/download/v${VERSION}/${{ env.PLUGIN_NAME }}-${VERSION}.txz\">|" \
-e "s|<!ENTITY txzSHA256.*|<!ENTITY txzSHA256 \"${SHA256}\">|" \
doctest.plg.template > dist/${{ env.PLUGIN_NAME }}.plg
echo "Generated PLG file:"
head -20 dist/${{ env.PLUGIN_NAME }}.plg
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: plugin-package
path: |
validation/plugin/dist/*.txz
validation/plugin/dist/*.plg
retention-days: 30
# Only run release job on tag push
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: plugin-package
path: dist/
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: "DocTest Plugin v${{ needs.build.outputs.version }}"
body: |
## DocTest Validation Plugin v${{ needs.build.outputs.version }}
This plugin validates features documented at [unraid-plugin-docs](https://mstrhakr.github.io/unraid-plugin-docs/).
### Installation
**Via Plugin Manager:**
```
https://raw.githubusercontent.com/${{ github.repository }}/main/validation/doctest.plg
```
**Or install directly:**
```bash
plugin install https://raw.githubusercontent.com/${{ github.repository }}/main/validation/doctest.plg
```
### What's Validated
- All 16 documented event handlers
- `parse_plugin_cfg()` and `mk_option()` functions
- `$var` array properties
- Page file rendering and form handling
- Notification system integration
### Package Details
- **SHA256:** `${{ needs.build.outputs.sha256 }}`
files: |
dist/*.txz
dist/*.plg
fail_on_unmatched_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update main branch PLG
run: |
# This step would update the PLG in the main branch
# For now, we'll document that this should be done manually
# or via a separate workflow that commits the updated PLG
echo "Release created. Remember to update validation/doctest.plg in main branch."