Skip to content

Retroactively Generate JARs #47

Retroactively Generate JARs

Retroactively Generate JARs #47

Workflow file for this run

name: Retroactively Generate JARs
on:
workflow_dispatch:
inputs:
core-version:
description: 'Core version to regenerate JARs for (e.g. 11.4.0, no v prefix)'
required: true
type: string
java-version:
description: 'JDK version used to build (e.g. 21.0.7 for modern releases, 15.0.2 for older backports)'
required: false
type: string
default: '21.0.7'
plugin-interface-version:
description: 'Exact stable plugin-interface version (optional for retroactive builds)'
required: false
type: string
postgresql-plugin-version:
description: 'Exact stable PostgreSQL plugin version (optional for retroactive builds)'
required: false
type: string
commit-to-github:
description: 'Also commit the generated JARs to the GitHub repositories and update tags'
required: false
type: boolean
default: false
workflow_call:
inputs:
core-version:
required: true
type: string
java-version:
required: false
type: string
default: '21.0.7'
plugin-interface-version:
required: false
type: string
postgresql-plugin-version:
required: false
type: string
commit-to-github:
required: false
type: boolean
default: false
jobs:
generate-jars:
environment: publish
runs-on: ubuntu-latest
concurrency:
group: generate-jars-${{ inputs.core-version }}
cancel-in-progress: false
steps:
- name: Checkout workflow tooling
uses: actions/checkout@v4
with:
path: ./workflow-tools
- name: Set up JDK ${{ inputs.java-version }}
uses: actions/setup-java@v2
with:
java-version: ${{ inputs.java-version }}
distribution: zulu
- name: Checkout supertokens-root
uses: actions/checkout@v4
with:
repository: supertokens/supertokens-root
path: ./supertokens-root
ref: ${{ startsWith(inputs.java-version, '15') && 'for_jdk_15_releases' || 'master' }}
- name: Clone repositories
run: |
cd supertokens-root
git clone https://${{ secrets.GH_TOKEN }}@github.com/supertokens/supertokens-core.git
git clone https://${{ secrets.GH_TOKEN }}@github.com/supertokens/supertokens-plugin-interface.git
git clone https://${{ secrets.GH_TOKEN }}@github.com/supertokens/supertokens-postgresql-plugin.git
- name: Discover related versions
id: versions
env:
CORE_VERSION: ${{ inputs.core-version }}
INPUT_PLUGIN_INTERFACE_VERSION: ${{ inputs.plugin-interface-version }}
INPUT_POSTGRESQL_VERSION: ${{ inputs.postgresql-plugin-version }}
CORE_DIR: ${{ github.workspace }}/supertokens-root/supertokens-core
PLUGIN_INTERFACE_DIR: ${{ github.workspace }}/supertokens-root/supertokens-plugin-interface
POSTGRESQL_DIR: ${{ github.workspace }}/supertokens-root/supertokens-postgresql-plugin
run: ./workflow-tools/.github/helpers/discover-package-versions.sh
- name: Checkout release tags
run: |
CORE_VER="${{ inputs.core-version }}"
PI_VER="${{ steps.versions.outputs.pi_version }}"
PG_VER="${{ steps.versions.outputs.pg_version }}"
git -C supertokens-root/supertokens-core checkout "v${CORE_VER}"
git -C supertokens-root/supertokens-plugin-interface checkout "v${PI_VER}"
git -C supertokens-root/supertokens-postgresql-plugin checkout "v${PG_VER}"
- name: Set up Gradle project
run: |
cd supertokens-root
{
echo "include 'supertokens-core'"
echo "include 'supertokens-plugin-interface'"
echo "include 'supertokens-postgresql-plugin'"
for mod in cli downloader ee; do
[[ -d "supertokens-core/$mod" ]] && echo "include 'supertokens-core:$mod'"
done
} > settings.gradle
- name: Git config
run: |
git config --global user.name "Supertokens Bot"
git config --global user.email "<>"
# ── plugin-interface ────────────────────────────────────────────────
- name: Build JARs for plugin-interface
run: |
cd supertokens-root/supertokens-plugin-interface
./runBuild
- name: Distribute JARs for plugin-interface
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ vars.AWS_REGION }}
S3_BUCKET: ${{ vars.S3_BUCKET }}
S3_JAR_PREFIX: ${{ vars.S3_JAR_PREFIX }}
COMMIT_TO_GITHUB: ${{ inputs.commit-to-github }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
PI_VER="${{ steps.versions.outputs.pi_version }}"
S3_JAR_PREFIX="${S3_JAR_PREFIX%/}"
cd supertokens-root/supertokens-plugin-interface
# S3 upload
if [[ -z "$S3_BUCKET" ]]; then
echo "S3_BUCKET is required to publish plugin-interface JARs" >&2
exit 1
else
s3_dest="s3://${S3_BUCKET}/${S3_JAR_PREFIX:+$S3_JAR_PREFIX/}supertokens-plugin-interface/v${PI_VER}/"
if aws s3 sync ./jar/ "$s3_dest"; then
echo "✓ Uploaded plugin-interface v${PI_VER} JARs to S3"
else
echo "Failed to upload plugin-interface v${PI_VER} JARs to S3" >&2
exit 1
fi
fi
# GitHub commit (only when checkbox is ticked)
if [[ "$COMMIT_TO_GITHUB" == "true" ]]; then
git add --all "./jar/*" > /dev/null 2>&1
if git diff --cached --quiet 2>/dev/null; then
echo "plugin-interface JARs unchanged — no GitHub commit needed"
elif git commit -m "build for release v${PI_VER}"; then
git push --delete origin "v${PI_VER}" 2>/dev/null || true
git tag --delete "v${PI_VER}" 2>/dev/null || true
git tag "v${PI_VER}" HEAD
if git push --force origin "v${PI_VER}"; then
PI_MINOR=$(echo "${PI_VER}" | cut -d. -f1,2)
git push origin "HEAD:refs/heads/${PI_MINOR}" || \
echo "::warning::Branch ${PI_MINOR} is ahead of v${PI_VER} — commit reachable only via tag"
# Deleting the tag drafts the GitHub release — re-publish it
gh release edit "v${PI_VER}" \
--repo supertokens/supertokens-plugin-interface \
--draft=false || \
echo "::warning::Could not re-publish GitHub release v${PI_VER} for plugin-interface — publish manually"
echo "✓ Committed plugin-interface JARs to GitHub and updated tag v${PI_VER}"
else
echo "::warning::Committed plugin-interface JARs but failed to update tag v${PI_VER} on GitHub"
fi
else
echo "::warning::Failed to commit plugin-interface JARs to GitHub"
fi
fi
# ── postgresql-plugin ───────────────────────────────────────────────
- name: Build JARs for postgresql-plugin
run: |
cd supertokens-root/supertokens-postgresql-plugin
./runBuild
- name: Distribute JARs for postgresql-plugin
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ vars.AWS_REGION }}
S3_BUCKET: ${{ vars.S3_BUCKET }}
S3_JAR_PREFIX: ${{ vars.S3_JAR_PREFIX }}
COMMIT_TO_GITHUB: ${{ inputs.commit-to-github }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
PG_VER="${{ steps.versions.outputs.pg_version }}"
S3_JAR_PREFIX="${S3_JAR_PREFIX%/}"
cd supertokens-root/supertokens-postgresql-plugin
# S3 upload
if [[ -z "$S3_BUCKET" ]]; then
echo "S3_BUCKET is required to publish PostgreSQL plugin JARs" >&2
exit 1
else
s3_dest="s3://${S3_BUCKET}/${S3_JAR_PREFIX:+$S3_JAR_PREFIX/}supertokens-postgresql-plugin/v${PG_VER}/"
if aws s3 sync ./jar/ "$s3_dest"; then
echo "✓ Uploaded postgresql-plugin v${PG_VER} JARs to S3"
else
echo "Failed to upload postgresql-plugin v${PG_VER} JARs to S3" >&2
exit 1
fi
fi
# GitHub commit (only when checkbox is ticked)
if [[ "$COMMIT_TO_GITHUB" == "true" ]]; then
git add --all "./jar/*" > /dev/null 2>&1
if git diff --cached --quiet 2>/dev/null; then
echo "postgresql-plugin JARs unchanged — no GitHub commit needed"
elif git commit -m "build for release v${PG_VER}"; then
git push --delete origin "v${PG_VER}" 2>/dev/null || true
git tag --delete "v${PG_VER}" 2>/dev/null || true
git tag "v${PG_VER}" HEAD
if git push --force origin "v${PG_VER}"; then
PG_MINOR=$(echo "${PG_VER}" | cut -d. -f1,2)
git push origin "HEAD:refs/heads/${PG_MINOR}" || \
echo "::warning::Branch ${PG_MINOR} is ahead of v${PG_VER} — commit reachable only via tag"
# Deleting the tag drafts the GitHub release — re-publish it
gh release edit "v${PG_VER}" \
--repo supertokens/supertokens-postgresql-plugin \
--draft=false || \
echo "::warning::Could not re-publish GitHub release v${PG_VER} for postgresql-plugin — publish manually"
echo "✓ Committed postgresql-plugin JARs to GitHub and updated tag v${PG_VER}"
else
echo "::warning::Committed postgresql-plugin JARs but failed to update tag v${PG_VER} on GitHub"
fi
else
echo "::warning::Failed to commit postgresql-plugin JARs to GitHub"
fi
fi
# ── core ────────────────────────────────────────────────────────────
- name: Build JARs for core
run: |
cd supertokens-root/supertokens-core
./runBuild
- name: Distribute JARs for core
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ vars.AWS_REGION }}
S3_BUCKET: ${{ vars.S3_BUCKET }}
S3_JAR_PREFIX: ${{ vars.S3_JAR_PREFIX }}
COMMIT_TO_GITHUB: ${{ inputs.commit-to-github }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
CORE_VER="${{ inputs.core-version }}"
S3_JAR_PREFIX="${S3_JAR_PREFIX%/}"
cd supertokens-root/supertokens-core
# S3 upload — gather main JAR and all sub-module JARs into a staging dir
if [[ -z "$S3_BUCKET" ]]; then
echo "S3_BUCKET is required to publish core JARs" >&2
exit 1
else
staging=$(mktemp -d)
cp ./jar/* "$staging/" 2>/dev/null || true
for mod in cli downloader ee; do
[[ -d "./$mod/jar" ]] && cp ./$mod/jar/* "$staging/" 2>/dev/null || true
done
s3_dest="s3://${S3_BUCKET}/${S3_JAR_PREFIX:+$S3_JAR_PREFIX/}supertokens-core/v${CORE_VER}/"
if aws s3 sync "$staging/" "$s3_dest"; then
echo "✓ Uploaded core v${CORE_VER} JARs to S3"
else
echo "Failed to upload core v${CORE_VER} JARs to S3" >&2
exit 1
fi
rm -rf "$staging"
fi
# GitHub commit (only when checkbox is ticked)
if [[ "$COMMIT_TO_GITHUB" == "true" ]]; then
git add --all "./jar/*" > /dev/null 2>&1
git add --all "./**/jar/*" > /dev/null 2>&1
if git diff --cached --quiet 2>/dev/null; then
echo "core JARs unchanged — no GitHub commit needed"
elif git commit -m "build for release v${CORE_VER}"; then
git push --delete origin "v${CORE_VER}" 2>/dev/null || true
git tag --delete "v${CORE_VER}" 2>/dev/null || true
git tag "v${CORE_VER}" HEAD
if git push --force origin "v${CORE_VER}"; then
CORE_MINOR=$(echo "${CORE_VER}" | cut -d. -f1,2)
git push origin "HEAD:refs/heads/${CORE_MINOR}" || \
echo "::warning::Branch ${CORE_MINOR} is ahead of v${CORE_VER} — commit reachable only via tag"
# Deleting the tag drafts the GitHub release — re-publish it
gh release edit "v${CORE_VER}" \
--repo supertokens/supertokens-core \
--draft=false || \
echo "::warning::Could not re-publish GitHub release v${CORE_VER} for core — publish manually"
echo "✓ Committed core JARs to GitHub and updated tag v${CORE_VER}"
else
echo "::warning::Committed core JARs but failed to update tag v${CORE_VER} on GitHub"
fi
else
echo "::warning::Failed to commit core JARs to GitHub"
fi
fi
- name: Build and upload downloadable packages
env:
CORE_VERSION: ${{ inputs.core-version }}
PLUGIN_INTERFACE_VERSION: ${{ steps.versions.outputs.pi_version }}
POSTGRESQL_VERSION: ${{ steps.versions.outputs.pg_version }}
ROOT_DIR: ${{ github.workspace }}/supertokens-root
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ vars.AWS_REGION }}
S3_BUCKET: ${{ vars.S3_BUCKET }}
S3_JAR_PREFIX: ${{ vars.S3_JAR_PREFIX }}
S3_JRE_PREFIX: core-runtime/jre
S3_PACKAGE_PREFIX: packages/v1
run: ./workflow-tools/.github/helpers/build-core-packages.sh