-
Notifications
You must be signed in to change notification settings - Fork 12
69 lines (60 loc) · 1.67 KB
/
Copy pathgithub-release.yml
File metadata and controls
69 lines (60 loc) · 1.67 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
name: GitHub Release
on:
push:
branches:
- main
paths:
- RELEASE.md
- web/package.json
- .github/workflows/github-release.yml
workflow_dispatch:
inputs:
version:
description: "Release version tag, for example v1.0.0"
required: false
permissions:
contents: write
jobs:
publish:
name: Publish GitHub release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Resolve version
id: version
shell: bash
run: |
if [ -n "${{ inputs.version }}" ]; then
version="${{ inputs.version }}"
else
version="v$(node -p "require('./web/package.json').version")"
fi
if [[ ! "$version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version: $version" >&2
exit 1
fi
if ! git rev-parse -q --verify "refs/tags/$version" >/dev/null; then
echo "Tag does not exist: $version" >&2
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.version.outputs.version }}
shell: bash
run: |
if gh release view "$VERSION" >/dev/null 2>&1; then
gh release edit "$VERSION" \
--title "$VERSION" \
--notes-file RELEASE.md \
--latest
else
gh release create "$VERSION" \
--title "$VERSION" \
--notes-file RELEASE.md \
--latest
fi