|
| 1 | +name: Build latest IANA data |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + build-data: |
| 8 | + name: Fetch and build latest data from IANA |
| 9 | + runs-on: ubuntu-latest |
| 10 | + |
| 11 | + steps: |
| 12 | + - uses: actions/checkout@v3 |
| 13 | + |
| 14 | + - name: Use Node.js |
| 15 | + uses: actions/setup-node@v3 |
| 16 | + with: |
| 17 | + node-version: lts/* |
| 18 | + cache: npm |
| 19 | + |
| 20 | + - name: Install dependencies |
| 21 | + run: npm ci |
| 22 | + |
| 23 | + # This differs slightly from the default `grunt data` flow. We want to explicitly compile |
| 24 | + # `zic` and `zdump` to avoid relying on whatever version is on the action runners. |
| 25 | + - name: Download tzdata and tzcode |
| 26 | + run: | |
| 27 | + npx grunt --verbose clean data-download |
| 28 | + npx grunt --verbose data-download --fetch-tzcode |
| 29 | +
|
| 30 | + - name: Build zic and zdump |
| 31 | + run: | |
| 32 | + pushd temp/download/latest |
| 33 | + make clean |
| 34 | + make |
| 35 | + popd |
| 36 | +
|
| 37 | + - name: Generate new data |
| 38 | + run: | |
| 39 | + npx grunt --verbose data-meta \ |
| 40 | + data-zic --zic-path=./temp/download/latest/zic \ |
| 41 | + data-zdump --zdump-path=./temp/download/latest/zdump \ |
| 42 | + data-collect \ |
| 43 | + data-dedupe \ |
| 44 | + data-pack \ |
| 45 | + data-tests |
| 46 | +
|
| 47 | + # Prepare version metadata for use in PR creation |
| 48 | + - name: Prepare metadata |
| 49 | + id: meta |
| 50 | + run: | |
| 51 | + echo "TZDATA_VERSION=$(cat temp/download/latest/version)" >> "$GITHUB_OUTPUT" |
| 52 | + echo -e "This contains the following changes from tzdb (edit this to remove details irrelevant to this project):\n\n\`\`\`" > temp/pr-body.txt |
| 53 | + awk '/^Release [[:digit:]]{4}/ {\ |
| 54 | + if (used != 1) { used = 1; active = 1 }\ |
| 55 | + else { active = 0 }\ |
| 56 | + } { if (active == 1) print }' \ |
| 57 | + temp/download/latest/NEWS >> temp/pr-body.txt |
| 58 | + echo "\`\`\`" >> temp/pr-body.txt |
| 59 | +
|
| 60 | + - name: Create pull request |
| 61 | + uses: peter-evans/create-pull-request@v5 |
| 62 | + with: |
| 63 | + author: 'GitHub Actions <[email protected]>' |
| 64 | + branch: automated/data-update |
| 65 | + commit-message: 'data: Add ${{ steps.meta.outputs.TZDATA_VERSION }}' |
| 66 | + title: 'data: Add ${{ steps.meta.outputs.TZDATA_VERSION }}' |
| 67 | + body-path: temp/pr-body.txt |
| 68 | + reviewers: ${{ github.actor }} |
0 commit comments