Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/android-sdk-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
tags:
- v[0-9]+.[0-9]+.[0-9]+
- v[0-9]+.[0-9]+.[0-9]+-*
workflow_call:

jobs:
sdk-tests:
Expand Down
94 changes: 94 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Tag release

on:
workflow_dispatch:
inputs:
bump:
description: "Which part of the version to increment"
type: choice
options:
- minor
- major
- patch
default: minor

permissions:
contents: read

jobs:
tag:
name: Tag master
runs-on: ubuntu-24.04
permissions:
contents: write
outputs:
version: ${{ steps.next.outputs.version }}
steps:
- name: Refuse to release from anything but master
if: github.ref != 'refs/heads/master'
run: |
echo "::error::Release must run on master, got ${{ github.ref }}. Re-run and pick master."
exit 1

- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Compute next version
id: next
env:
BUMP: ${{ inputs.bump }}
run: |
set -euo pipefail
latest=$(git tag -l | grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+$' | sed 's/^v//' | sort -V | tail -n1 || true)
latest=${latest:-0.0.0}
IFS=. read -r major minor patch <<<"${latest}"
case "$BUMP" in
major) major=$((major + 1)); minor=0; patch=0 ;;
minor) minor=$((minor + 1)); patch=0 ;;
patch) patch=$((patch + 1)) ;;
esac
version="v${major}.${minor}.${patch}"
Comment thread
mosherBT marked this conversation as resolved.
Resolved
echo "${latest} -> ${version}"
echo "version=${version}" >>"$GITHUB_OUTPUT"
{
echo "### Release \`${version}\`"
echo ""
echo "Previous: \`${latest}\` · bump: \`${BUMP}\` · commit: \`${GITHUB_SHA:0:7}\`"
} >>"$GITHUB_STEP_SUMMARY"

- name: Create and push tag
env:
VERSION: ${{ steps.next.outputs.version }}
run: |
set -euo pipefail
for tag in "${VERSION}" "${VERSION#v}"; do
if git rev-parse -q --verify "refs/tags/${tag}" >/dev/null; then
echo "::error::${tag} already exists. Someone tagged out of band."
exit 1
fi
done
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "${VERSION}" -m "Release ${VERSION}"
git push origin "${VERSION}"
Comment thread
mosherBT marked this conversation as resolved.
Resolved

ci:
# Tags pushed with GITHUB_TOKEN don't trigger other workflows, so CI is called directly.
name: CI
needs: tag
uses: ./.github/workflows/android-sdk-ci.yml

release:
name: GitHub release
needs: [tag, ci]
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- name: Create release
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.tag.outputs.version }}
run: gh release create "${VERSION}" --repo "${GITHUB_REPOSITORY}" --verify-tag --title "${VERSION}" --generate-notes
8 changes: 6 additions & 2 deletions android_sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ plugins {
id("org.jetbrains.kotlinx.kover") version "0.9.4"
}

// JitPack builds releases from their tag and sets VERSION to it.
def jitpackVersion = System.getenv("JITPACK") == "true" ? System.getenv("VERSION")?.replaceFirst(/^v/, "") : null
def sdkVersionName = jitpackVersion ==~ /\d+\.\d+\.\d+(-.+)?/ ? jitpackVersion : optableVersionName

android {
compileSdk 35

Expand All @@ -13,14 +17,14 @@ android {
targetSdkVersion 35

versionCode optableVersionCode as Integer
versionName optableVersionName
versionName sdkVersionName
archivesBaseName = "optable-android-sdk"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"

buildConfigField "String", "VERSION_CODE", "\"${optableVersionCode}\""
buildConfigField "String", "VERSION_NAME", "\"${optableVersionName}\""
buildConfigField "String", "VERSION_NAME", "\"${sdkVersionName}\""
}

buildTypes {
Expand Down
Loading