diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..6cd94b7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,67 @@ +name: Build and Release + +on: + push: + branches: [ main ] + tags: [ '*' ] + pull_request: + branches: [ main ] + workflow_dispatch: + +jobs: + build: + name: Build + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Full history so 'git rev-parse HEAD' gets the correct commit + + - name: Setup Zig + uses: mlugg/setup-zig@v1 + with: + version: 0.15.2 + + - name: Build Linux + run: zig build -Dtarget=x86_64-linux-gnu -Doptimize=ReleaseSafe + + - name: Package Linux + run: | + mv zig-out/bin/flint flint-linux-x86_64 + tar -czvf flint-linux-x86_64.tar.gz flint-linux-x86_64 + + - name: Build Windows + run: | + # Clean first in case of output conflicts + rm -rf zig-out zig-cache + zig build -Dtarget=x86_64-windows-gnu -Doptimize=ReleaseSafe + + - name: Package Windows + run: | + mv zig-out/bin/flint.exe flint-windows-x86_64.exe + zip flint-windows-x86_64.zip flint-windows-x86_64.exe + + - name: Upload Linux Artifact + uses: actions/upload-artifact@v4 + with: + name: flint-linux-x86_64.tar.gz + path: flint-linux-x86_64.tar.gz + + - name: Upload Windows Artifact + uses: actions/upload-artifact@v4 + with: + name: flint-windows-x86_64.zip + path: flint-windows-x86_64.zip + + - name: Publish Release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + flint-linux-x86_64.tar.gz + flint-windows-x86_64.zip + generate_release_notes: true