Repository navigation
72 lines (63 loc) · 2.1 KB
/
Copy pathrelease.yml
File metadata and controls
72 lines (63 loc) · 2.1 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
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Existing tag to release (e.g. v0.1.0)'
required: true
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
verify:
name: verify
uses: ./.github/workflows/ci.yml
release:
name: github release
needs: verify
runs-on: ubuntu-latest
# Packagist normally auto-updates via its GitHub integration. The notify step
# below is a manual fallback and only runs when these secrets are configured.
env:
PACKAGIST_USERNAME: ${{ secrets.PACKAGIST_USERNAME }}
PACKAGIST_TOKEN: ${{ secrets.PACKAGIST_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve tag
id: tag
run: |
TAG="${{ github.event.inputs.tag || github.ref_name }}"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
- name: Extract changelog notes
run: |
awk -v ver="${{ steps.tag.outputs.version }}" '
$0 ~ "^## \\[" ver "\\]" { grab = 1; next }
grab && /^## \[/ { exit }
grab { print }
' CHANGELOG.md > release-notes.md
if [ ! -s release-notes.md ]; then
echo "See [CHANGELOG.md](CHANGELOG.md) for details." > release-notes.md
fi
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${{ steps.tag.outputs.tag }}" \
--title "${{ steps.tag.outputs.tag }}" \
--notes-file release-notes.md \
--verify-tag
- name: Notify Packagist (optional)
if: ${{ env.PACKAGIST_TOKEN != '' }}
continue-on-error: true
run: |
curl -sf -X POST -H 'Content-Type: application/json' \
"https://packagist.org/api/update-package?username=${PACKAGIST_USERNAME}&apiToken=${PACKAGIST_TOKEN}" \
-d '{"repository":{"url":"https://packagist.org/packages/getpayin/paylink"}}'