-
Notifications
You must be signed in to change notification settings - Fork 1
100 lines (87 loc) · 2.98 KB
/
Copy pathrelease.yml
File metadata and controls
100 lines (87 loc) · 2.98 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
name: Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
tag:
description: "Release tag, for example v1.0.4"
required: true
type: string
permissions:
contents: write
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
release:
name: Build and publish release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "24"
- name: Install tools
run: |
sudo apt-get update
sudo apt-get install -y php-cli php-xml zip unzip libxml2-utils
gh --version
- name: Install frontend dependencies
run: |
if [ -f package-lock.json ]; then
npm ci --ignore-scripts --legacy-peer-deps
else
npm install --ignore-scripts --legacy-peer-deps
fi
- name: Resolve release version
id: version
run: |
meta_version="$(php -r '$xml = simplexml_load_file("meta.xml"); echo trim((string) $xml->version);')"
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
tag="${{ inputs.tag }}"
else
tag="${GITHUB_REF_NAME}"
fi
tag_version="${tag#v}"
if [ "$meta_version" != "$tag_version" ]; then
echo "meta.xml version ($meta_version) must match release tag ($tag)." >&2
exit 1
fi
echo "version=$meta_version" >> "$GITHUB_OUTPUT"
echo "tag=v$meta_version" >> "$GITHUB_OUTPUT"
- name: Validate package inputs
run: |
find plib htdocs \( -name '*.php' -o -name '*.phtml' \) -print0 \
| sort -z \
| xargs -0 -n1 php -l
npm test
xmllint --noout meta.xml
node -e "JSON.parse(require('fs').readFileSync('packaging/manifest.json', 'utf8'))"
sh -n packaging/build.sh
- name: Build release ZIP asset
run: |
version="${{ steps.version.outputs.version }}"
sh packaging/build.sh
zip -T "cloudflare-pro-${version}.zip"
- name: Generate release notes
run: |
awk 'NR == 1 { next } /^## / && seen { exit } /^## / { seen = 1; next } seen { print }' CHANGES.md > release-notes.md
if [ ! -s release-notes.md ]; then
echo "Cloudflare Pro ${{ steps.version.outputs.tag }}" > release-notes.md
fi
- name: Publish GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
tag="${{ steps.version.outputs.tag }}"
version="${{ steps.version.outputs.version }}"
if gh release view "$tag" >/dev/null 2>&1; then
gh release upload "$tag" "cloudflare-pro-${version}.zip" --clobber
else
gh release create "$tag" "cloudflare-pro-${version}.zip" \
--title "$tag" \
--notes-file release-notes.md
fi