Repository navigation
51 lines (45 loc) · 1.76 KB
/
Copy pathrelease.yml
File metadata and controls
51 lines (45 loc) · 1.76 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
name: Release
# When a version tag is pushed: create a GitHub Release with auto-generated
# notes. Packagist auto-syncs from the GitHub webhook on tag push, so there
# is no separate "publish to Packagist" step. The optional Packagist-API
# notify step runs only when PACKAGIST_USER / PACKAGIST_TOKEN secrets are
# configured, useful as a belt-and-braces force-refresh.
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+'
# One publish per ref at a time. GitHub can deliver a tag push more than once;
# without this, two runs race and the registry rejects the loser as a duplicate
# coordinate (seen on the v0.2.0 Maven Central release).
concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: write
jobs:
release:
name: GitHub Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: ${{ github.ref_name }}
generate_release_notes: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Notify Packagist (optional)
env:
PACKAGIST_USER: ${{ secrets.PACKAGIST_USER }}
PACKAGIST_TOKEN: ${{ secrets.PACKAGIST_TOKEN }}
run: |
if [ -z "$PACKAGIST_USER" ] || [ -z "$PACKAGIST_TOKEN" ]; then
echo "Packagist credentials not configured — skipping (the webhook handles updates)."
exit 0
fi
curl -fXPOST -H 'content-type:application/json' \
"https://packagist.org/api/update-package?username=$PACKAGIST_USER&apiToken=$PACKAGIST_TOKEN" \
-d "{\"repository\":{\"url\":\"https://github.com/${GITHUB_REPOSITORY}\"}}"