Skip to content

Commit 3c9d1e6

Browse files
committed
Test new less annoying build script
1 parent 4aec4c3 commit 3c9d1e6

File tree

3 files changed

+125
-77
lines changed

3 files changed

+125
-77
lines changed

.github/workflows/auto-bump-jdbc.yml

Lines changed: 79 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
workflow_dispatch: # manual “Run workflow” button
77

88
permissions:
9-
contents: write # push commits, create releases
9+
contents: write # push commits, create releases, trigger dispatch
1010
pull-requests: write # open / merge PRs
1111

1212
jobs:
@@ -15,110 +15,130 @@ jobs:
1515

1616
env:
1717
BOT_NAME: "Axionize"
18-
BOT_EMAIL: "Axionize+bot@example.com"
18+
BOT_EMAIL: "Axionize+bot@example.com" # Use the actual committer email
1919

2020
steps:
21-
# ─────────────────────────────────────────────────────────
2221
# 1) Checkout
23-
# ─────────────────────────────────────────────────────────
2422
- uses: actions/checkout@v3
2523
with:
2624
token: ${{ secrets.GITHUB_TOKEN }} # writeable token
2725

28-
# ─────────────────────────────────────────────────────────
2926
# 2) Latest version on Maven Central
30-
# ─────────────────────────────────────────────────────────
3127
- name: Fetch newest sqlite‑jdbc
3228
id: maven
3329
run: |
34-
latest=$(curl -s \
35-
'https://search.maven.org/solrsearch/select?q=g:%22org.xerial%22+AND+a:%22sqlite-jdbc%22&rows=1&wt=json' \
36-
| jq -r '.response.docs[0].latestVersion')
30+
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')
3731
echo "latest=$latest"
3832
echo "latest=$latest" >> "$GITHUB_OUTPUT"
3933
4034
# 2½) Make the version available as an env var
4135
- name: Export NEW_VER
4236
run: echo "NEW_VER=${{ steps.maven.outputs.latest }}" >> $GITHUB_ENV
4337

44-
# ─────────────────────────────────────────────────────────
4538
# 3) Current version in gradle.properties
46-
# ─────────────────────────────────────────────────────────
4739
- name: Read current version
4840
id: current
4941
run: |
50-
current=$(grep '^library_version=' gradle.properties | cut -d'=' -f2)
42+
current=$(grep '^library_version=' gradle.properties | cut -d'=' -f2 || echo "NOT_FOUND") # Handle missing file/key gracefully
5143
echo "current=$current"
5244
echo "current=$current" >> "$GITHUB_OUTPUT"
5345
54-
# 3½) Export NEW_VER (already in your file)
55-
- name: Export NEW_VER
56-
run: echo "NEW_VER=${{ steps.maven.outputs.latest }}" >> $GITHUB_ENV
46+
# 4) Exit early if nothing to update (or error reading current)
47+
- name: Check versions and decide action
48+
id: decision
49+
run: |
50+
if [[ "${{ steps.maven.outputs.latest }}" == "${{ steps.current.outputs.current }}" ]]; then
51+
echo "Version is up-to-date (${{ steps.current.outputs.current }}). No action needed."
52+
echo "should_bump=false" >> "$GITHUB_OUTPUT"
53+
elif [[ "${{ steps.current.outputs.current }}" == "NOT_FOUND" ]]; then
54+
echo "Could not read current version from gradle.properties. Skipping bump."
55+
echo "should_bump=false" >> "$GITHUB_OUTPUT"
56+
elif [[ -z "${{ steps.maven.outputs.latest }}" ]]; then
57+
echo "Could not fetch latest version from Maven. Skipping bump."
58+
echo "should_bump=false" >> "$GITHUB_OUTPUT"
59+
else
60+
echo "Current version (${{ steps.current.outputs.current }}) differs from latest (${{ steps.maven.outputs.latest }}). Proceeding with bump."
61+
echo "should_bump=true" >> "$GITHUB_OUTPUT"
62+
echo "TODAY=$(date -u +%F)" >> $GITHUB_ENV # Set TODAY env var only if bumping
63+
fi
5764
58-
# ─────────────────────────────────────────────────────────
59-
# 4) Exit early if nothing to update
60-
# ─────────────────────────────────────────────────────────
61-
- name: Skip if up‑to‑date
62-
if: ${{ steps.maven.outputs.latest == steps.current.outputs.current }}
63-
run: echo "Nothing to bump — already on ${{ steps.current.outputs.current }}."
64-
65-
# 5) Bump version & release_date ── we already compute TODAY here
66-
- name: Bump version & release date
67-
id: bump
68-
if: ${{ steps.maven.outputs.latest != steps.current.outputs.current }}
65+
# 5) Bump version & release_date
66+
- name: Bump version & release date in gradle.properties
67+
if: steps.decision.outputs.should_bump == 'true'
6968
run: |
7069
set -e
71-
TODAY=$(date -u +%F) # 2024-06-08
72-
echo "TODAY=$TODAY" >> $GITHUB_ENV # ← make it available later
73-
74-
sed -i "s/^library_version=.*/library_version=${{ steps.maven.outputs.latest }}/" gradle.properties
70+
echo "Updating gradle.properties to version ${{ env.NEW_VER }} and date ${{ env.TODAY }}"
71+
sed -i "s/^library_version=.*/library_version=${{ env.NEW_VER }}/" gradle.properties
7572
if grep -q '^release_date=' gradle.properties; then
76-
sed -i "s/^release_date=.*/release_date=${TODAY}/" gradle.properties
73+
sed -i "s/^release_date=.*/release_date=${{ env.TODAY }}/" gradle.properties
7774
else
78-
echo "release_date=${TODAY}" >> gradle.properties
75+
echo "release_date=${{ env.TODAY }}" >> gradle.properties
7976
fi
77+
echo "gradle.properties updated."
78+
79+
# --- CHOOSE ONE OF THE FOLLOWING OPTIONS (A or B) ---
8080

