Repository navigation
106 lines (91 loc) · 2.96 KB
/
Copy pathci.yml
File metadata and controls
106 lines (91 loc) · 2.96 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
name: CI
on:
push:
branches:
- master
pull_request:
jobs:
build-lowest-version:
name: Build lowest version
runs-on: ubuntu-latest
steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
coverage: none
extensions: mbstring, intl
- name: Checkout code
uses: actions/checkout@v7
- name: Download dependencies
run: composer update --no-interaction --prefer-stable --prefer-lowest --prefer-dist
- name: Run tests
run: ./vendor/bin/phpunit
build:
name: Build
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 10
matrix:
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
extensions: mbstring, intl
- name: Checkout code
uses: actions/checkout@v7
- name: Download dependencies
run: composer update --no-interaction --prefer-dist
- name: Run tests
run: ./vendor/bin/phpunit
release:
name: Release
needs:
- build-lowest-version
- build
if: github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
runs-on: ubuntu-latest
permissions:
contents: write
concurrency:
group: release
cancel-in-progress: false
outputs:
tag: ${{ steps.version.outputs.tag }}
created: ${{ steps.release.outputs.created }}
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Read the version from the changelog
id: version
run: |
version=$(sed -nE 's/^## ([0-9][^[:space:]]*).*/\1/p' CHANGELOG.md | head -1)
if [ -z "$version" ]; then
echo "::error file=CHANGELOG.md::No '## x.y.z' heading found in CHANGELOG.md"
exit 1
fi
echo "tag=$version" >> "$GITHUB_OUTPUT"
echo "The changelog version is $version; the tag is $version."
- name: Create the tag and the GitHub release
id: release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.version.outputs.tag }}
run: |
rc=0
git ls-remote --exit-code --tags origin "refs/tags/$TAG" >/dev/null || rc=$?
if [ "$rc" -eq 0 ]; then
echo "Tag $TAG already exists; nothing to release."
echo "created=false" >> "$GITHUB_OUTPUT"
exit 0
elif [ "$rc" -ne 2 ]; then
echo "::error::Could not check whether tag $TAG exists (git ls-remote exited with $rc)."
exit "$rc"
fi
gh release create "$TAG" --target "$GITHUB_SHA" --title "$TAG" --generate-notes
echo "created=true" >> "$GITHUB_OUTPUT"
echo "Created tag $TAG and its GitHub release from $GITHUB_SHA."