blob: 554810621e8c4f69362e6e438436607593c36b6e [file] [log] [blame]
Eric Ballb31722a2026-06-09 18:07:26 -07001---
2# SPDX-FileCopyrightText: 2026 The Linux Foundation
3# SPDX-License-Identifier: Apache-2.0
4
5name: "GitHub Release Action"
6description: "Creates GitHub releases with artifacts using the gh CLI tool"
7
8inputs:
9 release-targets:
10 description: "Make targets to build release artifacts"
11 required: false
12 default: "release"
13 artifact-glob:
14 description: "Glob pattern for release artifacts"
15 required: false
16 default: "release/*"
17 github-token:
18 description: "GitHub token for authentication"
19 required: true
20 draft:
21 description: "Create a draft release"
22 required: false
23 default: "false"
24
25runs:
26 using: "composite"
27 steps:
28 - name: Create GitHub Release
29 shell: bash
30 env:
31 GITHUB_TOKEN: ${{ inputs.github-token }}
32 RELEASE_TARGETS: ${{ inputs.release-targets }}
33 ARTIFACT_GLOB: ${{ inputs.artifact-glob }}
34 DRAFT_INPUT: ${{ inputs.draft }}
35 run: |
36 set -eu -o pipefail
37
38 # Determine version from git tags on HEAD
39 VERSION=""
40 for tag in $(git tag --points-at HEAD); do
41 if echo "$tag" | grep -qE '^v?[0-9]+\.[0-9]+\.[0-9]+(-dev[0-9]+)?$'; then
42 VERSION="$tag"
43 break
44 fi
45 done
46
47 if [ -z "$VERSION" ]; then
48 echo "ERROR: No SemVer tag (vX.Y.Z, X.Y.Z, or vX.Y.Z-devN) found on HEAD"
49 exit 1
50 fi
51
52 echo "Version: $VERSION"
53
54 # Build release artifacts
55 make $RELEASE_TARGETS
56
57 # Generate SHA256 checksums for all artifacts
58 CHECKSUM_FILE="checksums-sha256.txt"
59 sha256sum $ARTIFACT_GLOB > "$CHECKSUM_FILE"
60 echo "Generated checksums:"
61 cat "$CHECKSUM_FILE"
62
63 # Determine if this should be a draft release
64 DRAFT_FLAG=""
65 if [[ "$VERSION" == *"-dev"* ]] || [[ "$DRAFT_INPUT" == "true" ]]; then
66 DRAFT_FLAG="--draft"
67 echo "Creating draft release"
68 fi
69
70 # Get release notes from latest commit message
71 RELEASE_NOTES="$(git log -1 --pretty=%B)"
72
73 # Create GitHub release
74 gh release create "$VERSION" \
75 $ARTIFACT_GLOB \
76 "$CHECKSUM_FILE" \
77 --title "$VERSION" \
78 --notes "$RELEASE_NOTES" \
79 --generate-notes \
80 $DRAFT_FLAG