Background

Since the start of the TZDB project, I have been keeping it up to date by downloading the latest IANA database, and then, rebuilding the code and testing the changes manually.

This has become somewhat of a chore and I have automated it by creating a custom shell script that does everything in one go – download the latest IANA, windows TZ aliases, build, test and update the version. This has freed me to simply run the script when a new release of IANA pops up, followed by a push and release.

This, however, still required me to pay attention to the IANA releases and find time to do the manual work. Thus, I have decided to automate myself out of the equation completely by using Github Actions.

To achieve this, I have set up three actions in GitHub:

  • Test, which runs the unit tests after each push to the master branch,
  • Release, which is run after a push to the master repo,
  • Bump, which runs the update-compile.sh script and pushes the changes to the repo.

Below are the listings of the two important workflows (Bump and Release):

Bump workflow

As previously stated, this action, sets up the environment for the latest FreePascal and then executes the update-compile.sh in ci mode. This mode will do everything I would do manually, including pushing the updated files to the master branch.

The action is triggered once a month on the 1st day.

name: TZDB/CLDR Bump

on:
  push:
    branches: [ "master" ]
    paths:
      - './update-compile.sh'
  schedule:
    - cron: '0 9 1 1-12 *'
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3 
      - name: Install Free-Pascal
        run: sudo apt-get install -y fpc
      - name: Configure git
        run: |
          git config --global user.name 'Alexandru Ciobanu [bot]'
          git config --global user.email 'alex+git[bot]@ciobanu.org'
      - name: Update the Library
        run: mkdir ./bin && ./update-compile.sh ci

Link

Release workflow

This action runs once files are pushed to the master branch and will use GitHub API to create a new release using the changes.

name: Release

on:
  push:
    tags:        
      - '*'

jobs:
  release:
    name: "Release"

    runs-on: "ubuntu-latest"

    steps:
      - name: "Determine Tag"
        run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"

      - name: "Create Release"
        uses: "actions/github-script@v5"
        with:
          github-token: "$"
          script: |
            try {
              await github.rest.repos.createRelease({
                draft: false,
                generate_release_notes: true,
                name: 'TZDB ' + process.env.RELEASE_TAG,
                owner: context.repo.owner,
                prerelease: false,
                repo: context.repo.repo,
                tag_name: process.env.RELEASE_TAG,
              });
            } catch (error) {
              core.setFailed(error.message);
            }

Link

Final words

This setup has now completely removes myself from the manual work I was forced to do and also ensures that latest IANA updates are available at most one month after they are released.

Big thanks to our GitHub overlords for helping us free ourselves from the manual labour!