Skip to content

Commit

Permalink
Merge pull request #107 from aherrmann/zig-auto-update
Browse files Browse the repository at this point in the history
chore: automatically update Zig versions
  • Loading branch information
aherrmann authored Nov 22, 2023
2 parents 41307e7 + 7712a74 commit 6bd479b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/zig_update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Zig Update

on:
schedule:
- cron: 0 0 * * 1
workflow_dispatch:

jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Update
run: |
OLD_VERSION="$(grep -m 1 -oP '^\s+"\K\d+\.\d+\.\d+(?=":)' zig/private/versions.bzl)"
bazel run //util:update_zig_versions
[ -z "$(git status --porcelain=v1 zig/private/versions.bzl 2>/dev/null)" ] || {
NEW_VERSION="$(grep -m 1 -oP '^\s+"\K\d+\.\d+\.\d+(?=":)' zig/private/versions.bzl)"
git add zig/private/versions.bzl
readarray -t FILES < <(git grep -l -F "$OLD_VERSION" -- ':(exclude)zig/private/versions.bzl')
sed -i "s/${OLD_VERSION//./\\.}/$NEW_VERSION/g" "${FILES[@]}"
git add "${FILES[@]}"
git commit -m 'update Zig versions'
gh pr create \
--title "chore: update Zig versions up to $NEW_VERSION" \
--body "- [ ] Check that the automatic version replacements make sense."
}
2 changes: 1 addition & 1 deletion util/update_zig_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def generate_bzl_content(url, data, unsupported_versions, supported_platforms):

content.append(' },')

content.append('}')
content.append('}\n')

return '\n'.join(content)

Expand Down
4 changes: 2 additions & 2 deletions zig/private/common/filetypes.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
ZIG_SOURCE_EXTENSIONS = [".zig"]

# Based on the file-type classification in the Zig compiler
# https://github.com/ziglang/zig/blob/0.10.1/src/Compilation.zig#L4679-L4709
# https://github.com/ziglang/zig/blob/b57081f039bd3f8f82210e8896e336e3c3a6869b/src/Compilation.zig#L4679-L4709
# And which of these files are treated as C sources
# https://github.com/ziglang/zig/blob/0.10.1/src/main.zig#L1349-L1354
# https://github.com/ziglang/zig/blob/b57081f039bd3f8f82210e8896e336e3c3a6869b/src/main.zig#L1349-L1354
ZIG_C_SOURCE_EXTENSIONS = [
# .assembly
".s",
Expand Down

0 comments on commit 6bd479b

Please sign in to comment.