Skip to content

Commit 6118a29

Browse files
committed
Update workflows from templates.
1 parent 75643fc commit 6118a29

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

.github/bump-version.get.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fi
2020

2121
# Find the version files in this directory or its descendants, but don't recurse too deep.
2222
# This line must be kept in sync with "bump-version.set.sh".
23-
VERSFILES=$(find . -maxdepth 3 ! -path ./.git/\* | grep -v /node_modules/ | grep -E '.*/(version|Cargo.toml|package.json|pom.xml|version.sbt)$')
23+
VERSFILES=$(find . -maxdepth 3 ! -path ./.git/\* | grep -v /node_modules/ | grep -E '.*/(version|Cargo.toml|version.go|package.json|pom.xml|version.sbt)$')
2424

2525
# Do we have at least one?
2626
if [ -z "${VERSFILES}" ] ; then
@@ -40,14 +40,17 @@ for FILE in ${VERSFILES} ; do
4040
Cargo.toml)
4141
VERS=$(cargo metadata --manifest-path "${FILE}" --no-deps --offline --format-version 1 | jq -re '.packages[0].version')
4242
;;
43+
version.go)
44+
VERS=$(grep "const Version" < "${FILE}" | sed -e 's/^[^"]*"//' -e 's/"$//')
45+
;;
4346
package.json)
4447
if [ "$(dirname "${FILE}")" = "." ] ; then
4548
# This is the root package.json, so we want .version.
4649
VERS=$(jq -re '.version' < "${FILE}")
4750
else
4851
# This isn't the root package.json, so we assume it depends on the package declared in the root package.json. We need to
4952
# get the root package's name.
50-
ROOTJSNAME=$(jq -re '.name' < package.json)
53+
ROOTJSNAME="$(jq -re '.name' < package.json)"
5154
VERS=$(jq -re ".dependencies[\"${ROOTJSNAME}\"]" < "${FILE}")
5255
# Strip off any leading "^".
5356
VERS=${VERS/^/}

.github/bump-version.set.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fi
3535

3636
# Find the version files in this directory or its descendants, but don't recurse too deep.
3737
# This line must be kept in sync with "bump-version.get.sh".
38-
VERSFILES=$(find . -maxdepth 3 ! -path ./.git/\* | grep -v /node_modules/ | grep -E '.*/(version|Cargo.toml|package.json|pom.xml|version.sbt)$')
38+
VERSFILES=$(find . -maxdepth 3 ! -path ./.git/\* | grep -v /node_modules/ | grep -E '.*/(version|Cargo.toml|version.go|package.json|pom.xml|version.sbt)$')
3939

4040
# Edit the version files.
4141
for FILE in ${VERSFILES} ; do
@@ -55,12 +55,18 @@ for FILE in ${VERSFILES} ; do
5555
fi
5656
;;
5757

58+
version.go)
59+
sed 's/const Version = ".*"/const Version = "'"${NEWVERS}"'"/' "${FILE}" > "${FILE}.tmp"
60+
mv "${FILE}.tmp" "${FILE}"
61+
;;
62+
5863
package.json)
59-
if [ "$(dirname "${FILE}")" = "." ] ; then
64+
if [ "${DIR}" = "." ] ; then
6065
# This is the root package.json, so we want .version.
6166
jq --indent 4 ".version=\"${NEWVERS}\"" "${FILE}" > "${FILE}.new"
6267
else
63-
# We already know the root package name from above, so reuse that here.
68+
# Get the root package's name.
69+
ROOTJSNAME="$(jq -re '.name' < package.json)"
6470
jq --indent 4 ".dependencies[\"${ROOTJSNAME}\"]=\"^${NEWVERS}\"" "${FILE}" > "${FILE}.new"
6571
fi
6672
mv "${FILE}.new" "${FILE}"
@@ -70,7 +76,7 @@ for FILE in ${VERSFILES} ; do
7076
# Replace -foo with -SNAPSHOT to be compatible with Java conventions.
7177
JAVAVERS="${NEWVERS/-*/-SNAPSHOT}"
7278

73-
if [ "$(dirname "${FILE}")" = "." ] ; then
79+
if [ "${DIR}" = "." ] ; then
7480
# This is the root pom.xml, so we want /m:project/m:version.
7581
xmlstarlet ed -L -P -N m="http://maven.apache.org/POM/4.0.0" -u "/m:project/m:version" -v "${JAVAVERS}" "${FILE}"
7682
else

.github/workflows/notify.yaml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,22 @@ name: Notify
2323
- Update Workflows
2424
types:
2525
- completed
26-
branches:
27-
- main
2826
jobs:
2927
on-failure:
3028
runs-on: ubuntu-20.04
31-
if: ${{ github.event.workflow_run.conclusion != 'success' }}
29+
if: ${{ github.event.workflow_run.conclusion != 'success' && (github.event.workflow_run.head_branch
30+
== 'main' || github.event.workflow_run.event == 'release')}}
3231
steps:
3332
- name: Post to Slack on failure
34-
run: "set -x\necho 'Failed a run of <${{ github.event.workflow_run.html_url\
35-
\ }}|${{ github.event.workflow_run.name }}> in ${{ github.event.repository.name\
36-
\ }}.' > text.txt\necho \"GitHub Workflow Bot\" > username.txt\necho \":bomb:\"\
37-
\ > icon_emoji.txt\n# echo \"https://i.chzbgr.com/full/8209966592/h2FE3826C/how-awesome-are-you\"\
38-
\ > icon_url.txt\necho \"#build-failures\" > channel.txt\necho '{}' | \\\n\
39-
jq --rawfile text text.txt \\\n --rawfile username username.txt \\\n --rawfile\
33+
run: "set -x\n\ncat - << EOF > emoji.txt\nbomb\ncat-on-keyboard\nfire\ngrim_reaper\n\
34+
grumpycat\nmushroomcloud\noops\npoop\nsad-mac\nsadpanda\nskull_and_crossbones\n\
35+
this_is_fine\ntombstone\nEOF\nEMOJI=\"$(shuf -n 1 emoji.txt)\"\n\necho 'Failed\
36+
\ a run of <${{ github.event.workflow_run.html_url }}|${{ github.event.workflow_run.name\
37+
\ }}> in ${{ github.event.repository.name }}.' > text.txt\necho -n \"GitHub\
38+
\ Workflow Bot\" > username.txt\necho -n \":${EMOJI}:\" > icon_emoji.txt\n\
39+
# echo -n \"https://i.chzbgr.com/full/8209966592/h2FE3826C/how-awesome-are-you\"\
40+
\ > icon_url.txt\necho -n \"#build-failures\" > channel.txt\necho '{}' | \\\
41+
\njq --rawfile text text.txt \\\n --rawfile username username.txt \\\n --rawfile\
4042
\ icon_emoji icon_emoji.txt \\\n --rawfile channel channel.txt \\\n '. +\
4143
\ {\"text\": $text, \"username\": $username, \"icon_emoji\": $icon_emoji,\
4244
\ \"channel\": $channel}' | \\\ncurl -Ssf -d @- -H \"Content-type: application/json\"\

0 commit comments

Comments
 (0)