-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (60 loc) · 2.35 KB
/
Copy pathrelease.yml
File metadata and controls
73 lines (60 loc) · 2.35 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
name: Release
# NOTE: this repo uses bare `v*` tags — not the `php-v*` pattern the other
# Cryptohopper SDK repos use. Reason: Packagist reads Git tags directly as the
# version string and only recognises tags matching SemVer (`X.Y.Z` or `vX.Y.Z`),
# not prefixed tags. Using `v*` here matches the Go SDK convention.
on:
push:
tags: ['v*']
permissions:
contents: write
jobs:
verify-and-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: none
tools: composer:v2
- name: Validate composer.json
run: composer validate --strict
- name: Install dependencies
run: composer install --no-interaction --no-progress --prefer-dist
- name: Tag parity check
run: |
TAG_NAME="${GITHUB_REF_NAME#v}"
FILE_VERSION=$(php -r "require 'src/Version.php'; echo Cryptohopper\Sdk\Version::VERSION;")
echo "Tag name strips to: ${TAG_NAME}"
echo "Version.php constant: ${FILE_VERSION}"
if [ "${TAG_NAME}" != "${FILE_VERSION}" ]; then
echo "Tag and Version.php disagree — aborting release."
exit 1
fi
- name: Run PHPUnit
run: composer test
- name: Determine prerelease flag
id: prerelease
run: |
if [[ "${GITHUB_REF_NAME}" =~ -(alpha|beta|rc) ]]; then
echo "prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "prerelease=false" >> "$GITHUB_OUTPUT"
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ github.ref_name }}
prerelease: ${{ steps.prerelease.outputs.prerelease }}
generate_release_notes: true
body: |
## Installation
```bash
composer require cryptohopper/sdk:${GITHUB_REF_NAME#v}
```
Packagist auto-syncs from this repo's tags. If the new version does not
appear on [packagist.org](https://packagist.org/packages/cryptohopper/sdk)
within a few minutes, trigger a manual update from the Packagist dashboard.
See [CHANGELOG.md](https://github.com/cryptohopper/cryptohopper-php-sdk/blob/main/CHANGELOG.md) for what changed.