[VOL-5495] Add publish/release actions for merge
Signed-off-by: Eric Ball <eball@linuxfoundation.org>
Change-Id: I05ef8897523e7c3d128767c3795b7e11f4b0169a
diff --git a/.github/actions/github-release-action/README.md b/.github/actions/github-release-action/README.md
new file mode 100644
index 0000000..db48efc
--- /dev/null
+++ b/.github/actions/github-release-action/README.md
@@ -0,0 +1,68 @@
+<!--
+SPDX-License-Identifier: Apache-2.0
+SPDX-FileCopyrightText: 2026 The Linux Foundation
+-->
+
+# GitHub Release Action
+
+A composite GitHub Action that creates GitHub releases with artifacts using the `gh` CLI tool.
+
+## Description
+
+Builds release artifacts via `make`, generates SHA256 checksums, and creates a GitHub release with all artifacts attached. Supports draft releases for pre-release versions.
+
+## Usage
+
+```yaml
+- uses: ./.github/actions/github-release-action
+ with:
+ github-token: ${{ secrets.GITHUB_TOKEN }}
+```
+
+### Inputs
+
+| Input | Description | Required | Default |
+|-------|-------------|----------|---------|
+| `release-targets` | Make targets to build release artifacts | No | `release` |
+| `artifact-glob` | Glob pattern for release artifacts | No | `release/*` |
+| `github-token` | GitHub token for authentication | Yes | — |
+| `draft` | Create a draft release | No | `false` |
+
+### Example Workflow
+
+```yaml
+name: Release
+on:
+ push:
+ tags:
+ - "v*"
+
+jobs:
+ release:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - uses: ./.github/actions/github-release-action
+ with:
+ github-token: ${{ secrets.GITHUB_TOKEN }}
+ release-targets: "build package"
+ artifact-glob: "dist/*"
+```
+
+## How It Works
+
+1. Finds a SemVer tag on HEAD (`vX.Y.Z`, `X.Y.Z`, or `vX.Y.Z-devN`)
+2. Builds release artifacts using `make <release-targets>`
+3. Generates SHA256 checksums for all matched artifacts
+4. Creates a GitHub release with artifacts and checksums attached
+5. Marks the release as draft if the tag contains `-dev` or `draft` input is `true`
+
+## Requirements
+
+- Repository must have a SemVer tag on the current commit
+- A `Makefile` with the specified release target(s)
+- `gh` CLI (pre-installed on GitHub Actions runners)
+- `GITHUB_TOKEN` with permissions to create releases
diff --git a/.github/actions/github-release-action/action.yaml b/.github/actions/github-release-action/action.yaml
new file mode 100644
index 0000000..5548106
--- /dev/null
+++ b/.github/actions/github-release-action/action.yaml
@@ -0,0 +1,80 @@
+---
+# SPDX-FileCopyrightText: 2026 The Linux Foundation
+# SPDX-License-Identifier: Apache-2.0
+
+name: "GitHub Release Action"
+description: "Creates GitHub releases with artifacts using the gh CLI tool"
+
+inputs:
+ release-targets:
+ description: "Make targets to build release artifacts"
+ required: false
+ default: "release"
+ artifact-glob:
+ description: "Glob pattern for release artifacts"
+ required: false
+ default: "release/*"
+ github-token:
+ description: "GitHub token for authentication"
+ required: true
+ draft:
+ description: "Create a draft release"
+ required: false
+ default: "false"
+
+runs:
+ using: "composite"
+ steps:
+ - name: Create GitHub Release
+ shell: bash
+ env:
+ GITHUB_TOKEN: ${{ inputs.github-token }}
+ RELEASE_TARGETS: ${{ inputs.release-targets }}
+ ARTIFACT_GLOB: ${{ inputs.artifact-glob }}
+ DRAFT_INPUT: ${{ inputs.draft }}
+ run: |
+ set -eu -o pipefail
+
+ # Determine version from git tags on HEAD
+ VERSION=""
+ for tag in $(git tag --points-at HEAD); do
+ if echo "$tag" | grep -qE '^v?[0-9]+\.[0-9]+\.[0-9]+(-dev[0-9]+)?$'; then
+ VERSION="$tag"
+ break
+ fi
+ done
+
+ if [ -z "$VERSION" ]; then
+ echo "ERROR: No SemVer tag (vX.Y.Z, X.Y.Z, or vX.Y.Z-devN) found on HEAD"
+ exit 1
+ fi
+
+ echo "Version: $VERSION"
+
+ # Build release artifacts
+ make $RELEASE_TARGETS
+
+ # Generate SHA256 checksums for all artifacts
+ CHECKSUM_FILE="checksums-sha256.txt"
+ sha256sum $ARTIFACT_GLOB > "$CHECKSUM_FILE"
+ echo "Generated checksums:"
+ cat "$CHECKSUM_FILE"
+
+ # Determine if this should be a draft release
+ DRAFT_FLAG=""
+ if [[ "$VERSION" == *"-dev"* ]] || [[ "$DRAFT_INPUT" == "true" ]]; then
+ DRAFT_FLAG="--draft"
+ echo "Creating draft release"
+ fi
+
+ # Get release notes from latest commit message
+ RELEASE_NOTES="$(git log -1 --pretty=%B)"
+
+ # Create GitHub release
+ gh release create "$VERSION" \
+ $ARTIFACT_GLOB \
+ "$CHECKSUM_FILE" \
+ --title "$VERSION" \
+ --notes "$RELEASE_NOTES" \
+ --generate-notes \
+ $DRAFT_FLAG