From c8a392193cecc649f1813552147ce7fc5681ab0a Mon Sep 17 00:00:00 2001 From: Andreas Herrmann Date: Tue, 21 Nov 2023 22:59:31 +0100 Subject: [PATCH 1/4] append a newline to the generated file --- util/update_zig_versions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/update_zig_versions.py b/util/update_zig_versions.py index 4fd1aa82..6c619433 100755 --- a/util/update_zig_versions.py +++ b/util/update_zig_versions.py @@ -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) From 9247f49d8e5a0a35f5cf52f2e34ebf66f524cfcd Mon Sep 17 00:00:00 2001 From: Andreas Herrmann Date: Tue, 21 Nov 2023 22:59:02 +0100 Subject: [PATCH 2/4] automatic Zig update GH actions workflow --- .github/workflows/zig_update.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/zig_update.yaml diff --git a/.github/workflows/zig_update.yaml b/.github/workflows/zig_update.yaml new file mode 100644 index 00000000..d4e49861 --- /dev/null +++ b/.github/workflows/zig_update.yaml @@ -0,0 +1,24 @@ +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: | + 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 + git commit -m 'update Zig versions' + gh pr create \ + --title "chore: update Zig versions up to $NEW_VERSION" \ + --body "- [ ] Manually update references to the latest Zig version." + } From 514d8734893853a0e8294ee627f12183e2562c82 Mon Sep 17 00:00:00 2001 From: Andreas Herrmann Date: Wed, 22 Nov 2023 08:17:18 +0100 Subject: [PATCH 3/4] make Zig code links version independent --- zig/private/common/filetypes.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zig/private/common/filetypes.bzl b/zig/private/common/filetypes.bzl index b581ef8c..86679de3 100644 --- a/zig/private/common/filetypes.bzl +++ b/zig/private/common/filetypes.bzl @@ -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", From 7712a74b73cb22cd27380c05c0f8b18c145a6a21 Mon Sep 17 00:00:00 2001 From: Andreas Herrmann Date: Wed, 22 Nov 2023 08:30:22 +0100 Subject: [PATCH 4/4] Automatically replace the old version in code --- .github/workflows/zig_update.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/zig_update.yaml b/.github/workflows/zig_update.yaml index d4e49861..13d2dbf2 100644 --- a/.github/workflows/zig_update.yaml +++ b/.github/workflows/zig_update.yaml @@ -13,12 +13,16 @@ jobs: 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 "- [ ] Manually update references to the latest Zig version." + --body "- [ ] Check that the automatic version replacements make sense." }