Skip to content

Commit bcad96e

Browse files
authored
Sync workflows (#340)
* Sync workflows * collapse
1 parent 5794fc0 commit bcad96e

15 files changed

+140
-105
lines changed
Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash -e
22

3-
version=$(grep -Eo "[0-9]+.[0-9]+.0" version.gradle.kts)
3+
version=$("$(dirname "$0")/get-version.sh")
44

5-
if [[ $version =~ ([0-9]+).([0-9]+).0 ]]; then
5+
if [[ $version =~ ([0-9]+)\.([0-9]+)\.0 ]]; then
66
major="${BASH_REMATCH[1]}"
77
minor="${BASH_REMATCH[2]}"
88
else
@@ -12,17 +12,33 @@ fi
1212

1313
if [[ $minor == 0 ]]; then
1414
prior_major=$((major - 1))
15-
prior_minor=$(grep -Po "^## Version $prior_major.\K([0-9]+)" CHANGELOG.md | head -1)
16-
prior_version="$prior_major.$prior_minor"
15+
prior_minor=$(sed -n "s/^## Version $prior_major\.\([0-9]\+\)\..*/\1/p" CHANGELOG.md | head -1)
16+
if [[ -z $prior_minor ]]; then
17+
# assuming this is the first release
18+
range=
19+
else
20+
range="v$prior_major.$prior_minor.0..HEAD"
21+
fi
1722
else
18-
prior_version="$major.$((minor - 1)).0"
23+
range="v$major.$((minor - 1)).0..HEAD"
1924
fi
2025

21-
for component in aws-xray consistent-sampling jfr-streaming jmx-metrics maven-extension runtime-attach samplers; do
22-
echo "### $component"
26+
declare -A component_names=()
27+
component_names["aws-xray/"]="AWS X-Ray"
28+
component_names["consistent-sampling/"]="Consistent sampling"
29+
component_names["jfr-streaming/"]="JFR streaming"
30+
component_names["jmx-metrics/"]="JMX metrics"
31+
component_names["maven-extension/"]="Maven extension"
32+
component_names["runtime-attach/"]="Runtime attach"
33+
component_names["samplers/"]="Samplers"
34+
component_names["static-instrumenter/"]="Static instrumenter"
35+
36+
for component in */ ; do
37+
component_name=${component_names[$component]:=$component}
38+
echo "### $component_name"
2339
echo
24-
git log --reverse --pretty=format:"- %s" "v$prior_version"..HEAD $component \
25-
| sed -r 's,\(#([0-9]+)\),\n ([#\1](https://github.com/open-telemetry/opentelemetry-java-contrib/pull/\1)),'
40+
git log --reverse --pretty=format:"- %s" $range $component \
41+
| sed -r 's,\(#([0-9]+)\),\n ([#\1](https://github.com/open-telemetry/opentelemetry-java-contrib/pull/\1)),'
2642
echo
2743
echo
2844
done

.github/scripts/get-version.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash -e
2+
3+
grep -Po "val stableVersion = \"\K[0-9]+.[0-9]+.0" version.gradle.kts

.github/scripts/markdown-link-check-with-retry.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash -e
22

3+
# this script helps to reduce sporadic link check failures by retrying at a file-by-file level
4+
35
retry_count=3
46

57
for file in "$@"; do

.github/scripts/set-git-user.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash -e
2+
3+
git config user.name opentelemetry-java-bot
4+
git config user.email [email protected]

.github/scripts/update-version.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash -e
2+
3+
version=$1
4+
5+
if [[ $version == *-SNAPSHOT ]]; then
6+
alpha_version=${version//-SNAPSHOT/-alpha-SNAPSHOT}
7+
else
8+
alpha_version=$version-alpha
9+
fi
10+
11+
sed -Ei "s/val stableVersion = \"[^\"]*\"/val stableVersion = \"$version\"/" version.gradle.kts
12+
sed -Ei "s/val alphaVersion = \"[^\"]*\"/val alphaVersion = \"$alpha_version\"/" version.gradle.kts

.github/workflows/backport.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,19 @@ jobs:
1616
fetch-depth: 0
1717

1818
- name: Set git user
19-
run: |
20-
git config user.name opentelemetry-java-bot
21-
git config user.email [email protected]
19+
run: .github/scripts/set-git-user.sh
2220

2321
- name: Create pull request
2422
env:
2523
NUMBER: ${{ github.event.inputs.number }}
24+
# not using the default GITHUB_TOKEN because pull requests generated by it do not run any workflows
2625
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
2726
run: |
2827
commit=$(gh pr view $NUMBER --json mergeCommit --jq .mergeCommit.oid)
2928
title=$(gh pr view $NUMBER --json title --jq .title)
3029
url=$(gh pr view $NUMBER --json url --jq .url)
3130
32-
branch=backport-$NUMBER-to-${GITHUB_REF_NAME//\//-}
31+
branch="backport-${NUMBER}-to-${GITHUB_REF_NAME//\//-}"
3332
3433
git cherry-pick $commit
3534
git push origin HEAD:$branch

.github/workflows/build.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,18 @@ jobs:
7373
uses: ./.github/workflows/reusable-misspell-check.yml
7474

7575
publish-snapshots:
76+
# the condition is on the steps below instead of here on the job, because skipping the job
77+
# causes the job to show up as canceled in the GitHub UI which prevents the build section from
78+
# collapsing when everything (else) is green
79+
#
80+
# and the name is updated when the steps below are skipped which makes what's happening clearer
81+
# in the GitHub UI
82+
name: publish-snapshots${{ github.ref_name == 'main' && github.repository == 'open-telemetry/opentelemetry-java-contrib' && '' || ' (skipped)' }}
7683
needs:
7784
# intentionally not blocking snapshot publishing on markdown-link-check or misspell-check
7885
- build
7986
- integration-test
8087
runs-on: ubuntu-latest
81-
# skipping release branches because the versions in those branches are not snapshots
82-
# (also this skips pull requests)
83-
if: ${{ github.ref_name == 'main' && github.repository == 'open-telemetry/opentelemetry-java-contrib' }}
8488
steps:
8589
- uses: actions/checkout@v3
8690

@@ -92,6 +96,9 @@ jobs:
9296

9397
- name: Build and publish snapshots
9498
uses: gradle/gradle-build-action@v2
99+
# skipping release branches because the versions in those branches are not snapshots
100+
# (also this skips pull requests)
101+
if: ${{ github.ref_name == 'main' && github.repository == 'open-telemetry/opentelemetry-java-contrib' }}
95102
with:
96103
arguments: assemble publishToSonatype
97104
env:

.github/workflows/codeql-daily.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Nightly CodeQL analysis
1+
name: CodeQL (daily)
22

33
on:
44
schedule:
@@ -13,7 +13,7 @@ jobs:
1313
- uses: actions/checkout@v3
1414

1515
- name: Set up Java 17
16-
uses: actions/setup-java@v2
16+
uses: actions/setup-java@v3
1717
with:
1818
distribution: temurin
1919
java-version: 17
@@ -35,6 +35,7 @@ jobs:
3535
uses: github/codeql-action/analyze@v2
3636

3737
open-issue-on-failure:
38+
# open an issue on failure because it can be easy to miss CI failure notifications
3839
needs: analyze
3940
if: failure()
40-
uses: ./.github/workflows/reusable-create-issue-for-failure.yml
41+
uses: ./.github/workflows/reusable-open-issue-on-failure.yml

.github/workflows/merge-change-log-to-main.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,21 @@ jobs:
1515
fetch-depth: 0
1616

1717
- name: Set git user
18-
run: |
19-
git config user.name opentelemetry-java-bot
20-
git config user.email [email protected]
18+
run: .github/scripts/set-git-user.sh
2119

2220
# this will fail if there have been conflicting change log updates introduced in main
2321
- name: Create pull request against main
2422
env:
23+
# not using the default GITHUB_TOKEN because pull requests generated by it do not run any workflows
2524
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
2625
run: |
2726
message="Merge change log updates from $GITHUB_REF_NAME"
2827
body="Merge change log updates from \`$GITHUB_REF_NAME\`."
29-
branch=merge-change-log-updates-from-${GITHUB_REF_NAME//\//-}
28+
branch="merge-change-log-updates-from-${GITHUB_REF_NAME//\//-}"
3029
30+
# perform a 3-way merge of a single file
3131
git format-patch --stdout HEAD..origin/$GITHUB_REF_NAME CHANGELOG.md | git apply --3way
32+
3233
git commit -a -m "$message"
3334
git push origin HEAD:$branch
3435
gh pr create --title "$message" \

.github/workflows/prepare-patch-release.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ jobs:
1010

1111
- name: Set environment variables
1212
run: |
13-
prior_version=$(grep -Eo "[0-9]+.[0-9]+.[0-9]+" version.gradle.kts)
14-
if [[ $prior_version =~ ([0-9]+.[0-9]+).([0-9]+) ]]; then
13+
version=$(.github/scripts/get-version.sh)
14+
if [[ $version =~ ([0-9]+\.[0-9]+)\.([0-9]+) ]]; then
1515
major_minor="${BASH_REMATCH[1]}"
1616
patch="${BASH_REMATCH[2]}"
1717
else
18-
echo "unexpected version: $prior_version"
18+
echo "unexpected version: $version"
1919
exit 1
2020
fi
2121
echo "VERSION=$major_minor.$((patch + 1))" >> $GITHUB_ENV
@@ -28,20 +28,18 @@ jobs:
2828
fi
2929
3030
- name: Update version
31-
run: |
32-
sed -ri "s/[0-9]+\.[0-9]+\.[0-9]+/$VERSION/" version.gradle.kts
31+
run: .github/scripts/update-version.sh $VERSION
3332

3433
- name: Set git user
35-
run: |
36-
git config user.name opentelemetry-java-bot
37-
git config user.email [email protected]
34+
run: .github/scripts/set-git-user.sh
3835

3936
- name: Create pull request
4037
env:
38+
# not using the default GITHUB_TOKEN because pull requests generated by it do not run any workflows
4139
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
4240
run: |
4341
message="Prepare release $VERSION"
44-
branch=prepare-release-$VERSION
42+
branch="prepare-release-${VERSION}"
4543
4644
git commit -a -m "$message"
4745
git push origin HEAD:$branch

0 commit comments

Comments
 (0)