81-
# ---------------------------------------------------------------------
82-
# 5) OPTION A → Commit directly to main (UNCOMMENT to use)
83-
# ---------------------------------------------------------------------
84-
# - name: Bump + push to main # ← uncomment block to enable option A
85-
# if: ${{ steps.maven.outputs.latest != steps.current.outputs.current }}
86-
# env:
87-
# LATEST: ${{ steps.maven.outputs.latest }}
81+
# OPTION A: Commit directly to main
82+
# - name: Commit and Push Bump Directly to main
83+
# if: steps.decision.outputs.should_bump == 'true'
8884
# run: |
8985
# set -e
90-
# sed -i "s/^library_version=.*/library_version=${LATEST}/" gradle.properties
91-
# git config user.name "Axionize"
92-
# git config user.email "154778082+Axionize@users.noreply.github.com"
86+
# git config user.name "${{ env.BOT_NAME }}"
87+
# git config user.email "${{ env.BOT_EMAIL }}"
9388
# git add gradle.properties
94-
# git commit -m "chore: bump sqlite-jdbc to ${LATEST}"
89+
# git commit -m "chore: bump sqlite-jdbc to ${{ env.NEW_VER }} (released ${{ env.TODAY }})"
90+
# echo "Pushing changes to main..."
9591
# git push origin HEAD:main
92+
# echo "Changes pushed."
9693

97-
# ---------------------------------------------------------------------
98-
# 5/6) OPTION B → PR + auto‑merge (DEFAULT below)
99-
# ---------------------------------------------------------------------
100-
# 6) Create or update the PR
94+
# OPTION B: Create PR and Enable Auto-Merge (DEFAULT in your original)
10195
- name: Create PR
10296
id: create-pr
103-
if: ${{ steps.maven.outputs.latest != steps.current.outputs.current }}
97+
if: steps.decision.outputs.should_bump == 'true'
10498
uses: peter-evans/create-pull-request@v5
10599
with:
100+
# Use the specific BOT_EMAIL for author/committer
101+
author: "${{ env.BOT_NAME }} <${{ env.BOT_EMAIL }}>"
102+
committer: "${{ env.BOT_NAME }} <${{ env.BOT_EMAIL }}>"
106103
token: ${{ secrets.GITHUB_TOKEN }}
107-
branch: bump-sqlite-${{ steps.maven.outputs.latest }}
104+
branch: bump-sqlite-${{ env.NEW_VER }}
108105
add-paths: gradle.properties
109-
commit-message: "chore: bump sqlite-jdbc to ${{ steps.maven.outputs.latest }} (released ${{ env.TODAY }})"
110-
title: "chore: bump sqlite-jdbc to ${{ steps.maven.outputs.latest }}"
106+
commit-message: "chore: bump sqlite-jdbc to ${{ env.NEW_VER }} (released ${{ env.TODAY }})"
107+
title: "chore: bump sqlite-jdbc to ${{ env.NEW_VER }}"
111108
body: |
112-
Automated bump
113-
• **library_version** → `${{ steps.maven.outputs.latest }}`
109+
Automated bump
110+
• **library_version** → `${{ env.NEW_VER }}`
114111
• **release_date** → `${{ env.TODAY }}`
115112
delete-branch: true
116-
author: "${{ env.BOT_NAME }} <${{ env.BOT_EMAIL }}>"
117-
committer: "${{ env.BOT_NAME }} <${{ env.BOT_EMAIL }}>"
118113

