-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (61 loc) · 1.95 KB
/
release.yml
File metadata and controls
72 lines (61 loc) · 1.95 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: Create Release
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
on:
push:
branches:
- main
paths:
- VERSION
workflow_dispatch:
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Read release version
id: version
run: |
version="$(tr -d '[:space:]' < VERSION)"
version="${version#v}"
if ! printf '%s' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$'; then
echo "VERSION must contain a semantic version like 1.2.3 or 1.2.3-beta.1"
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "tag=v$version" >> "$GITHUB_OUTPUT"
- name: Check whether the release already exists
id: existing
env:
GH_TOKEN: ${{ github.token }}
run: |
if gh release view "${{ steps.version.outputs.tag }}" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Create GitHub release
if: steps.existing.outputs.exists != 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
for attempt in 1 2 3; do
if gh release create "${{ steps.version.outputs.tag }}" \
--repo "$GITHUB_REPOSITORY" \
--target "$GITHUB_SHA" \
--title "TPS ${{ steps.version.outputs.tag }}" \
--generate-notes; then
exit 0
fi
if [ "$attempt" -eq 3 ]; then
echo "Failed to create GitHub release after $attempt attempts."
exit 1
fi
echo "Release creation failed on attempt $attempt. Retrying..."
sleep 5
done