Skip to content

Commit 19c2e3f

Browse files
authored
GitHub action sync (#592)
sync'ing with latest in https://github.com/trask/repository-practices
1 parent ec32e3a commit 19c2e3f

11 files changed

+140
-101
lines changed

.github/scripts/draft-change-log-entries.sh

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@ else
2424
fi
2525

2626
declare -A component_names=()
27-
component_names["aws-resources/"]="AWS Resources"
28-
component_names["aws-xray/"]="AWS X-Ray SDK Support"
29-
component_names["aws-xray-propagator/"]="AWS X-Ray Propagator"
27+
component_names["aws-resources/"]="AWS resources"
28+
component_names["aws-xray/"]="AWS X-Ray SDK support"
29+
component_names["aws-xray-propagator/"]="AWS X-Ray propagator"
3030
component_names["consistent-sampling/"]="Consistent sampling"
31+
component_names["jfr-events/"]="JFR events"
3132
component_names["jfr-streaming/"]="JFR streaming"
3233
component_names["jmx-metrics/"]="JMX metrics"
3334
component_names["maven-extension/"]="Maven extension"
3435
component_names["micrometer-meter-provider/"]="Micrometer MeterProvider"
36+
component_names["noop-api/"]="No-op API"
3537
component_names["runtime-attach/"]="Runtime attach"
38+
component_names["resource-providers/"]="Resource providers"
3639
component_names["samplers/"]="Samplers"
3740
component_names["static-instrumenter/"]="Static instrumenter"
3841

@@ -41,10 +44,17 @@ echo
4144

4245
for component in */ ; do
4346
component_name=${component_names[$component]:=$component}
44-
echo "### $component_name"
45-
echo
46-
git log --reverse --pretty=format:"- %s" $range $component \
47-
| sed -r 's,\(#([0-9]+)\),\n ([#\1](https://github.com/open-telemetry/opentelemetry-java-contrib/pull/\1)),'
48-
echo
49-
echo
47+
commits=$(git log --reverse \
48+
--perl-regexp \
49+
--author='^(?!dependabot\[bot\] )' \
50+
--pretty=format:"- %s" \
51+
"$range" \
52+
"$component")
53+
if [[ "$commits" != "" ]]; then
54+
echo "### $component_name"
55+
echo
56+
echo "$commits" \
57+
| sed -E 's,\(#([0-9]+)\)$,\n ([#\1](https://github.com/open-telemetry/opentelemetry-java-contrib/pull/\1)),'
58+
echo
59+
fi
5060
done
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash -e
2+
3+
# this script merges release notes for $VERSION into CHANGELOG.md
4+
# the release date for $VERSION should be available in $RELEASE_DATE
5+
# and the release notes for $VERSION should be available in /tmp/changelog-section.md
6+
7+
if [[ $VERSION =~ ^[0-9]+\.[0-9]+\.0 ]]; then
8+
# this was not a patch release, so the version exists already in the CHANGELOG.md
9+
10+
# update the release date
11+
sed -Ei "s/## Version $VERSION .*/## Version $VERSION ($RELEASE_DATE)/" CHANGELOG.md
12+
13+
# the entries are copied over from the release branch to support workflows
14+
# where change log entries may be updated after preparing the release branch
15+
16+
{
17+
# copy the portion above the release, up to and including the heading
18+
sed -n "0,/^## Version $VERSION /p" CHANGELOG.md
19+
# copy the release notes for $VERSION
20+
cat /tmp/changelog-section.md
21+
# copy the portion below the release
22+
sed -n "0,/^## Version $VERSION /d;0,/^## Version /{/^## Version/!d};p" CHANGELOG.md
23+
} > /tmp/CHANGELOG.md
24+
25+
# update the real CHANGELOG.md
26+
cp /tmp/CHANGELOG.md CHANGELOG.md
27+
28+
else
29+
# this was a patch release, so the version does not exist already in the CHANGELOG.md
30+
31+
{
32+
# copy the portion above the top-most release, not including the heading
33+
sed -n "0,/^## Version /{ /^## Version /!p }" CHANGELOG.md
34+
# add the heading
35+
echo "## Version $VERSION ($RELEASE_DATE)"
36+
# copy the release notes for $VERSION
37+
cat /tmp/changelog-section.md
38+
# copy the portion starting from the top-most release
39+
sed -n "/^## Version /,\$p" CHANGELOG.md
40+
} > /tmp/CHANGELOG.md
41+
42+
# update the real CHANGELOG.md
43+
cp /tmp/CHANGELOG.md CHANGELOG.md
44+
fi

.github/workflows/backport.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ jobs:
2828
env:
2929
NUMBER: ${{ github.event.inputs.number }}
3030
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
31-
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
31+
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
3232
run: |
3333
commit=$(gh pr view $NUMBER --json mergeCommit --jq .mergeCommit.oid)
3434
title=$(gh pr view $NUMBER --json title --jq .title)
3535
3636
branch="opentelemetrybot/backport-${NUMBER}-to-${GITHUB_REF_NAME//\//-}"
3737
38+
git checkout -b $branch
3839
git cherry-pick $commit
39-
git push origin HEAD:$branch
40+
git push --set-upstream origin $branch
4041
gh pr create --title "[$GITHUB_REF_NAME] $title" \
4142
--body "Clean cherry-pick of #$NUMBER to the \`$GITHUB_REF_NAME\` branch." \
42-
--head $branch \
4343
--base $GITHUB_REF_NAME

.github/workflows/build.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,12 @@ jobs:
6262
path: jmx-metrics/build/reports/tests/integrationTest
6363

6464
markdown-link-check:
65-
# release branches are excluded to avoid unnecessary maintenance if external links break
66-
if: ${{ !startsWith(github.ref_name, 'release/') }}
65+
# release branches are excluded to avoid unnecessary maintenance
66+
if: "!startsWith(github.ref_name, 'release/')"
6767
uses: ./.github/workflows/reusable-markdown-link-check.yml
6868

6969
misspell-check:
70-
# release branches are excluded to avoid unnecessary maintenance if new misspellings are added
71-
# to the misspell dictionary
70+
# release branches are excluded to avoid unnecessary maintenance
7271
if: ${{ !startsWith(github.ref_name, 'release/') }}
7372
uses: ./.github/workflows/reusable-misspell-check.yml
7473

@@ -111,15 +110,13 @@ jobs:
111110
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
112111

113112
required-status-check:
113+
# markdown-link-check is not required so pull requests are not blocked if external links break
114+
# misspell-check is not required so pull requests are not blocked if new misspellings are added
114115
needs:
115-
# markdown-link-check is not required so that pull requests will not be blocked if external
116-
# links break
117-
# similarly misspell-check is not required so that pull requests will not be blocked if new
118-
# misspellings are added to the misspell dictionary
119116
- build
120117
- integration-test
121-
runs-on: ubuntu-latest
122118
if: always()
119+
runs-on: ubuntu-latest
123120
steps:
124121
- if: |
125122
needs.build.result != 'success' ||

.github/workflows/codeql-daily.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: CodeQL (daily)
22

33
on:
44
schedule:
5+
# Daily at 01:30 (UTC)
56
- cron: '30 1 * * *'
67
workflow_dispatch:
78

@@ -33,6 +34,7 @@ jobs:
3334

3435
open-issue-on-failure:
3536
# open an issue on failure because it can be easy to miss CI failure notifications
36-
needs: analyze
37-
if: failure()
37+
needs:
38+
- analyze
39+
if: failure() && github.run_attempt == 1
3840
uses: ./.github/workflows/reusable-open-issue-on-failure.yml

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ jobs:
4545
- name: Create pull request
4646
env:
4747
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
48-
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
48+
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
4949
run: |
5050
message="Prepare release $VERSION"
5151
branch="opentelemetrybot/prepare-release-${VERSION}"
5252
53+
git checkout -b $branch
5354
git commit -a -m "$message"
54-
git push origin HEAD:$branch
55+
git push --set-upstream origin $branch
5556
gh pr create --title "[$GITHUB_REF_NAME] $message" \
5657
--body "$message." \
57-
--head $branch \
5858
--base $GITHUB_REF_NAME

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ jobs:
88
steps:
99
- uses: actions/checkout@v3
1010

11-
- run: |
11+
- name: Verify prerequisites
12+
run: |
1213
if [[ $GITHUB_REF_NAME != main ]]; then
1314
echo this workflow should only be run against main
1415
exit 1
@@ -21,7 +22,8 @@ jobs:
2122
2223
create-pull-request-against-release-branch:
2324
runs-on: ubuntu-latest
24-
needs: prereqs
25+
needs:
26+
- prereqs
2527
steps:
2628
- uses: actions/checkout@v3
2729

@@ -55,21 +57,22 @@ jobs:
5557
- name: Create pull request against the release branch
5658
env:
5759
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
58-
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
60+
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
5961
run: |
6062
message="Prepare release $VERSION"
6163
branch="opentelemetrybot/prepare-release-${VERSION}"
6264
65+
git checkout -b $branch
6366
git commit -a -m "$message"
64-
git push origin HEAD:$branch
67+
git push --set-upstream origin $branch
6568
gh pr create --title "[$RELEASE_BRANCH_NAME] $message" \
6669
--body "$message." \
67-
--head $branch \
6870
--base $RELEASE_BRANCH_NAME
6971
7072
create-pull-request-against-main:
7173
runs-on: ubuntu-latest
72-
needs: prereqs
74+
needs:
75+
- prereqs
7376
steps:
7477
- uses: actions/checkout@v3
7578

@@ -103,15 +106,15 @@ jobs:
103106
- name: Create pull request against main
104107
env:
105108
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
106-
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
109+
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
107110
run: |
108111
message="Update version to $NEXT_VERSION"
109112
body="Update version to \`$NEXT_VERSION\`."
110113
branch="opentelemetrybot/update-version-to-${NEXT_VERSION}"
111114
115+
git checkout -b $branch
112116
git commit -a -m "$message"
113-
git push origin HEAD:$branch
117+
git push --set-upstream origin $branch
114118
gh pr create --title "$message" \
115119
--body "$body" \
116-
--head $branch \
117120
--base main

0 commit comments

Comments
 (0)