-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (61 loc) · 2.5 KB
/
Copy pathrelease.yml
File metadata and controls
69 lines (61 loc) · 2.5 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
name: Release
# Build a distributable plugin zip and attach it to the GitHub release whenever
# a version tag is pushed. The Datalumo plugin checks for updates against these
# release assets (see src/Support/UpdateChecker.php), so the zip must contain the
# Composer-built vendor/ directory — GitHub's auto-generated source zip does not.
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: composer:v2
coverage: none
- name: Install production dependencies
# --ignore-platform-req=php: the release runs on the plugin's PHP floor
# (8.1), but the dev tooling (Pest) needs 8.3+. With no lock file present,
# Composer resolves the whole graph even under --no-dev, so the dev
# requirement's PHP gate would block the build. Dev deps aren't installed
# here and the prod deps have no upper PHP bound, so ignoring the PHP
# requirement leaves the shipped vendor/ unchanged.
run: composer install --no-dev --optimize-autoloader --prefer-dist --no-interaction --ignore-platform-req=php
- name: Verify tag matches plugin version
run: |
HEADER_VERSION="$(grep -oP 'Version:\s*\K[0-9.]+' datalumo.php)"
TAG_VERSION="${GITHUB_REF_NAME#v}"
echo "Plugin header: ${HEADER_VERSION} — tag: ${TAG_VERSION}"
if [ "${HEADER_VERSION}" != "${TAG_VERSION}" ]; then
echo "::error::Tag ${GITHUB_REF_NAME} does not match plugin header version ${HEADER_VERSION}. Bump the Version header and Stable tag before tagging."
exit 1
fi
- name: Build plugin zip
run: |
mkdir -p build/datalumo
rsync -a ./ build/datalumo/ \
--exclude '.git' \
--exclude '.github' \
--exclude '.gitignore' \
--exclude '.slimm' \
--exclude 'build' \
--exclude '*.zip' \
--exclude 'tests' \
--exclude 'bin' \
--exclude 'phpunit.xml' \
--exclude '.phpunit.cache' \
--exclude 'composer.lock'
(cd build && zip -rq datalumo.zip datalumo)
- name: Create release and upload asset
uses: softprops/action-gh-release@v2
with:
files: build/datalumo.zip
generate_release_notes: true