44 push :
55 tags :
66 - ' v*'
7+ - ' [0-9]*.[0-9]*.[0-9]*'
78 release :
89 types : [published]
910
@@ -14,7 +15,7 @@ permissions:
1415jobs :
1516 validate-tag :
1617 runs-on : ubuntu-latest
17- if : startsWith(github.ref, 'refs/tags/v ')
18+ if : startsWith(github.ref, 'refs/tags/')
1819
1920 outputs :
2021 version : ${{ steps.version.outputs.version }}
2728 - name : Validate version tag
2829 id : version
2930 run : |
30- VERSION=${GITHUB_REF#refs/tags/v}
31+ VERSION=${GITHUB_REF#refs/tags/}
32+ VERSION=${VERSION#v}
3133 echo "version=$VERSION" >> $GITHUB_OUTPUT
3234
3335 # Check if it's a pre-release (contains alpha, beta, rc)
@@ -45,16 +47,21 @@ jobs:
4547
4648 - name : Check version matches composer.json
4749 run : |
48- COMPOSER_VERSION=$(php -r "echo json_decode(file_get_contents('composer.json'))->version;")
49- if [ "${{ steps.version.outputs.version }}" != "$COMPOSER_VERSION" ]; then
50+ COMPOSER_VERSION=$(php -r '$composer = json_decode(file_get_contents("composer.json")); echo $composer->version ?? "";')
51+
52+ # Libraries published through Packagist usually derive the package
53+ # version from the Git tag. composer.json intentionally omits
54+ # "version" as of v3.4.1, so only enforce this check when a version
55+ # field is explicitly present.
56+ if [ -n "$COMPOSER_VERSION" ] && [ "${{ steps.version.outputs.version }}" != "$COMPOSER_VERSION" ]; then
5057 echo "Version mismatch: tag ${{ steps.version.outputs.version }} != composer.json $COMPOSER_VERSION"
5158 exit 1
5259 fi
5360
5461 test-before-release :
5562 runs-on : ubuntu-latest
5663 needs : validate-tag
57- if : startsWith(github.ref, 'refs/tags/v ')
64+ if : startsWith(github.ref, 'refs/tags/')
5865
5966 steps :
6067 - name : Checkout code
6471 uses : shivammathur/setup-php@v2
6572 with :
6673 php-version : ' 8.3'
67- extensions : curl, mbstring, json, openssl, gd
74+ extensions : curl, mbstring, json, openssl, gd, pcntl, xml, dom, simplexml, tokenizer, intl
6875 coverage : none
6976 tools : composer:v2
7077
@@ -73,11 +80,13 @@ jobs:
7380
7481 - name : Run full test suite
7582 run : composer check
83+ env :
84+ NO_NETWORK : 1
7685
7786 create-release :
7887 runs-on : ubuntu-latest
7988 needs : [validate-tag, test-before-release]
80- if : startsWith(github.ref, 'refs/tags/v ')
89+ if : startsWith(github.ref, 'refs/tags/')
8190
8291 steps :
8392 - name : Checkout code
8998 uses : shivammathur/setup-php@v2
9099 with :
91100 php-version : ' 8.3'
92- extensions : curl, mbstring, json, openssl, gd
101+ extensions : curl, mbstring, json, openssl, gd, pcntl, xml, dom, simplexml, tokenizer, intl
93102 tools : composer:v2
94103
95104 - name : Install dependencies
@@ -129,11 +138,11 @@ jobs:
129138 packagist-webhook :
130139 runs-on : ubuntu-latest
131140 needs : [validate-tag, create-release]
132- if : startsWith(github.ref, 'refs/tags/v ') && needs.validate-tag.outputs.is_prerelease == 'false'
141+ if : startsWith(github.ref, 'refs/tags/') && needs.validate-tag.outputs.is_prerelease == 'false'
133142
134143 steps :
135144 - name : Update Packagist
136145 run : |
137146 curl -XPOST -H'content-type:application/json' \
138147 "https://packagist.org/api/update-package?username=${{ secrets.PACKAGIST_USERNAME }}&apiToken=${{ secrets.PACKAGIST_TOKEN }}" \
139- -d'{"repository":{"url":"https://github.com/${{ github.repository }}"}}'
148+ -d'{"repository":{"url":"https://github.com/${{ github.repository }}"}}'
0 commit comments