Skip to content

Release

Release #11

Workflow file for this run

---
name: Release
on:
workflow_dispatch:
jobs:
release:
name: "release"
runs-on: ubuntu-latest
steps:
- run: |
if [[ $GITHUB_REF_NAME != release/* ]]; then
echo This workflow can only be run against release branches
exit 1
fi
- uses: actions/checkout@v4
- name: Set environment variables
run: |
version=$(.github/scripts/get-version.sh)
if [[ $version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
patch="${BASH_REMATCH[3]}"
else
echo "unexpected version: $version"
exit 1
fi
if [[ $patch == 0 ]]; then
if [[ $minor == 0 ]]; then
prior_major=$((major - 1))
prior_minor=$(grep -Po "^## Version $prior_major.\K[0-9]+" CHANGELOG.md | head -1)
prior_version="$prior_major.$prior_minor"
else
prior_version="$major.$((minor - 1)).0"
fi
else
prior_version="$major.$minor.$((patch - 1))"
fi
inst_version=$(grep ^opentelemetry-alpha gradle/libs.versions.toml | sed -E "s/^.*\"(.*)\"/\1/")
sdk_version=$(cat gradle/libs.versions.toml | grep "^opentelemetry =" | sed -E "s/^.*\"(.*)\"/\1/")
echo "VERSION=$version" >> $GITHUB_ENV
echo "PRIOR_VERSION=$prior_version" >> $GITHUB_ENV
echo "INST_VERSION=$inst_version" >> $GITHUB_ENV
echo "OTEL_SDK_VERSION=$sdk_version" >> $GITHUB_ENV
# check out main branch to verify there won't be problems with merging the change log
# at the end of this workflow
- uses: actions/checkout@v4
with:
ref: main
- name: Check that change log update was merged to main
run: |
if [[ $VERSION == *.0 ]]; then
# not making a patch release
if ! grep --quiet "^## Version $VERSION " CHANGELOG.md; then
echo the pull request generated by prepare-release-branch.yml needs to be merged first
exit 1
fi
fi
# back to the release branch
- uses: actions/checkout@v4
with:
# tags are needed for the generate-release-contributors.sh script
fetch-depth: 0
- name: Set up JDK for running Gradle
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Build and publish artifacts
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -Pfinal=true
env:
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
- name: Generate release notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
.github/scripts/generate-release-notes.sh "$VERSION" "$PRIOR_VERSION" "$INST_VERSION" "$OTEL_SDK_VERSION"
- id: create-github-release
name: Create GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cp android-agent/build/outputs/aar/opentelemetry-android-release.aar opentelemetry-android.aar
gh release create --target $GITHUB_REF_NAME \
--title "Version $VERSION" \
--notes-file /tmp/release-notes.txt \
v$VERSION \
opentelemetry-android.aar
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create release tag for release builds
env:
GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
if: "${{ inputs.release_type == 'final' }}"
run: |
VERSION_NUMBER=$(grep ^version= gradle.properties | sed -e 's/^.*=//')
VERSION="v${VERSION_NUMBER}"
git tag ${VERSION}
git push origin ${VERSION}