name: Publish Release on: push: branches: - main paths: - version.txt workflow_dispatch: jobs: build: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Read Version from version.txt id: read_version run: | VERSION=$(cat version.txt) echo "version=$VERSION" >> "$GITHUB_OUTPUT" echo "tag=v$VERSION" >> "$GITHUB_OUTPUT" echo "Version: $VERSION" - name: Extract Release Notes id: release_notes run: | VERSION=$(cat version.txt) # Extract release notes for this version # Find the section for this version and extract until the next version section RELEASE_NOTES=$(awk -v ver="$VERSION" ' /^## \[/ { if (found) exit if ($0 ~ "\\[" ver "\\]") found=1 else if (found) exit next } found && NF { print } ' RELEASENOTES.md | sed -e :a -e '/^$/N;$!ba' -e 's/^[[:space:]]*//;s/[[:space:]]*$//') # Escape newlines for GitHub output RELEASE_NOTES="${RELEASE_NOTES//'%'/'%25'}" RELEASE_NOTES="${RELEASE_NOTES//$'\n'/'%0A'}" RELEASE_NOTES="${RELEASE_NOTES//$'\r'/'%0D'}" echo "body=$RELEASE_NOTES" >> "$GITHUB_OUTPUT" - name: Compile Spearhead uses: https://git.dutchie031.com/dutchie031/DcsMissionScriptingTools/github-action@action/v0 with: source-root: ./src output-file: ./output/spearhead.lua - name: Check for existing tag id: check_tag run: | if git tag | grep -q "^${{ steps.read_version.outputs.tag }}$"; then echo "Tag already exists. Exiting." exit 1 fi - name: Apply Tag to Current Commit run: | git config user.name "github-actions" git config user.email "github-actions@github.com" git tag ${{ steps.read_version.outputs.tag }} git push origin ${{ steps.read_version.outputs.tag }} - name: Copy Release to Versioned File run: | cp ./output/spearhead.lua ./output/spearhead.${{ steps.read_version.outputs.tag }}.lua echo "Versioned file created: spearhead.${{ steps.read_version.outputs.tag }}.lua" - name: Create Release and Upload Assets uses: akkuman/gitea-release-action@v1 with: tag_name: ${{ steps.read_version.outputs.tag }} name: Release ${{ steps.read_version.outputs.tag }} body: ${{ steps.release_notes.outputs.body }} draft: true files: |- ./output/spearhead.lua ./output/spearhead.${{ steps.read_version.outputs.tag }}.lua #token: ${{ secrets.GITHUB_TOKEN }} env: NODE_OPTIONS: '--experimental-fetch'