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
9 changes: 3 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@ jobs:
build:
# we want to run ubuntu-latest but we'll pin to a specific version so CI is reproducable
runs-on: ubuntu-24.04
strategy:
matrix:
java: [ '17' ] # Java is

steps:
- uses: actions/checkout@v4

- name: Set up JDK ${{ matrix.java }}
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
java-version: 17
distribution: 'temurin'

- name: Grant execute permission for gradlew
Expand All @@ -34,5 +31,5 @@ jobs:
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-java-${{ matrix.java }}
name: test-results
path: build/test-results/test/
66 changes: 66 additions & 0 deletions .github/workflows/create-and-publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# This workflow creates a new release by running CI and then executing the release script.
# It can be run manually with a choice of which semver segment to bump.
name: Create And Publish Release
on:
workflow_dispatch:
inputs:
semver_segment_to_bump:
description: 'Which semver segment to bump'
required: true
default: 'PATCH'
type: choice
options:
- PATCH
- MINOR
- MAJOR
branch:
description: 'Branch to create release from'
required: true
default: 'main'
type: string

jobs:
ci:
name: Run CI
# we want to run ubuntu-latest but we'll pin to a specific version so CI is reproducable
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Run tests
run: ./gradlew check build

create-release:
name: Create Release
# we want to run ubuntu-latest but we'll pin to a specific version so CI is reproducable
runs-on: ubuntu-24.04
needs: ci
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
token: ${{ secrets.RELEASE_TOKEN }}
fetch-depth: 0

- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Run release script
run: |
chmod +x scripts/create-new-release.sh
scripts/create-new-release.sh --push=true --branch=${{ inputs.branch }} --semver-segment-to-bump=${{ inputs.semver_segment_to_bump }}
136 changes: 136 additions & 0 deletions .github/workflows/publish-existing-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# This workflow is triggered when a new tag is pushed to main.
# It can also be run manually to re-publish a release in case it failed for some reason.
name: Publish Existing Release

on:
push:
tags:
- 'v*'
branches:
- main
workflow_dispatch:
inputs:
tag:
description: 'Tag to publish (e.g., v1.0.0)'
required: true
type: string

jobs:
validate-and-publish:
name: Validate Tag and Publish Release
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Determine tag
id: determine-tag
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
TAG_NAME="${{ github.ref_name }}"
else
TAG_NAME="${{ inputs.tag }}"
fi
echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT
echo "Using tag: $TAG_NAME"

- name: Validate tag format
run: |
TAG="${{ steps.determine-tag.outputs.tag }}"

# Check if tag starts with 'v'
if [[ ! "$TAG" =~ ^v ]]; then
echo "Error: Tag '$TAG' must start with 'v'"
exit 1
fi

# Extract version without 'v' prefix
VERSION="${TAG#v}"

# Check if version is valid semver (x.y.z)
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Tag '$TAG' is not valid semver format (vx.y.z)"
exit 1
fi

# Check that version does not end with -SNAPSHOT
if [[ "$VERSION" =~ -SNAPSHOT$ ]]; then
echo "Error: Tag '$TAG' cannot end with '-SNAPSHOT'"
exit 1
fi

echo "Tag '$TAG' is valid"

- name: Verify tag exists
run: |
TAG="${{ steps.determine-tag.outputs.tag }}"
if ! git tag -l | grep -q "^$TAG$"; then
echo "Error: Tag '$TAG' does not exist"
exit 1
fi
echo "Tag '$TAG' exists"

- name: Checkout tag
run: |
git checkout ${{ steps.determine-tag.outputs.tag }}

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Run CI
run: ./gradlew check build

- name: Build release artifacts
run: ./gradlew publishToMavenLocal -Pversion=${{ steps.determine-tag.outputs.tag }}

- name: Find built artifacts
id: find-artifacts
run: |
VERSION="${{ steps.determine-tag.outputs.tag }}"
VERSION_NO_V="${VERSION#v}"

# Find the built JAR files
MAIN_JAR=$(find build/libs -name "*-${VERSION_NO_V}.jar" ! -name "*-sources.jar" ! -name "*-javadoc.jar" | head -1)
SOURCES_JAR=$(find build/libs -name "*-${VERSION_NO_V}-sources.jar" | head -1)
JAVADOC_JAR=$(find build/libs -name "*-${VERSION_NO_V}-javadoc.jar" | head -1)

echo "main-jar=$MAIN_JAR" >> $GITHUB_OUTPUT
echo "sources-jar=$SOURCES_JAR" >> $GITHUB_OUTPUT
echo "javadoc-jar=$JAVADOC_JAR" >> $GITHUB_OUTPUT

echo "Found artifacts:"
echo " Main JAR: $MAIN_JAR"
echo " Sources JAR: $SOURCES_JAR"
echo " Javadoc JAR: $JAVADOC_JAR"

- name: Create GitHub Release
run: |
TAG="${{ steps.determine-tag.outputs.tag }}"

# Create the release
gh release create "$TAG" \
--generate-notes \
--title "Release $TAG"

# Upload artifacts if they exist
if [[ -n "${{ steps.find-artifacts.outputs.main-jar }}" && -f "${{ steps.find-artifacts.outputs.main-jar }}" ]]; then
gh release upload "$TAG" "${{ steps.find-artifacts.outputs.main-jar }}"
fi

if [[ -n "${{ steps.find-artifacts.outputs.sources-jar }}" && -f "${{ steps.find-artifacts.outputs.sources-jar }}" ]]; then
gh release upload "$TAG" "${{ steps.find-artifacts.outputs.sources-jar }}"
fi

if [[ -n "${{ steps.find-artifacts.outputs.javadoc-jar }}" && -f "${{ steps.find-artifacts.outputs.javadoc-jar }}" ]]; then
gh release upload "$TAG" "${{ steps.find-artifacts.outputs.javadoc-jar }}"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ The remaining sections document developing the SDK itself. Nothing below is requ
- These hooks automatically run common checks for you but CI also runs the same checks before merging to the main branch is allowed
- NOTE: this will overwrite existing hooks. Take backups before running

<!-- ## Releasing the SDK -->

<!-- TODO: polish this section -->

<!-- - summary: push the button on github -->
<!-- - bumping a major -->

## Running a local OpenTelemetry collector

OpenTelemetry provides a local collector with a debug exporter which logs all traces, logs, and metrics to stdout.
Expand Down
Loading