Skip to content

bump upstream version to 3.46.1.3 #96

bump upstream version to 3.46.1.3

bump upstream version to 3.46.1.3 #96

name: Update From Upstream
on:
push:
branches:
- 'releases/**'
paths:
- '.fork-meta/upstream-version.txt'
jobs:
update-from-upstream:
runs-on: ubuntu-latest
outputs:
upstream_version: ${{ steps.add-upstream-and-update.outputs.upstream_version }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN }}
- run: git status
- name: Setup git config
run: |
# setup the username and email
git config user.name "Austin G. Arbor"
git config user.email "${{ vars.GIT_COMMIT_EMAIL }}"
- name: Add Upstream and Update
id: add-upstream-and-update
run: |
git remote add upstream https://github.com/xerial/sqlite-jdbc.git
git fetch upstream
upstream_version=$(cat .fork-meta/upstream-version.txt)
echo "upstream_version=${upstream_version}" >> "$GITHUB_OUTPUT"
# overwrite our pom.xml, Makefile, and README.adoc with the upstream version
git checkout "tags/${upstream_version}" -- pom.xml Makefile README.adoc
git commit -m "update pom.xml, Makefile, and README.adoc from ${upstream_version}"
# note: when rebasing, ours and theirs is flipped
git merge --strategy=ort --strategy-option=theirs "tags/${upstream_version}"
- name: Modify pom.xml
run: |
# set the distribution management url to ours
set -e
# update project url
yq -i -e '.project.url = "https://github.com/austinarbor/sqlite-jdbc"' pom.xml
# update groupId
yq -i -e '.project.groupId = "dev.aga.sqlite"' pom.xml
# update snapshot repository url
yq -i -e '.project.distributionManagement.snapshotRepository.url = "https://s01.oss.sonatype.org/content/repositories/snapshots"' pom.xml
# update connection
yq -i -e '.project.scm.connection = "scm:git:git://github.com/austinarbor/sqlite-jdbc.git"' pom.xml
# update developer connection
yq -i -e '.project.scm.developerConnection = "scm:git:[email protected]:austinarbor/sqlite-jdbc.git"' pom.xml
# update url
yq -i -e '.project.scm.url = "https://github.com/austinarbor/sqlite-jdbc"' pom.xml
# update nexus url
yq -i -e '(.project.build.plugins.plugin.[] | select(.artifactId == "nexus-staging-maven-plugin") | .configuration.nexusUrl) ="https://s01.oss.sonatype.org/"' pom.xml
# disable the auto release for now
yq -i -e '(.project.build.plugins.plugin.[] | select(.artifactId == "nexus-staging-maven-plugin") | .configuration.autoReleaseAfterClose) ="false"' pom.xml
# yq seems to maybe have a bug with this? not sure of a better way to insert the developer
yq -i '.project.developers += {"+developer" : {"id": "austinarbor", "name": "Austin G. Arbor", "email": "[email protected]"}}' pom.xml -p=xml -o=xml
# remove the + from the developer tag
sed -i 's/+developer/developer/g' pom.xml
- name: Download and Update decimal.c
run: |
maven_version=$(yq '.project.version' pom.xml)
if [[ "${{ steps.add-upstream-and-update.outputs.upstream_version }}" != "${maven_version}" ]]; then
echo "version mismatch detected"
echo "maven: ${maven_version}"
echo "upstream: ${upstream_version}"
exit 1
fi
IFS=. read major minor patch build <<<"${maven_version}"
sqlite_version=$(printf "%d.%02d.%02d" "${major}" "${minor}" "${patch}")
amalgamation_version=$(printf "%d%02d%02d00" "${major}" "${minor}" "${patch}")
echo "amalgamation version: ${amalgamation_version}"
file_name="sqlite-src-${amalgamation_version}.zip"
download_url="https://www.sqlite.org/2024/${file_name}"
wget "${download_url}"
unzip "${file_name}"
dir_name="${file_name//.zip/}"
cp "${dir_name}/ext/misc/decimal.c" src/main/ext/decimal.c
# remove the ifdef block(s)
perl -i -p0e 's/#ifdef _WIN32.*#endif//gms' src/main/ext/decimal.c
rm -rf "${file_name}/"
- name: Update Makefile
run: |
# disable exit on failure for the grep
set +e
grep SQLITE_EXTRA_INIT Makefile
if [[ "$?" == "0" ]]; then
echo "SQLITE_EXTRA_INIT found, failing"
exit 1
fi
set -e
# get the last line number that contains -DSQLITE_ , we will need to insert our custom line after
prev_line_num=$(awk '/-DSQLITE_/ {print FNR}' Makefile | tail -n 1)
line_num=$((prev_line_num+1))
# need \ to make the spacing work
new_line="\ -DSQLITE_EXTRA_INIT=core_init \\\\"
sed -i "${line_num}i ${new_line}" Makefile
- name: Update README.adoc
run: |
# insert our "header" into the readme
set +e
sed -i '1i == SQLite JDBC Driver Fork\n\nThis repo is a fork of https://github.com/xerial/sqlite-jdbc[xerial/sqlite-jdbc], the only difference being the inclusion of the `decimal.c` extension in the jar.\n\nimage:https://img.shields.io/maven-central/v/dev.aga.sqlite/sqlite-jdbc?color=g&label=maven%20central[Maven Central,link=https://central.sonatype.com/search?q=g%3Adev.aga.sqlite+a%3Asqlite-jdbc]\n\n_Everything below this line comes from the original repository._\n' README.adoc
- name: Create commit message
id: create-commit-message
run: |
message="update pom.xml, Makefile, decimal.c, and README.adoc for ${{ steps.add-upstream-and-update.outputs.upstream_version }}"
set +e
# if decimal.c wasn't updated, remove it from the commit message
git diff --exit-code src/main/ext/decimal.c
if [ $? -eq 0 ]; then
message="${message/decimal.c, /}"
fi
set -e
echo "commit_message=${message}" >> $GITHUB_OUTPUT
- name: Commit modified files
uses: EndBug/add-and-commit@v9
with:
add: '[ "pom.xml", "README.adoc", "Makefile", "src/main/ext/decimal.c" ]'
message: ${{ steps.create-commit-message.outputs.commit_message }}
author_name: 'Austin G. Arbor'
author_email: '${{ vars.GIT_COMMIT_EMAIL }}'
push: false
- name: Check for Modified Files
run: |
# if we still have unchanged files, something is wrong
if [[ -n "$(git status --porcelain)" ]]; then
echo "modified files leftover, exiting"
git status --porcelain
exit 1
fi
- name: Resolve Conflicts
run: |
git merge --strategy=ort --strategy-option=ours origin/master
- name: Push Changes
run: |
git push --force
matrix:
name: Build matrix
runs-on: ubuntu-latest
needs: [ update-from-upstream ]
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- name: Build matrix from Makefile
id: set-matrix
# parse the Makefile to retrieve the list of targets in 'native-all', without 'native'
run: |
matrix=$((
echo '{ "target" : ['
sed -n "/^native-all *: */ { s///; p }" Makefile | sed "s/^native\s//g" | sed 's/ /, /g' | xargs -n 1 echo | sed -r 's/^([^,]*)(,?)$/"\1"\2/'
echo " ]}"
) | jq -c .)
echo $matrix | jq .
echo "matrix=$matrix" >> $GITHUB_OUTPUT
build:
name: Build native libraries
runs-on: ubuntu-latest
needs: [ matrix ]
strategy:
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v3
# Delete existing libs so we only upload the generated one into the artifact
- name: Delete existing native libs
run: rm -fr src/main/resources/org/sqlite/native
- name: Build native libraries
run: make ${{ matrix.target }}
env:
OCI_EXE: docker
- name: Upload native libraries
uses: actions/upload-artifact@v3
with:
name: native-libs
path: src/main/resources/org/sqlite/native/
test:
name: Test latest build
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
runs-on: ${{ matrix.os }}
needs: [ update-from-upstream, build ]
steps:
- name: setup java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
java-package: jdk
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git pull --rebase
- name: Download native libraries
uses: actions/download-artifact@v3
with:
name: native-libs
path: src/main/resources/org/sqlite/native/
- uses: actions/checkout@v3
with:
repository: austinarbor/sqlite-jdbc-decimal-test
path: sqlite-jdbc-decimal-test
- name: create packaged jar
run: mvn clean package -DskipTests
- name: copy jar into test project
run: |
cp "target/sqlite-jdbc-${{ needs.update-from-upstream.outputs.upstream_version }}.jar" sqlite-jdbc-decimal-test/libs/
- name: run tests
uses: gradle/gradle-build-action@v2
with:
arguments: test
build-root-directory: sqlite-jdbc-decimal-test
cache-read-only: ${{ github.ref != 'refs/heads/master' && !startsWith(github.ref, 'refs/heads/releases/') }}
push:
name: Push new native libraries to branch
runs-on: ubuntu-latest
needs: [ test ]
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GH_TOKEN }}
fetch-depth: 0
- run: git pull --rebase
- name: Download native libraries
uses: actions/download-artifact@v3
with:
name: native-libs
path: src/main/resources/org/sqlite/native/
- run: git status
- name: Commit and push
uses: EndBug/add-and-commit@v9
with:
message: 'chore: update native libraries'
author_name: 'Austin G. Arbor'
author_email: '${{ vars.GIT_COMMIT_EMAIL }}'
open-pr:
name: Open PR
runs-on: ubuntu-latest
needs: [ update-from-upstream, push ]
steps:
- uses: actions/checkout@v3
- name: Open PR
run: |
upstream_version="${{ needs.update-from-upstream.outputs.upstream_version }}"
gh pr create \
--repo austinarbor/sqlite-jdbc \
--base master \
--title "Prepare ${upstream_version}" \
--body "Changes for ${upstream_version}" \
--no-maintainer-edit
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}