119-
# 7) Enable auto‑merge
120114
- name: Enable PR auto‑merge
121-
if: ${{ steps.create-pr.outputs.pull-request-number }}
122-
run: gh pr merge --squash --auto "${{ steps.create-pr.outputs.pull-request-number }}"
115+
id: merge-pr # Give it an ID for potential future checks
116+
# Run only if the PR was actually created in the previous step
117+
if: steps.create-pr.outputs.pull-request-number
123118
env:
124-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
120+
run: |
121+
echo "Enabling auto-merge for PR #${{ steps.create-pr.outputs.pull-request-number }}"
122+
gh pr merge --squash --auto "${{ steps.create-pr.outputs.pull-request-number }}"
123+
echo "Auto-merge enabled."
124+
# Note: Merging happens asynchronously after checks pass.
125+
126+
# --- END OF OPTIONS ---
127+
128+
# 6) ***NEW STEP***: Send repository_dispatch IF a bump occurred
129+
- name: Trigger Nightly Release via Dispatch
130+
# Condition: EITHER direct push was attempted OR a PR was created
131+
if: steps.decision.outputs.should_bump == 'true'
132+
env:
133+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
134+
# Pass the new version info if needed by the triggered workflow
135+
NEW_VER_PAYLOAD: ${{ env.NEW_VER }}
136+
run: |
137+
echo "Bump occurred. Sending repository_dispatch event: sqlite_jdbc_bumped"
138+
gh api \
139+
--method POST \
140+
-H "Accept: application/vnd.github.v3+json" \
141+
/repos/${{ github.repository }}/dispatches \
142+
-f event_type='sqlite_jdbc_bumped' \
143+
-f client_payload='{"version": "${{ env.NEW_VER_PAYLOAD }}", "reason": "Auto-bump completed"}'
144+
echo "Dispatch event sent."

.github/workflows/gradle.yml

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,50 @@
11
name: Nightly Release
22

33
on:
4-
# rebuild on every push to the default branch
4+
# Trigger on pushes to main (covers manual pushes, other non-bot pushes)
55
push:
66
branches: [ main ]
77

8-
# …and once a day at 04:00 UTC (if uncommented)
8+
# ***CHANGED***: Trigger ONLY when Auto-Bump sends the specific dispatch event
9+
repository_dispatch:
10+
types: [sqlite_jdbc_bumped] # Matches event_type sent by Auto-Bump
11+
12+
# ***REMOVED***: No longer need workflow_run trigger
13+
# workflow_run:
14+
# workflows: ["Auto‑Bump SQLite‑JDBC"]
15+
# types: [completed]
16+
17+
# Optional: Keep schedule if you want independent nightly builds
918
# schedule:
1019
# - cron: '0 4 * * *'
11-
workflow_run:
12-
workflows: ["Auto‑Bump SQLite‑JDBC"]
13-
types: [completed]
1420

1521
jobs:
1622
build-and-release:
23+
# No complex 'if' condition needed at the job level anymore,
24+
# the triggers themselves filter correctly.
1725
runs-on: ubuntu-latest
1826

1927
env:
28+
# These are less critical now but good practice
2029
BOT_NAME: "Axionize (automation)"
2130
BOT_EMAIL: "Axionize+bot@example.com"
2231

2332
steps:
2433
# ─────────────────────────────────────────────────────────────
25-
# 1. Check out sources
34+
# 1. Check out sources (ensure it gets the code AFTER the bump)
2635
# ─────────────────────────────────────────────────────────────
2736
- uses: actions/checkout@v3
37+
with:
38+
# When triggered by dispatch/push, checkout should get the latest commit
39+
# that includes the bump. fetch-depth: 0 might be needed if release notes use history.
40+
ref: 'main' # Explicitly checkout main
2841

