-
Notifications
You must be signed in to change notification settings - Fork 11
51 lines (44 loc) · 1.7 KB
/
tzdata-update.yml
File metadata and controls
51 lines (44 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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