Auto‑Bump SQLite‑JDBC #7
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: Auto‑Bump SQLite‑JDBC | |
| on: | |
| schedule: # every day at 05:00 UTC | |
| - cron: '0 5 * * *' | |
| workflow_dispatch: # manual “Run workflow” button | |
| permissions: | |
| contents: write # push commits, create releases | |
| pull-requests: write # open / merge PRs | |
| jobs: | |
| bump: | |
| runs-on: ubuntu-latest | |
| env: | |
| BOT_NAME: "Axionize" | |
| BOT_EMAIL: "[email protected]" | |
| steps: | |
| # ───────────────────────────────────────────────────────── | |
| # 1) Checkout | |
| # ───────────────────────────────────────────────────────── | |
| - uses: actions/checkout@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} # writeable token | |
| # ───────────────────────────────────────────────────────── | |
| # 2) Latest version on Maven Central | |
| # ───────────────────────────────────────────────────────── | |
| - name: Fetch newest sqlite‑jdbc | |
| id: maven | |
| run: | | |
| latest=$(curl -s \ | |
| 'https://search.maven.org/solrsearch/select?q=g:%22org.xerial%22+AND+a:%22sqlite-jdbc%22&rows=1&wt=json' \ | |
| | jq -r '.response.docs[0].latestVersion') | |
| echo "latest=$latest" | |
| echo "latest=$latest" >> "$GITHUB_OUTPUT" | |
| # 2½) Make the version available as an env var | |
| - name: Export NEW_VER | |
| run: echo "NEW_VER=${{ steps.maven.outputs.latest }}" >> $GITHUB_ENV | |
| # ───────────────────────────────────────────────────────── | |
| # 3) Current version in gradle.properties | |
| # ───────────────────────────────────────────────────────── | |
| - name: Read current version | |
| id: current | |
| run: | | |
| current=$(grep '^library_version=' gradle.properties | cut -d'=' -f2) | |
| echo "current=$current" | |
| echo "current=$current" >> "$GITHUB_OUTPUT" | |
| # 3½) Export NEW_VER (already in your file) | |
| - name: Export NEW_VER | |
| run: echo "NEW_VER=${{ steps.maven.outputs.latest }}" >> $GITHUB_ENV | |
| # ───────────────────────────────────────────────────────── | |
| # 4) Exit early if nothing to update | |
| # ───────────────────────────────────────────────────────── | |
| - name: Skip if up‑to‑date | |
| if: ${{ steps.maven.outputs.latest == steps.current.outputs.current }} | |
| run: echo "Nothing to bump — already on ${{ steps.current.outputs.current }}." | |
| # 5) Bump version & release_date ── we already compute TODAY here | |
| - name: Bump version & release date | |
| id: bump | |
| if: ${{ steps.maven.outputs.latest != steps.current.outputs.current }} | |
| run: | | |
| set -e | |
| TODAY=$(date -u +%F) # 2024-06-08 | |
| echo "TODAY=$TODAY" >> $GITHUB_ENV # ← make it available later | |
| sed -i "s/^library_version=.*/library_version=${{ steps.maven.outputs.latest }}/" gradle.properties | |
| if grep -q '^release_date=' gradle.properties; then | |
| sed -i "s/^release_date=.*/release_date=${TODAY}/" gradle.properties | |
| else | |
| echo "release_date=${TODAY}" >> gradle.properties | |
| fi | |
| # --------------------------------------------------------------------- | |
| # 5) OPTION A → Commit directly to main (UNCOMMENT to use) | |
| # --------------------------------------------------------------------- | |
| # - name: Bump + push to main # ← uncomment block to enable option A | |
| # if: ${{ steps.maven.outputs.latest != steps.current.outputs.current }} | |
| # env: | |
| # LATEST: ${{ steps.maven.outputs.latest }} | |
| # run: | | |
| # set -e | |
| # sed -i "s/^library_version=.*/library_version=${LATEST}/" gradle.properties | |
| # git config user.name "Axionize" | |
| # git config user.email "[email protected]" | |
| # git add gradle.properties | |
| # git commit -m "chore: bump sqlite-jdbc to ${LATEST}" | |
| # git push origin HEAD:main | |
| # --------------------------------------------------------------------- | |
| # 5/6) OPTION B → PR + auto‑merge (DEFAULT below) | |
| # --------------------------------------------------------------------- | |
| # 6) Create or update the PR | |
| - name: Create PR | |
| id: create-pr | |
| if: ${{ steps.maven.outputs.latest != steps.current.outputs.current }} | |
| uses: peter-evans/create-pull-request@v5 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| branch: bump-sqlite-${{ steps.maven.outputs.latest }} | |
| add-paths: gradle.properties | |
| commit-message: "chore: bump sqlite-jdbc to ${{ steps.maven.outputs.latest }} (released ${{ env.TODAY }})" | |
| title: "chore: bump sqlite-jdbc to ${{ steps.maven.outputs.latest }}" | |
| body: | | |
| Automated bump | |
| • **library_version** → `${{ steps.maven.outputs.latest }}` | |
| • **release_date** → `${{ env.TODAY }}` | |
| delete-branch: true | |
| author: "${{ env.BOT_NAME }} <${{ env.BOT_EMAIL }}>" | |
| committer: "${{ env.BOT_NAME }} <${{ env.BOT_EMAIL }}>" | |
| # 7) Enable auto‑merge | |
| - name: Enable PR auto‑merge | |
| if: ${{ steps.create-pr.outputs.pull-request-number }} | |
| run: gh pr merge --squash --auto "${{ steps.create-pr.outputs.pull-request-number }}" | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |