Repository navigation
69 lines (56 loc) · 1.78 KB
/
Copy pathgithub-release.yml
File metadata and controls
69 lines (56 loc) · 1.78 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: Create GitHub Release from Tag
on:
push:
tags:
- "v*"
permissions:
contents: write
concurrency:
group: github-release-${{ github.ref }}
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
ref: ${{ github.sha }}
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: 22.22.1
- name: Verify tag matches package.json version
id: version
env:
TAG_NAME: ${{ github.ref_name }}
run: |
set -euo pipefail
PKG_VERSION=$(node -p "require('./package.json').version")
EXPECTED_TAG="v${PKG_VERSION}"
if [[ "${TAG_NAME}" != "${EXPECTED_TAG}" ]]; then
echo "Tag ${TAG_NAME} does not match package.json version ${PKG_VERSION} (expected ${EXPECTED_TAG})."
exit 1
fi
echo "tag_name=${TAG_NAME}" >> "$GITHUB_OUTPUT"
echo "pkg_version=${PKG_VERSION}" >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: ${{ steps.version.outputs.tag_name }}
PKG_VERSION: ${{ steps.version.outputs.pkg_version }}
run: |
set -euo pipefail
if gh release view "${TAG_NAME}" >/dev/null 2>&1; then
echo "Release ${TAG_NAME} already exists; skipping creation."
exit 0
fi
PRERELEASE_FLAG=()
if [[ "${PKG_VERSION}" == *"-"* ]]; then
PRERELEASE_FLAG=(--prerelease)
fi
gh release create "${TAG_NAME}" \
--title "${TAG_NAME}" \
--generate-notes \
"${PRERELEASE_FLAG[@]}"