TZDB check #1829
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: TZDB check | |
| on: | |
| push: | |
| tags: | |
| - 'tzdb*' | |
| schedule: | |
| - cron: '50 1 * * *' | |
| permissions: | |
| contents: read | |
| jobs: | |
| tzdbcheck: | |
| permissions: | |
| contents: write # for peter-evans/create-pull-request to create branch | |
| pull-requests: write # for peter-evans/create-pull-request to create a PR | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.PERSONAL_GITHUB_TOKEN }} | |
| fetch-tags: true | |
| - name: Setup git | |
| run: | | |
| git config --global user.name "Stephen Colebourne (CI)" | |
| git config --global user.email "[email protected]" | |
| - name: Set up JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 8 | |
| distribution: 'temurin' | |
| cache: 'maven' | |
| - name: Maven version | |
| run: | | |
| mkdir -p ./.mvn | |
| echo "-e" >> ./.mvn/maven.config | |
| echo "-B" >> ./.mvn/maven.config | |
| echo "-ntp" >> ./.mvn/maven.config | |
| echo "-DtrimStackTrace=false" >> ./.mvn/maven.config | |
| echo "--settings" >> ./.mvn/maven.config | |
| echo "$( pwd )/.github/maven-settings.xml" >> ./.mvn/maven.config | |
| mvn --version | |
| mkdir -p target | |
| #------------------------------------------------------------------------ | |
| - name: Get current version | |
| run: | | |
| CURRENT_TZDB=$(mvn help:evaluate -Dexpression=tz.database.version -q -DforceStdout) | |
| echo "current: $CURRENT_TZDB" | |
| echo "CURRENT_TZDB=$CURRENT_TZDB" >> $GITHUB_ENV | |
| - name: Get latest version | |
| working-directory: target | |
| run: | | |
| git clone https://github.com/JodaOrg/global-tz.git tz | |
| cd tz | |
| git checkout global-tz | |
| LATEST_TZDB=$(git describe --abbrev=0 --tags) | |
| echo "latest: $LATEST_TZDB" | |
| echo "LATEST_TZDB=$LATEST_TZDB" >> $GITHUB_ENV | |
| - name: Compare versions | |
| run: | | |
| echo "current: $CURRENT_TZDB" | |
| echo "latest: $LATEST_TZDB" | |
| if [ "$CURRENT_TZDB" == "$LATEST_TZDB" ]; then echo "NOOP=true" >> $GITHUB_ENV; fi | |
| - name: Build with Maven | |
| if: env.NOOP != 'true' | |
| run: | | |
| mvn install site | |
| - name: Download | |
| if: env.NOOP != 'true' | |
| working-directory: target | |
| run: | | |
| wget https://github.com/JodaOrg/global-tz/releases/download/${LATEST_TZDB}/tzdata${LATEST_TZDB}-rearguard.tar.gz | |
| ls -la | |
| mkdir -p tzdata${LATEST_TZDB}-rearguard | |
| ls -la | |
| tar -xf tzdata${LATEST_TZDB}-rearguard.tar.gz -C tzdata${LATEST_TZDB}-rearguard | |
| ls -la | |
| - name: Copy rearguard files | |
| if: env.NOOP != 'true' | |
| run: | | |
| mkdir -p src/tzdb/${LATEST_TZDB} | |
| cp -r target/tzdata${LATEST_TZDB}-rearguard/. src/tzdb/${LATEST_TZDB} | |
| - name: Update build with new tzdb | |
| if: env.NOOP != 'true' | |
| run: | | |
| mvn package -Dtzdb-update | |
| mvn versions:set-property -DnewVersion=${LATEST_TZDB} -Dproperty=tz.database.version -DgenerateBackupPoms=false | |
| - name: Create Pull Request | |
| if: env.NOOP != 'true' | |
| id: createpr | |
| uses: peter-evans/create-pull-request@v3 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }} | |
| with: | |
| token: ${{ secrets.PERSONAL_GITHUB_TOKEN }} | |
| base: main | |
| commit-message: 'Update time zone data to ${{ env.LATEST_TZDB }}' | |
| committer: Stephen Colebourne (CI) <[email protected]> | |
| author: Stephen Colebourne (CI) <[email protected]> | |
| title: 'Update time zone data to ${{ env.LATEST_TZDB }}' | |
| body: 'Update time zone data to ${{ env.LATEST_TZDB }}' | |
| assignees: jodastephen | |
| labels: TZDB | |
| branch: bot/update-tzdb | |
| - name: Auto-merge the Pull Request | |
| if: steps.createpr.outputs.pull-request-number | |
| run: gh pr merge --squash --auto "${{ steps.createpr.outputs.pull-request-number }}" | |
| env: | |
| GH_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }} | |
| - name: Delete tzdb tag | |
| if: "startsWith(github.ref, 'refs/tags/tzdb')" | |
| run: | | |
| git tag --delete "${GITHUB_REF_NAME}" || true | |
| git push --delete origin "${GITHUB_REF_NAME}" || true |