Add Git tagging step to build workflow for automated versioning #22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release GhostInjector | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| pull_request: | |
| branches: [ main, master ] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-and-release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y mingw-w64 | |
| - name: Configure CMake | |
| run: | | |
| cmake -B build -DCMAKE_TOOLCHAIN_FILE=toolchain-mingw.cmake -DCMAKE_BUILD_TYPE=Release | |
| - name: Build | |
| run: cmake --build build | |
| - name: Strip executable | |
| run: x86_64-w64-mingw32-strip build/ghostinjector-*.exe | |
| - name: Rename executable | |
| run: mv build/ghostinjector-*.exe build/ghostinjector.exe | |
| - name: Create Git Tag with Commit Message | |
| if: (github.ref == 'refs/heads/main' && github.event_name == 'push') || startsWith(github.ref, 'refs/tags/v') | |
| run: | | |
| TAG_NAME="${{ (github.ref == 'refs/heads/main' && 'latest') || github.ref_name }}" | |
| COMMIT_MSG=$(git log -1 --pretty=%B) | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@github.com" | |
| git tag -a "$TAG_NAME" -m "$COMMIT_MSG" -f | |
| git push origin "$TAG_NAME" -f | |
| - name: Create Release | |
| if: (github.ref == 'refs/heads/main' && github.event_name == 'push') || startsWith(github.ref, 'refs/tags/v') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ (github.ref == 'refs/heads/main' && 'latest') || github.ref_name }} | |
| name: ${{ (github.ref == 'refs/heads/main' && 'Latest Build (Development)') || github.ref_name }} | |
| body: | | |
| ## 🚀 Latest Development Build | |
| **Commit:** ${{ github.sha }} | |
| ### 📥 Download | |
| - **Windows:** `ghostinjector.exe` | |
| files: build/ghostinjector.exe | |
| draft: false | |
| prerelease: ${{ github.ref == 'refs/heads/main' }} | |
| make_latest: ${{ github.ref == 'refs/heads/main' }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |