File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ name : tzdata update
2+ on :
3+ schedule :
4+ - cron : " 0 23 * * *"
5+ workflow_dispatch :
6+
7+ permissions :
8+ contents : write
9+
10+ jobs :
11+ update :
12+ runs-on : ubuntu-latest
13+ steps :
14+ - name : Check out repository code
15+ uses : actions/checkout@v4
16+ - name : Set up Go
17+ uses : actions/setup-go@v5
18+ with :
19+ go-version-file : go.mod
20+ - name : Fetch latest tzcode version
21+ run : |
22+ set -euo pipefail
23+ workdir=$(mktemp -d)
24+ wget -O "$workdir/tzcode-latest.tar.gz" https://www.iana.org/time-zones/repository/tzcode-latest.tar.gz
25+ tar -xzf "$workdir/tzcode-latest.tar.gz" -C "$workdir"
26+
27+ version_file=$(find "$workdir" -maxdepth 2 -type f -name version | head -n 1)
28+ if [ -z "$version_file" ]; then
29+ echo "version file not found in tzcode-latest.tar.gz" >&2
30+ exit 1
31+ fi
32+
33+ latest_version=$(tr -d ' \n' < "$version_file")
34+ current_version=$(grep -E 'tzVersion' scripts/tzgen/main.go | sed -E 's/.*"([^"]+)".*/\1/' | head -n 1)
35+
36+ echo "current=$current_version latest=$latest_version"
37+ if [ "$latest_version" = "$current_version" ]; then
38+ echo "tzdata is already up to date"
39+ exit 0
40+ fi
41+
42+ sed -i.bak -E 's/tzVersion = ".*"/tzVersion = "'"$latest_version"'"/' scripts/tzgen/main.go
43+ rm -f scripts/tzgen/main.go.bak
44+ gofmt -w scripts/tzgen/main.go
45+ go run scripts/tzgen/main.go
46+
47+ git config user.name "github-actions[bot]"
48+ git config user.email "github-actions[bot]@users.noreply.github.com"
49+ git add scripts/tzgen/main.go tz
50+ git commit -m "Update tzdata to ${latest_version}"
51+ git push
You can’t perform that action at this time.
0 commit comments