Files
action-server-install/.github/workflows/release.yml
2026-02-14 16:28:51 -05:00

60 lines
1.8 KiB
YAML

name: Release
on:
push:
tags:
- 'v*'
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Extract changelog
id: changelog
run: |
VERSION=${{ steps.version.outputs.version }}
# Extract the changelog section for this version
CHANGELOG=$(sed -n "/## \[$VERSION\]/,/## \[/p" CHANGELOG.md | sed '$d')
# Use a delimiter to handle multiline
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.tag }}
release_name: Release ${{ steps.version.outputs.tag }}
body: ${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false
- name: Update major version tag
run: |
VERSION=${{ steps.version.outputs.version }}
MAJOR_VERSION=$(echo $VERSION | cut -d. -f1)
git config user.name github-actions
git config user.email github-actions@github.com
# Force update the major version tag
git tag -fa "v$MAJOR_VERSION" -m "Update v$MAJOR_VERSION to $VERSION"
git push origin "v$MAJOR_VERSION" --force