2942
# ─────────────────────────────────────────────────────────────
30-
# 2. JDK8 + Gradle cache
43+
# ***REMOVED***: No longer need the run_condition check step
44+
# ─────────────────────────────────────────────────────────────
45+
46+
# ─────────────────────────────────────────────────────────────
47+
# 2. JDK8 + Gradle cache (Runs unconditionally now when job starts)
3148
# ─────────────────────────────────────────────────────────────
3249
- name: Set up JDK8
3350
uses: actions/setup-java@v3
@@ -37,15 +54,15 @@ jobs:
3754
cache: gradle
3855

3956
# ─────────────────────────────────────────────────────────────
40-
# 3. Validate wrapper (supply SHA-256 whitelist)
57+
# 3. Validate wrapper
4158
# ─────────────────────────────────────────────────────────────
4259
- name: Validate Gradle wrapper
4360
uses: gradle/wrapper-validation-action@v1
4461

4562
# ─────────────────────────────────────────────────────────────
4663
# 4. Build shaded JAR
4764
# ─────────────────────────────────────────────────────────────
48-
- name: Build
65+
- name: Build Shaded JAR
4966
uses: gradle/gradle-build-action@v2
5067
with:
5168
arguments: clean build --no-daemon --stacktrace
@@ -57,22 +74,33 @@ jobs:
5774
id: locate
5875
run: |
5976
set -e
60-
jar=$(ls -1 build/libs/*-all.jar | head -n1)
61-
echo "jar=$jar" >>"$GITHUB_OUTPUT"
62-
63-
# Handles both YYYYMMDD and YYYY-MM-DD dates
64-
ver=$(basename "$jar" | sed -E 's/^sqlite-jdbc-([0-9.]+\+[0-9]{8}|[0-9.]+\+[0-9]{4}-[0-9]{2}-[0-9]{2})-all\.jar$/\1/')
77+
jar_path=$(ls -1 build/libs/*-all.jar | head -n1)
78+
if [ -z "$jar_path" ]; then
79+
echo "Error: Could not find the *-all.jar file in build/libs/"
80+
exit 1
81+
fi
82+
echo "jar=$jar_path" >>"$GITHUB_OUTPUT"
83+
84+
ver=$(basename "$jar_path" | sed -E 's/^sqlite-jdbc-([0-9.]+\+([0-9]{8}|[0-9]{4}-[0-9]{2}-[0-9]{2}))-all\.jar$/\1/')
85+
if [ -z "$ver" ] || [ "$ver" == "$(basename "$jar_path")" ]; then
86+
echo "Error: Could not extract version from JAR filename: $(basename "$jar_path")"
87+
exit 1
88+
fi
6589
echo "ver=$ver" >>"$GITHUB_OUTPUT"
90+
echo "Extracted version: $ver from $jar_path"
6691
6792
# ─────────────────────────────────────────────────────────────
6893
# 6. Create/update a version‑tagged release
6994
# ─────────────────────────────────────────────────────────────
7095
- name: Publish nightly release
96+
# Only condition now is that locate step must succeed
97+
if: steps.locate.outputs.ver != ''
7198
uses: ncipollo/release-action@v1
7299
with:
73-
tag: nightly-${{ steps.locate.outputs.ver }} # ex: nightly-3.49.1.0+20250420
100+
tag: nightly-${{ steps.locate.outputs.ver }}
74101
name: Nightly ${{ steps.locate.outputs.ver }}
75102
artifacts: ${{ steps.locate.outputs.jar }}
76103
prerelease: true
77-
makeLatest: true # marks this release as “latest”
78-
token: ${{ secrets.GITHUB_TOKEN }}
104+
makeLatest: true
105+
allowUpdates: true
106+
token: ${{ secrets.GITHUB_TOKEN }}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ mod_license=Apache
1313

1414
library_name=sqlite-jdbc
1515
library_maven_name=org.xerial:sqlite-jdbc
16-
library_version=3.49.1.0
16+
library_version=3.47.2.0
1717

1818
release_date=2025-04-20

0 commit comments

Comments
 (0)