Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 11 additions & 32 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ name: Release

on:
push:
tags:
- 'v*'
branches: [main]

permissions:
contents: write
Expand All @@ -13,41 +12,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Extract version from tag
- name: Generate version
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"

- name: Verify version matches source
run: |
src_version=$(grep '#define NVFD_VERSION' include/nvfd.h | cut -d'"' -f2)
if [ "$src_version" != "${{ steps.version.outputs.version }}" ]; then
echo "ERROR: Tag ${{ github.ref_name }} does not match NVFD_VERSION \"$src_version\" in include/nvfd.h"
exit 1
fi

- name: Generate release notes
id: notes
run: |
prev_tag=$(git tag --sort=-v:refname | sed -n '2p')
if [ -n "$prev_tag" ]; then
echo "## Changes since $prev_tag" > notes.md
echo "" >> notes.md
git log "$prev_tag"..HEAD --pretty=format:"- %s" --no-merges >> notes.md
else
echo "## Initial release" > notes.md
fi
echo "" >> notes.md
echo "## Installation" >> notes.md
echo '```bash' >> notes.md
echo "git clone https://github.com/${{ github.repository }}.git" >> notes.md
echo "cd nvfd" >> notes.md
echo "sudo scripts/install.sh" >> notes.md
echo '```' >> notes.md
timestamp=$(date -u +%Y%m%d-%H%M%S)
echo "tag=v${src_version}-${timestamp}" >> "$GITHUB_OUTPUT"
echo "name=Release v${src_version}-${timestamp}" >> "$GITHUB_OUTPUT"

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: NVFD v${{ steps.version.outputs.version }}
body_path: notes.md
generate_release_notes: false
tag_name: ${{ steps.version.outputs.tag }}
name: ${{ steps.version.outputs.name }}
body: "Automated release for commit ${{ github.sha }}"
make_latest: "true"