-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (63 loc) · 2 KB
/
Copy pathrelease.yml
File metadata and controls
67 lines (63 loc) · 2 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
name: Release
on:
push:
branches:
- main
permissions:
contents: read
jobs:
verify:
if: startsWith(github.event.head_commit.message, 'Release v')
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.4', '8.5']
steps:
- uses: actions/checkout@v7
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: composer:v2
- run: composer validate --strict
- run: composer install --no-interaction --prefer-dist
- name: Run package checks
shell: bash
run: |
set -euo pipefail
if php -r '$c=json_decode(file_get_contents("composer.json"), true, 512, JSON_THROW_ON_ERROR); exit(isset($c["scripts"]["test"]) ? 0 : 1);'; then
composer test
elif [ -d tests ] && [ -x vendor/bin/pest ]; then
vendor/bin/pest
elif [ -d tests ] && [ -x vendor/bin/phpunit ]; then
vendor/bin/phpunit tests
else
find src -type f -name '*.php' -print0 | xargs -0 -n1 php -l
fi
publish:
if: startsWith(github.event.head_commit.message, 'Release v')
needs: verify
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- name: Publish GitHub release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: |
set -euo pipefail
first_line="${COMMIT_MESSAGE%%$'\n'*}"
tag="${first_line#Release }"
if ! [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
echo "Invalid release tag: $tag" >&2
exit 1
fi
if gh release view "$tag" >/dev/null 2>&1; then
echo "Release $tag already exists."
exit 0
fi
gh release create "$tag" --target "$GITHUB_SHA" --title "$tag" --generate-notes