version-3.53.3 #1
Workflow file for this run
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: amalgamation | |
| on: | |
| push: | |
| tags: | |
| - "version-*" | |
| - "3.*" | |
| workflow_dispatch: | |
| inputs: | |
| sqlite_tag: | |
| description: "Upstream sqlite/sqlite tag to build (e.g. version-3.47.2). Defaults to the contents of SQLITE_TAG." | |
| required: false | |
| type: string | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| name: Build and release SQLite amalgamation | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out this repository | |
| uses: actions/checkout@v4 | |
| - name: Resolve SQLite tag | |
| id: resolve | |
| env: | |
| INPUT_TAG: ${{ inputs.sqlite_tag }} | |
| run: | | |
| set -euo pipefail | |
| TAG="${INPUT_TAG:-}" | |
| if [ -z "$TAG" ]; then | |
| if [ ! -f SQLITE_TAG ]; then | |
| echo "::error::SQLITE_TAG file not found in repository root" | |
| exit 1 | |
| fi | |
| TAG="$(tr -d " \t\r\n" < SQLITE_TAG)" | |
| fi | |
| if [ -z "$TAG" ]; then | |
| echo "::error::No SQLite tag given (SQLITE_TAG file is empty)" | |
| exit 1 | |
| fi | |
| # Accept both "version-3.53.3" and bare "3.53.3" | |
| case "$TAG" in | |
| version-*) ;; | |
| *) TAG="version-$TAG" ;; | |
| esac | |
| if [ "${GITHUB_REF_TYPE:-}" = "tag" ]; then | |
| RELEASE_TAG="$GITHUB_REF_NAME" | |
| # Guard against tagging a release whose SQLITE_TAG file was not updated | |
| PUSHED="${RELEASE_TAG#version-}" | |
| WANT="${TAG#version-}" | |
| case "$PUSHED" in | |
| "$WANT"*) ;; | |
| *) | |
| echo "::error::Pushed tag '$RELEASE_TAG' does not match SQLITE_TAG file contents '$TAG'. Update SQLITE_TAG in the tagged commit, or push a matching tag." | |
| exit 1 | |
| ;; | |
| esac | |
| else | |
| RELEASE_TAG="$TAG" | |
| fi | |
| echo "Building upstream tag: $TAG (release tag: $RELEASE_TAG)" | |
| { | |
| echo "sqlite_tag=$TAG" | |
| echo "release_tag=$RELEASE_TAG" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Install build dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y --no-install-recommends tcl tcl-dev zip | |
| - name: Fetch SQLite source at tag | |
| run: | | |
| git clone --depth 1 --branch "${{ steps.resolve.outputs.sqlite_tag }}" \ | |
| -c advice.detachedHead=false \ | |
| https://github.com/sqlite/sqlite.git sqlite-src | |
| - name: Build amalgamation | |
| working-directory: sqlite-src | |
| run: | | |
| set -euo pipefail | |
| ./configure | |
| make sqlite3.c | |
| # Old tags (pre-3.24) ship shell.c as a plain source file instead of a make target | |
| make shell.c || cp src/shell.c shell.c | |
| - name: Package | |
| id: package | |
| run: | | |
| set -euo pipefail | |
| VERSION="$(tr -d " \t\r\n" < sqlite-src/VERSION)" | |
| IFS=. read -r MAJOR MINOR PATCH BRANCH <<< "$VERSION" | |
| # sqlite.org download naming: 3.X.Y -> 3XXYY00, 3.X.Y.Z -> 3XXYYZZ (e.g. 3.53.3 -> 3530300) | |
| NUM="$(printf '%d%02d%02d%02d' "$MAJOR" "$MINOR" "${PATCH:-0}" "${BRANCH:-0}")" | |
| DIR="sqlite-amalgamation-$NUM" | |
| mkdir "$DIR" | |
| cp sqlite-src/sqlite3.c sqlite-src/sqlite3.h sqlite-src/shell.c "$DIR"/ | |
| cp sqlite-src/src/sqlite3ext.h "$DIR"/ | |
| zip -9 -r "$DIR.zip" "$DIR" | |
| (cd "$DIR" && sha256sum sqlite3.c sqlite3.h shell.c sqlite3ext.h) > sha256sums.txt | |
| sha256sum "$DIR.zip" >> sha256sums.txt | |
| cat sha256sums.txt | |
| SOURCE_ID="$(sed -n 's/^#define SQLITE_SOURCE_ID[[:space:]]*"\(.*\)".*/\1/p' "$DIR/sqlite3.h")" | |
| { | |
| echo "version=$VERSION" | |
| echo "dir=$DIR" | |
| echo "zip=$DIR.zip" | |
| echo "source_id=$SOURCE_ID" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Create GitHub release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| RELEASE_TAG: ${{ steps.resolve.outputs.release_tag }} | |
| SQLITE_TAG: ${{ steps.resolve.outputs.sqlite_tag }} | |
| VERSION: ${{ steps.package.outputs.version }} | |
| DIR: ${{ steps.package.outputs.dir }} | |
| ZIP: ${{ steps.package.outputs.zip }} | |
| SOURCE_ID: ${{ steps.package.outputs.source_id }} | |
| run: | | |
| set -euo pipefail | |
| ASSETS=("$ZIP" "$DIR/sqlite3.c" "$DIR/sqlite3.h" "$DIR/shell.c" "$DIR/sqlite3ext.h" sha256sums.txt) | |
| { | |
| echo "SQLite **$VERSION** amalgamation, built from [sqlite/sqlite tag \`$SQLITE_TAG\`](https://github.com/sqlite/sqlite/releases/tag/$SQLITE_TAG) with \`./configure && make sqlite3.c shell.c\` on ubuntu-latest." | |
| echo | |
| echo '```' | |
| echo "SQLITE_SOURCE_ID: $SOURCE_ID" | |
| echo '```' | |
| echo | |
| echo "\`$ZIP\` matches the sqlite.org download layout (sqlite3.c, sqlite3.h, shell.c, sqlite3ext.h); the same four files are also attached individually, plus \`sha256sums.txt\`." | |
| } > notes.md | |
| if gh release view "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then | |
| echo "Release $RELEASE_TAG already exists; replacing assets" | |
| gh release upload "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" --clobber "${ASSETS[@]}" | |
| else | |
| gh release create "$RELEASE_TAG" \ | |
| --repo "$GITHUB_REPOSITORY" \ | |
| --target "$GITHUB_SHA" \ | |
| --title "SQLite $VERSION amalgamation" \ | |
| --notes-file notes.md \ | |
| "${ASSETS[@]}" | |
| fi |