Skip to content

More workflow edits #17

More workflow edits

More workflow edits #17

name: Build and Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name for the release'
required: true
default: 'v0.0.1'
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Make compile script and compiler executable
run: |
chmod +x compile.sh
chmod +x spcomp spcomp64
- name: Compile plugin
run: ./compile.sh offstyledb.sp
- name: Check if compiled file exists
run: |
if [ ! -f "./compiled/offstyledb.smx" ]; then
echo "Error: Compiled plugin not found!"
exit 1
fi
ls -la compiled/
- name: Get tag name
id: get_tag
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "tag_name=${{ github.event.inputs.tag_name }}" >> $GITHUB_OUTPUT
else
echo "tag_name=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
fi
- name: Generate changelog
id: changelog
run: |
current_tag=${{ steps.get_tag.outputs.tag_name }}
previous_tag=$(git tag --sort=-version:refname | head -n 2 | tail -n 1 || echo "")
if [ -n "$previous_tag" ]; then
commits=$(git log --oneline $previous_tag..$current_tag)
body="Automated release of Offstyle Database plugin
## Changes
$commits
## Installation
1. Download \`offstyledb.smx\`
2. Upload to your SourceMod plugins directory
3. Restart your server or use \`sm plugins reload offstyledb\`"
else
body="Automated release of Offstyle Database plugin
## Changes
- Initial release
## Installation
1. Download \`offstyledb.smx\`
2. Upload to your SourceMod plugins directory
3. Restart your server or use \`sm plugins reload offstyledb\`"
fi
echo "body<<EOF" >> $GITHUB_OUTPUT
echo "$body" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.get_tag.outputs.tag_name }}
name: Release ${{ steps.get_tag.outputs.tag_name }}
body: ${{ steps.changelog.outputs.body }}
files: ./compiled/offstyledb.smx
draft: false
prerelease: false