From 59fc2eef4e3ce22116948ca8c5d358d3e144fa58 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Mon, 1 Dec 2025 19:15:52 -0800 Subject: [PATCH] Move snapshot publishing to daily build --- .github/workflows/build-daily.yml | 45 +++++++++++++++++++ .github/workflows/build.yml | 11 ----- .../reusable-workflow-notification.yml | 44 ++++++++++++++++++ 3 files changed, 89 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/build-daily.yml create mode 100644 .github/workflows/reusable-workflow-notification.yml diff --git a/.github/workflows/build-daily.yml b/.github/workflows/build-daily.yml new file mode 100644 index 0000000..df4bd5f --- /dev/null +++ b/.github/workflows/build-daily.yml @@ -0,0 +1,45 @@ +name: Build (daily) + +on: + schedule: + # daily at 3:24 UTC + - cron: "24 3 * * *" + workflow_dispatch: + +permissions: + contents: read + +jobs: + publish-snapshots: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 + + - name: Set up JDK for running Gradle + uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0 + with: + distribution: temurin + java-version: 17 + + - name: Set up gradle + uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0 + + - name: Publish snapshots + run: ./gradlew assemble publishToSonatype + env: + SONATYPE_USER: ${{ secrets.SONATYPE_USER }} + SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }} + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }} + DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} + + workflow-notification: + permissions: + contents: read + issues: write + needs: + - publish-snapshots + if: always() + uses: ./.github/workflows/reusable-workflow-notification.yml + with: + success: ${{ needs.publish-snapshots.result == 'success' }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9c16c70..6fa3fa8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,14 +29,3 @@ jobs: run: ./gradlew build env: DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} - - - name: Publish snapshots - # skipping release branches because the versions in those branches are not snapshots - if: github.ref_name == 'main' && github.repository == 'open-telemetry/opentelemetry-proto-java' - run: ./gradlew publishToSonatype - env: - SONATYPE_USER: ${{ secrets.SONATYPE_USER }} - SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }} - GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} - GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }} - DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} diff --git a/.github/workflows/reusable-workflow-notification.yml b/.github/workflows/reusable-workflow-notification.yml new file mode 100644 index 0000000..80a98e9 --- /dev/null +++ b/.github/workflows/reusable-workflow-notification.yml @@ -0,0 +1,44 @@ +# this is useful because notifications for scheduled workflows are only sent to the user who +# initially created the given workflow +name: Reusable - Workflow notification + +on: + workflow_call: + inputs: + success: + type: boolean + required: true + +permissions: + contents: read + +jobs: + workflow-notification: + permissions: + contents: read + issues: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 + + - name: Open issue or add comment if issue already open + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # TODO (trask) search doesn't support exact phrases, so it's possible that this could grab the wrong issue + number=$(gh issue list --search "in:title Workflow failed: $GITHUB_WORKFLOW" --limit 1 --json number -q .[].number) + + echo $number + echo ${{ inputs.success }} + + if [[ $number ]]; then + if [[ "${{ inputs.success }}" == "true" ]]; then + gh issue close $number + else + gh issue comment $number \ + --body "See [$GITHUB_WORKFLOW #$GITHUB_RUN_NUMBER](https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)." + fi + elif [[ "${{ inputs.success }}" == "false" ]]; then + gh issue create --title "Workflow failed: $GITHUB_WORKFLOW (#$GITHUB_RUN_NUMBER)" \ + --body "See [$GITHUB_WORKFLOW #$GITHUB_RUN_NUMBER](https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)." + fi