Repository navigation
75 lines (69 loc) · 2.72 KB
/
Copy pathci.yml
File metadata and controls
75 lines (69 loc) · 2.72 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
name: CI
on:
push:
pull_request:
jobs:
test:
name: PHP ${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
steps:
- uses: actions/checkout@v7
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: curl, json
- name: Validate composer.json
run: composer validate --strict
- name: Lint PHP files
run: find src tests -name '*.php' -print0 | xargs -0 -n1 -t php -l
- name: Smoke test (fails on any Deprecated/Warning/Notice)
run: php -d error_reporting=E_ALL tests/smoke.php
- name: Functional test against a local stub of the API (fails on any Deprecated/Warning/Notice)
run: php -d error_reporting=E_ALL tests/functional.php
release:
name: GitHub release
# Only on a version tag (1.2.3, no v), and only once the whole 8.0-8.5 matrix is green: a tag
# that fails CI must not produce a release.
needs: test
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Publish the release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.ref_name }}
run: |
set -euo pipefail
if gh release view "$TAG" >/dev/null 2>&1; then
echo "Release $TAG already exists, nothing to do."
exit 0
fi
# actions/checkout fetches the pushed ref by its COMMIT sha into refs/tags/$TAG,
# which turns an annotated tag into a lightweight one (actions/checkout#290):
# `git cat-file -t` then says "commit" and the tag message is never read. 1.2.0
# shipped with generated notes for that reason. Re-fetching the tag ref itself
# restores the tag object; --force because the ref already exists.
git fetch --force --no-tags origin "+refs/tags/$TAG:refs/tags/$TAG"
if [ "$(git cat-file -t "$TAG")" = "tag" ]; then
# Annotated tag: its message is the changelog. Co-author trailers are
# commit metadata, not release notes.
{
git tag -l --format='%(contents:subject)' "$TAG"
printf '\n'
git tag -l --format='%(contents:body)' "$TAG"
} | grep -v '^Co-Authored-By:' > notes.md || true
gh release create "$TAG" --title "$TAG" --notes-file notes.md
else
# Lightweight tag: no message to read, so let GitHub build the notes.
gh release create "$TAG" --title "$TAG" --generate-notes
fi