Skip to content

Commit

Permalink
fix: using argsWithAlloc for windows support and
Browse files Browse the repository at this point in the history
added release.yml for automated builds and releases
  • Loading branch information
vaibhavsijaria committed Oct 1, 2024
1 parent a95cc7b commit 109a2b7
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 3 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Build and Release

on:
push:
tags:
- 'v*.*.*'

jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
artifact_name: ziglox-linux-amd64
- os: windows-latest
artifact_name: ziglox-windows-amd64.exe
- os: macos-latest
artifact_name: ziglox-macos-amd64

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Zig Compiler
uses: mlugg/[email protected]

- name: Build
run: zig build -Doptimize=ReleaseSafe

- name: Rename binary
shell: bash
run: |
if [ "${{ matrix.os }}" == "windows-latest" ]; then
mv zig-out/bin/ziglox.exe zig-out/bin/${{ matrix.artifact_name }}
else
mv zig-out/bin/ziglox zig-out/bin/${{ matrix.artifact_name }}
fi
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: zig-out/bin/${{ matrix.artifact_name }}
if-no-files-found: error

release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: release-assets
merge-multiple: true

- name: Move artifacts to root of release-assets
run: |
find release-assets -type f -exec mv {} release-assets/ \;
find release-assets -type d -empty -delete
- name: Generate SHA256 checksums
run: |
cd release-assets
sha256sum * > SHA256SUMS.txt
- name: Create release notes
run: |
echo "## Ziglox ${{ github.ref_name }}" > release-notes.md
echo "" >> release-notes.md
echo "**SHA256 Checksums**:" >> release-notes.md
echo '```' >> release-notes.md
cat release-assets/SHA256SUMS.txt >> release-notes.md
echo '```' >> release-notes.md
- name: Create release
uses: ncipollo/[email protected]
with:
artifacts: "release-assets/*"
token: ${{ secrets.GITHUB_TOKEN }}
name: Release ${{ github.ref_name }}
bodyFile: release-notes.md
draft: false
prerelease: false
generateReleaseNotes: false
7 changes: 4 additions & 3 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ const runFile = run.runFile;
const runPrompt = run.runPrompt;

pub fn main() !void {
var args = std.process.args();
_ = args.next().?;

var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = arena.allocator();

var args = try std.process.argsWithAllocator(allocator);
defer args.deinit();
_ = args.next().?;

if (args.next()) |path| {
if (args.skip()) {
print("Usage: ziglox [script]\n", .{});
Expand Down
3 changes: 3 additions & 0 deletions src/run.zig
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
const std = @import("std");
const Printer = @import("tools/printers.zig");

const Scanner = @import("scanner.zig").Scanner;
const Parser = @import("parser.zig").Parser;
const Interpreter = @import("interpreter.zig").Interpreter;

const printTokens = Printer.printTokens;
const printObj = Printer.printObj;
const AstPrinter = Printer.AstPrinter;

const Allocator = std.mem.Allocator;
const fs = std.fs;
const print = std.debug.print;
Expand Down

0 comments on commit 109a2b7

Please sign in to comment.