Leverage boms for transient core deps #17
Workflow file for this run
This file contains 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: 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 | ||
# otel instrumentation version comes in through alpha bom | ||
# inst_version=$(grep ^opentelemetry-alpha gradle/libs.versions.toml | sed -E "s/^.*\"(.*)\"/\1/") | ||
inst_version=$(./gradlew --console=plain android-agent:dependencies | \ | ||
grep 'io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom ' | \ | ||
sed -e "s/.* -> //" | sed -e "s/ .*//" | \ | ||
sort | head -1) | ||
# otel-java core libs are transient deps thru instrumentation boms | ||
sdk_version=$(./gradlew --console=plain android-agent:dependencies | \ | ||
grep 'io.opentelemetry:opentelemetry-api ' | \ | ||
sed -e "s/.* -> //" | sed -e "s/ .*//" | \ | ||
sort | head -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: | | ||
gh release create --target $GITHUB_REF_NAME \ | ||
--title "Version $VERSION" \ | ||
--notes-file /tmp/release-notes.txt \ | ||
v$VERSION | ||
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} | ||