-
-
Notifications
You must be signed in to change notification settings - Fork 52
58 lines (50 loc) · 1.36 KB
/
release.yml
File metadata and controls
58 lines (50 loc) · 1.36 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
name: Release
on:
push:
tags:
- 'v*.*.*'
permissions:
contents: write
jobs:
tests:
uses: ./.github/workflows/tests.yml
secrets: inherit
release:
needs: tests
runs-on: ubuntu-latest
steps:
- name: Determine release flags
id: flags
env:
TAG: ${{ github.ref_name }}
run: |
if [[ "$TAG" == *"-"* ]]; then
echo "prerelease=--prerelease" >> "$GITHUB_OUTPUT"
else
echo "prerelease=" >> "$GITHUB_OUTPUT"
fi
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
TAG: ${{ github.ref_name }}
PRERELEASE_FLAG: ${{ steps.flags.outputs.prerelease }}
run: |
if gh release view "$TAG" >/dev/null 2>&1; then
echo "Release $TAG already exists, skipping creation."
exit 0
fi
gh release create "$TAG" --generate-notes $PRERELEASE_FLAG
cleanup:
needs: tests
if: failure()
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Delete tag on test failure
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
TAG: ${{ github.ref_name }}
run: gh api -X DELETE "repos/$GH_REPO/git/refs/tags/$TAG"