Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/tzdata-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: tzdata update
on:
schedule:
- cron: "0 23 * * *"
workflow_dispatch:

permissions:
contents: write

jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Fetch latest tzcode version
run: |
set -euo pipefail
workdir=$(mktemp -d)
wget -O "$workdir/tzcode-latest.tar.gz" https://www.iana.org/time-zones/repository/tzcode-latest.tar.gz
tar -xzf "$workdir/tzcode-latest.tar.gz" -C "$workdir"

version_file=$(find "$workdir" -maxdepth 2 -type f -name version | head -n 1)
if [ -z "$version_file" ]; then
echo "version file not found in tzcode-latest.tar.gz" >&2
exit 1
fi

latest_version=$(tr -d ' \n' < "$version_file")
current_version=$(grep -E 'tzVersion' scripts/tzgen/main.go | sed -E 's/.*"([^"]+)".*/\1/' | head -n 1)

echo "current=$current_version latest=$latest_version"
if [ "$latest_version" = "$current_version" ]; then
echo "tzdata is already up to date"
exit 0
fi

sed -i.bak -E 's/tzVersion = ".*"/tzVersion = "'"$latest_version"'"/' scripts/tzgen/main.go
rm -f scripts/tzgen/main.go.bak
gofmt -w scripts/tzgen/main.go
go run scripts/tzgen/main.go

git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add scripts/tzgen/main.go tz
git commit -m "Update tzdata to ${latest_version}"
git push
5 changes: 4 additions & 1 deletion scripts/tzgen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import (
"strings"
)

const tzdataURL = "https://data.iana.org/time-zones/releases/tzdata2025b.tar.gz"
const (
tzVersion = "2025c"
tzdataURL = "https://data.iana.org/time-zones/releases/tzdata" + tzVersion + ".tar.gz"
)

func main() {
if err := run(context.Background()); err != nil {
Expand Down