Node 20 actions are deprecated and forced onto Node 24 with warnings on every job. Bump actions/checkout v4->v7, actions/upload-artifact v4->v7 and softprops/action-gh-release v2->v3; none of these workflows use inputs whose behavior changed. download-artifact, setup-emsdk and freebsd-vm already run current runtimes.
203 lines
7.0 KiB
YAML
203 lines
7.0 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
tags:
|
|
- "v*"
|
|
paths:
|
|
- "include/kryon_version.h"
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: "Release version, for example v0.1.0"
|
|
required: true
|
|
type: string
|
|
prerelease:
|
|
description: "Mark the GitHub release as a prerelease"
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
create-tag:
|
|
name: Create Release Tag
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/heads/')
|
|
outputs:
|
|
tag: ${{ steps.version.outputs.tag }}
|
|
|
|
steps:
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v7
|
|
with:
|
|
fetch-depth: 0
|
|
submodules: recursive
|
|
|
|
- name: Resolve Version
|
|
id: version
|
|
run: |
|
|
set -euo pipefail
|
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
tag="${{ inputs.version }}"
|
|
else
|
|
tag="$(sed -n 's/^#define KRYON_VERSION_STRING "\([^"]*\)".*/\1/p' include/kryon_version.h)"
|
|
fi
|
|
case "$tag" in
|
|
v[0-9]*.[0-9]*.[0-9]*) ;;
|
|
*) echo "Version must look like v0.1.0" >&2; exit 1 ;;
|
|
esac
|
|
header_tag="$(sed -n 's/^#define KRYON_VERSION_STRING "\([^"]*\)".*/\1/p' include/kryon_version.h)"
|
|
if [ "$tag" != "$header_tag" ]; then
|
|
echo "Requested $tag but include/kryon_version.h contains $header_tag" >&2
|
|
exit 1
|
|
fi
|
|
if git rev-parse -q --verify "refs/tags/$tag" >/dev/null; then
|
|
echo "Tag $tag already exists; nothing to release."
|
|
echo "tag=" >> "$GITHUB_OUTPUT"
|
|
exit 0
|
|
fi
|
|
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Ensure CHANGELOG Entry
|
|
if: steps.version.outputs.tag != ''
|
|
run: |
|
|
set -euo pipefail
|
|
tag="${{ steps.version.outputs.tag }}"
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
|
|
# If the entry already exists (hand-written by a maintainer), use it as-is.
|
|
if grep -q "^## $tag " CHANGELOG.md; then
|
|
echo "CHANGELOG entry for $tag already present."
|
|
exit 0
|
|
fi
|
|
|
|
# Otherwise generate one from commits since the most recent tag.
|
|
prev_tag="$(git describe --tags --abbrev=0 2>/dev/null || true)"
|
|
date="$(date +%Y-%m-%d)"
|
|
range="${prev_tag:+$prev_tag..}HEAD"
|
|
range="${range:-HEAD}"
|
|
|
|
{
|
|
printf '## %s - %s\n\n' "$tag" "$date"
|
|
printf '### Changed\n\n'
|
|
git log "$range" --no-merges --pretty=format:'- %s' \
|
|
| sed -E 's/^- ([a-z])/- \u\1/'
|
|
printf '\n\n'
|
|
} > /tmp/new_entry.md
|
|
|
|
# Insert the generated block immediately after the "# Changelog" heading.
|
|
cp CHANGELOG.md CHANGELOG.md.bak
|
|
awk -v entry=/tmp/new_entry.md '
|
|
FNR==1 && /^# Changelog/ {
|
|
print
|
|
while ((getline line < entry) > 0) print line
|
|
next
|
|
}
|
|
{ print }
|
|
' CHANGELOG.md.bak > CHANGELOG.md
|
|
rm -f CHANGELOG.md.bak
|
|
|
|
git add CHANGELOG.md
|
|
git commit -m "Update CHANGELOG for $tag" || echo "No CHANGELOG changes to commit."
|
|
git push origin "HEAD:${GITHUB_REF_NAME}"
|
|
|
|
- name: Create And Push Tag
|
|
if: steps.version.outputs.tag != ''
|
|
run: |
|
|
set -euo pipefail
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git tag -a "${{ steps.version.outputs.tag }}" -m "Release ${{ steps.version.outputs.tag }}"
|
|
git push origin "${{ steps.version.outputs.tag }}"
|
|
|
|
build-release:
|
|
name: Build Release Artifacts
|
|
runs-on: ubuntu-latest
|
|
needs: create-tag
|
|
if: always() && (startsWith(github.ref, 'refs/tags/') || needs.create-tag.outputs.tag != '')
|
|
|
|
steps:
|
|
- name: Resolve Tag
|
|
id: ref
|
|
run: |
|
|
set -euo pipefail
|
|
if [ -n "${{ needs.create-tag.outputs.tag }}" ]; then
|
|
tag="${{ needs.create-tag.outputs.tag }}"
|
|
else
|
|
tag="${GITHUB_REF_NAME}"
|
|
fi
|
|
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v7
|
|
with:
|
|
ref: ${{ steps.ref.outputs.tag }}
|
|
submodules: recursive
|
|
fetch-depth: 0
|
|
|
|
- name: Install Packages
|
|
run: |
|
|
set -euo pipefail
|
|
sudo apt-get update
|
|
sudo apt-get install -y build-essential cmake libssl-dev pkg-config zlib1g-dev libzstd-dev libbrotli-dev libglib2.0-dev libgtk-3-dev libsdl2-dev libdrm-dev libgbm-dev libegl1-mesa-dev libgles2-mesa-dev
|
|
|
|
- name: Build And Test
|
|
run: |
|
|
set -euo pipefail
|
|
make clean CMAKE=/usr/bin/cmake
|
|
make all CMAKE=/usr/bin/cmake
|
|
make test CMAKE=/usr/bin/cmake
|
|
|
|
- name: Package Static Library
|
|
run: |
|
|
set -euo pipefail
|
|
make dist-static CMAKE=/usr/bin/cmake VERSION="${{ steps.ref.outputs.tag }}"
|
|
make check-static-package CMAKE=/usr/bin/cmake VERSION="${{ steps.ref.outputs.tag }}"
|
|
archive="$(find dist -maxdepth 1 -type f -name kryon-*-static.tar.gz | head -n 1)"
|
|
test -n "$archive"
|
|
echo "KRYON_STATIC_ARCHIVE=$archive" >> "$GITHUB_ENV"
|
|
|
|
- name: Package Every Kryon Tool
|
|
run: |
|
|
set -euo pipefail
|
|
make dist-tools CMAKE=/usr/bin/cmake VERSION="${{ steps.ref.outputs.tag }}"
|
|
make check-tools-package CMAKE=/usr/bin/cmake VERSION="${{ steps.ref.outputs.tag }}"
|
|
archive="$(find dist -maxdepth 1 -type f -name 'kryon-*-tools-*.tar.gz' | head -n 1)"
|
|
test -n "$archive"
|
|
echo "KRYON_TOOLS_ARCHIVE=$archive" >> "$GITHUB_ENV"
|
|
|
|
- name: Write Checksums
|
|
run: |
|
|
sha256sum "$KRYON_STATIC_ARCHIVE" "$KRYON_TOOLS_ARCHIVE" > SHA256SUMS
|
|
|
|
- name: Upload Static Library Artifact
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: kryon-static-library-${{ steps.ref.outputs.tag }}
|
|
path: ${{ env.KRYON_STATIC_ARCHIVE }}
|
|
if-no-files-found: error
|
|
|
|
- name: Upload Tools Artifact
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: kryon-tools-${{ steps.ref.outputs.tag }}
|
|
path: ${{ env.KRYON_TOOLS_ARCHIVE }}
|
|
if-no-files-found: error
|
|
|
|
- name: Publish GitHub Release
|
|
uses: softprops/action-gh-release@v3
|
|
with:
|
|
tag_name: ${{ steps.ref.outputs.tag }}
|
|
name: Kryon ${{ steps.ref.outputs.tag }}
|
|
prerelease: ${{ github.event_name == 'workflow_dispatch' && inputs.prerelease || false }}
|
|
files: |
|
|
${{ env.KRYON_STATIC_ARCHIVE }}
|
|
${{ env.KRYON_TOOLS_ARCHIVE }}
|
|
SHA256SUMS
|