Skip to content

chore: add versioning support and release workflow #11

chore: add versioning support and release workflow

chore: add versioning support and release workflow #11

Workflow file for this run

name: Release
on:
push:
branches:
- main
paths:
- 'src/version.h'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Get Last Tag
run: |
LAST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1) || echo "0.0.0")
echo "LAST_TAG=$LAST_TAG" >> $GITHUB_ENV
- name: Get Version from version.h
run: |
MAJOR=$(grep '#define RELEASE_VER_MAIN' src/version.h | awk '{print $3}')
MINOR=$(grep '#define RELEASE_VER_SUB' src/version.h | awk '{print $3}')
PATCH=$(grep '#define RELEASE_VER_FIX' src/version.h | awk '{print $3}')
VERSION="$MAJOR.$MINOR.$PATCH"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Create Tag
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "${{ env.VERSION }}" -m "${{ env.VERSION }}"
- name: Generate Release Notes
run: |
chmod +x .github/workflows/genReleaseNote.sh
.github/workflows/genReleaseNote.sh -v ${{ env.LAST_TAG }}...${{ env.VERSION }}
- name: Get Latest Workflow Run
id: workflow
run: |
RUN_ID=$(gh api repos/${{ github.repository }}/actions/workflows/build.yml/runs \
--jq '.workflow_runs[0].id')
echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
path: build_artifacts
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ steps.workflow.outputs.run_id }}
- name: Prepare Release Files
run: |
for arch in x86 x64 arm64; do
mv build_artifacts/setdll-$arch/setdll.exe build_artifacts/setdll-$arch.exe
rm -rf build_artifacts/setdll-$arch
done
cp injectpe.bat build_artifacts/
cp README.md build_artifacts/
- name: Create Archive
run: |
cd build_artifacts
7z a -mx=9 -ms=on -m0=lzma2 -mmt=on setdll-${{ env.VERSION }}.7z *
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.VERSION }}
name: ${{ env.VERSION }}
body_path: release.md
files: build_artifacts/setdll-${{ env.VERSION }}.7z
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}