From 6fe39442b27b8421b07a812f0df16a48d161cb9b Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Fri, 31 Jan 2025 11:47:31 -0500 Subject: [PATCH 1/6] add `timetzdata` build tag --- .github/workflows/release-nightly.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-nightly.yml b/.github/workflows/release-nightly.yml index 2264c9e822d1c..6a575e08f05b2 100644 --- a/.github/workflows/release-nightly.yml +++ b/.github/workflows/release-nightly.yml @@ -29,7 +29,7 @@ jobs: # xgo build - run: make release env: - TAGS: bindata sqlite sqlite_unlock_notify + TAGS: bindata timetzdata sqlite sqlite_unlock_notify - name: import gpg key id: import_gpg uses: crazy-max/ghaction-import-gpg@v6 From 4db5afc0171efcf207671878ca280575bb2a240f Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Fri, 31 Jan 2025 11:48:13 -0500 Subject: [PATCH 2/6] add `timetzdata` build tag --- .github/workflows/release-tag-rc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-tag-rc.yml b/.github/workflows/release-tag-rc.yml index a406602dc0a74..d86633beea5cc 100644 --- a/.github/workflows/release-tag-rc.yml +++ b/.github/workflows/release-tag-rc.yml @@ -30,7 +30,7 @@ jobs: # xgo build - run: make release env: - TAGS: bindata sqlite sqlite_unlock_notify + TAGS: bindata timetzdata sqlite sqlite_unlock_notify - name: import gpg key id: import_gpg uses: crazy-max/ghaction-import-gpg@v6 From 6aca0668c26a00c42a55463597195c2338fc2ff2 Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Fri, 31 Jan 2025 11:48:29 -0500 Subject: [PATCH 3/6] add `timetzdata` build tag --- .github/workflows/release-tag-version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-tag-version.yml b/.github/workflows/release-tag-version.yml index f67b76f40873b..8ccbf5cffbf06 100644 --- a/.github/workflows/release-tag-version.yml +++ b/.github/workflows/release-tag-version.yml @@ -32,7 +32,7 @@ jobs: # xgo build - run: make release env: - TAGS: bindata sqlite sqlite_unlock_notify + TAGS: bindata timetzdata sqlite sqlite_unlock_notify - name: import gpg key id: import_gpg uses: crazy-max/ghaction-import-gpg@v6 From de59d7779e0873654ba68926889f9f676b3e1ce1 Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Tue, 4 Feb 2025 15:22:00 -0500 Subject: [PATCH 4/6] import timezone data via import rather than tag --- .github/workflows/release-nightly.yml | 2 +- .github/workflows/release-tag-rc.yml | 2 +- .github/workflows/release-tag-version.yml | 2 +- modules/setting/timezones_freebsd.go | 6 ++++++ modules/setting/timezones_windows.go | 6 ++++++ 5 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 modules/setting/timezones_freebsd.go create mode 100644 modules/setting/timezones_windows.go diff --git a/.github/workflows/release-nightly.yml b/.github/workflows/release-nightly.yml index 6a575e08f05b2..2264c9e822d1c 100644 --- a/.github/workflows/release-nightly.yml +++ b/.github/workflows/release-nightly.yml @@ -29,7 +29,7 @@ jobs: # xgo build - run: make release env: - TAGS: bindata timetzdata sqlite sqlite_unlock_notify + TAGS: bindata sqlite sqlite_unlock_notify - name: import gpg key id: import_gpg uses: crazy-max/ghaction-import-gpg@v6 diff --git a/.github/workflows/release-tag-rc.yml b/.github/workflows/release-tag-rc.yml index d86633beea5cc..a406602dc0a74 100644 --- a/.github/workflows/release-tag-rc.yml +++ b/.github/workflows/release-tag-rc.yml @@ -30,7 +30,7 @@ jobs: # xgo build - run: make release env: - TAGS: bindata timetzdata sqlite sqlite_unlock_notify + TAGS: bindata sqlite sqlite_unlock_notify - name: import gpg key id: import_gpg uses: crazy-max/ghaction-import-gpg@v6 diff --git a/.github/workflows/release-tag-version.yml b/.github/workflows/release-tag-version.yml index 8ccbf5cffbf06..f67b76f40873b 100644 --- a/.github/workflows/release-tag-version.yml +++ b/.github/workflows/release-tag-version.yml @@ -32,7 +32,7 @@ jobs: # xgo build - run: make release env: - TAGS: bindata timetzdata sqlite sqlite_unlock_notify + TAGS: bindata sqlite sqlite_unlock_notify - name: import gpg key id: import_gpg uses: crazy-max/ghaction-import-gpg@v6 diff --git a/modules/setting/timezones_freebsd.go b/modules/setting/timezones_freebsd.go new file mode 100644 index 0000000000000..4cd50f3de5270 --- /dev/null +++ b/modules/setting/timezones_freebsd.go @@ -0,0 +1,6 @@ +// Copyright 2025 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package setting + +import _ "time/tzdata" diff --git a/modules/setting/timezones_windows.go b/modules/setting/timezones_windows.go new file mode 100644 index 0000000000000..4cd50f3de5270 --- /dev/null +++ b/modules/setting/timezones_windows.go @@ -0,0 +1,6 @@ +// Copyright 2025 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package setting + +import _ "time/tzdata" From 9ca98df5f77a062eea84dbf9a39a45517f2e49aa Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Tue, 4 Feb 2025 19:29:12 -0500 Subject: [PATCH 5/6] fix lint --- modules/setting/timezones_freebsd.go => timezones_freebsd.go | 2 +- modules/setting/timezones_windows.go => timezones_windows.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename modules/setting/timezones_freebsd.go => timezones_freebsd.go (87%) rename modules/setting/timezones_windows.go => timezones_windows.go (87%) diff --git a/modules/setting/timezones_freebsd.go b/timezones_freebsd.go similarity index 87% rename from modules/setting/timezones_freebsd.go rename to timezones_freebsd.go index 4cd50f3de5270..1176ab0115cff 100644 --- a/modules/setting/timezones_freebsd.go +++ b/timezones_freebsd.go @@ -1,6 +1,6 @@ // Copyright 2025 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT -package setting +package main import _ "time/tzdata" diff --git a/modules/setting/timezones_windows.go b/timezones_windows.go similarity index 87% rename from modules/setting/timezones_windows.go rename to timezones_windows.go index 4cd50f3de5270..1176ab0115cff 100644 --- a/modules/setting/timezones_windows.go +++ b/timezones_windows.go @@ -1,6 +1,6 @@ // Copyright 2025 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT -package setting +package main import _ "time/tzdata" From 605ca1eae843af687e62c44b466f3816dc897ced Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 5 Feb 2025 11:20:19 +0800 Subject: [PATCH 6/6] add more comments --- main_timezones.go | 16 ++++++++++++++++ timezones_freebsd.go | 6 ------ timezones_windows.go | 6 ------ 3 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 main_timezones.go delete mode 100644 timezones_freebsd.go delete mode 100644 timezones_windows.go diff --git a/main_timezones.go b/main_timezones.go new file mode 100644 index 0000000000000..e1233007c62f2 --- /dev/null +++ b/main_timezones.go @@ -0,0 +1,16 @@ +// Copyright 2025 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +//go:build windows + +package main + +// Golang has the ability to load OS's timezone data from most UNIX systems (https://github.com/golang/go/blob/master/src/time/zoneinfo_unix.go) +// Even if the timezone data is missing, users could install the related packages to get it. +// But on Windows, although `zoneinfo_windows.go` tries to load the timezone data from Windows registry, +// some users still suffer from the issue that the timezone data is missing: https://github.com/go-gitea/gitea/issues/33235 +// So we import the tzdata package to make sure the timezone data is included in the binary. +// +// For non-Windows package builders, they could still use the "TAGS=timetzdata" to include the tzdata package in the binary. +// If we decided to add the tzdata for other platforms, modify the "go:build" directive above. +import _ "time/tzdata" diff --git a/timezones_freebsd.go b/timezones_freebsd.go deleted file mode 100644 index 1176ab0115cff..0000000000000 --- a/timezones_freebsd.go +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2025 The Gitea Authors. All rights reserved. -// SPDX-License-Identifier: MIT - -package main - -import _ "time/tzdata" diff --git a/timezones_windows.go b/timezones_windows.go deleted file mode 100644 index 1176ab0115cff..0000000000000 --- a/timezones_windows.go +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2025 The Gitea Authors. All rights reserved. -// SPDX-License-Identifier: MIT - -package main - -import _ "time/tzdata"