Skip to content

Commit c6ba17a

Browse files
Merge pull request #7 from JarvusInnovations/develop
Release: v1.4.1
2 parents 29296a6 + 8f461b0 commit c6ba17a

File tree

4 files changed

+27
-162
lines changed

4 files changed

+27
-162
lines changed

.github/workflows/release-deploy.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/release-prepare.yml

Lines changed: 7 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -4,109 +4,17 @@ on:
44
push:
55
branches: [ develop ]
66

7-
env:
8-
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
9-
RELEASE_BRANCH: main
7+
permissions:
8+
contents: read
9+
pull-requests: write
1010

1111
jobs:
1212
release-prepare:
13+
1314
runs-on: ubuntu-latest
1415
steps:
1516

16-
- uses: actions/checkout@v2
17+
- uses: JarvusInnovations/infra-components@channels/github-actions/release-prepare/latest
1718
with:
18-
fetch-depth: 0
19-
20-
# - uses: mxschmitt/action-tmate@v3
21-
22-
- name: Create/update pull request
23-
run: |
24-
# get latest release tag
25-
latest_release=$(git describe --tags --abbrev=0 origin/${{ env.RELEASE_BRANCH }})
26-
latest_release_bumped=$(echo $latest_release | awk -F. -v OFS=. '{$NF++;print}')
27-
28-
29-
# create or update PR
30-
pr_body="$(cat <<EOF
31-
Release: ${latest_release_bumped}
32-
33-
## Improvements
34-
35-
## Technical
36-
37-
EOF
38-
)"
39-
40-
pr_number=$(hub pr list -h develop -f '%I')
41-
42-
if [ -n "${pr_number}" ]; then
43-
echo "Updating PR #${pr_number}"
44-
existing_comment_id=$(hub api "/repos/${GITHUB_REPOSITORY}/issues/${pr_number}/comments" | jq '.[] | select(.user.login=="jarvus-bot") | .id')
45-
else
46-
echo "Opening PR"
47-
hub pull-request -b "${RELEASE_BRANCH}" -h develop -F <(echo "${pr_body}") > /tmp/pr.json
48-
pr_number=$(hub pr list -h develop -f '%I')
49-
echo "Opened PR #${pr_number}"
50-
fi
51-
52-
53-
# build changelog
54-
commits=$(
55-
git log \
56-
--first-parent \
57-
--reverse \
58-
--format="%H" \
59-
"origin/${RELEASE_BRANCH}..develop"
60-
)
61-
62-
changelog=()
63-
64-
while read -r commit; do
65-
subject="$(git show -s --format=%s "${commit}")"
66-
line=""
67-
68-
if [[ "${subject}" =~ Merge\ pull\ request\ \#([0-9]+) ]]; then
69-
line="$(hub pr show -f '%t [%i] @%au' "${BASH_REMATCH[1]}" || true)"
70-
fi
71-
72-
if [ -z "${line}" ]; then
73-
author="$(hub api "/repos/${GITHUB_REPOSITORY}/commits/${commit}" -H Accept:application/vnd.github.v3+json | jq -r '.author.login')"
74-
if [ -n "${author}" ]; then
75-
author="@${author}"
76-
else
77-
author="$(git show -s --format=%ae "${commit}")"
78-
fi
79-
80-
line="${subject} ${author}"
81-
fi
82-
83-
# move ticket number prefix into to existing square brackets at end
84-
line="$(echo "${line}" | perl -pe 's/^([A-Z]+-[0-9]+):?\s*(.*?)\s*\[([^]]+)\]\s*(\S+)$/\2 [\3, \1] \4/')"
85-
86-
# move ticket number prefix into to new square brackets at end
87-
line="$(echo "${line}" | perl -pe 's/^([A-Z]+-[0-9]+):?\s*(.*?)\s*(\S+)$/\2 [\1] \3/')"
88-
89-
# combine doubled square brackets at the end
90-
line="$(echo "${line}" | perl -pe 's/^\s*(.*?)\s*\[([A-Z]+-[0-9]+)\]\s*\[([^]]+)\]\s*(\S+)$/\1 [\3, \2] \4/')"
91-
92-
changelog+=("- ${line}")
93-
done <<< "${commits}"
94-
95-
96-
# create or update comment
97-
comment_body="$(cat <<EOF
98-
## Changelog
99-
100-
\`\`\`markdown
101-
$(IFS=$'\n'; echo "${changelog[*]}")
102-
\`\`\`
103-
EOF
104-
)"
105-
106-
if [ -n "${existing_comment_id}" ]; then
107-
echo "Updating comment #${existing_comment_id}"
108-
hub api "/repos/${GITHUB_REPOSITORY}/issues/comments/${existing_comment_id}" -f body="${comment_body}"
109-
else
110-
echo "Creating comment"
111-
hub api "/repos/${GITHUB_REPOSITORY}/issues/${pr_number}/comments" -f body="${comment_body}"
112-
fi
19+
github-token: ${{ secrets.GITHUB_TOKEN }}
20+
release-branch: main
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: 'Release: Publish PR'
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
types: [ closed ]
7+
8+
jobs:
9+
release-publish:
10+
11+
runs-on: ubuntu-latest
12+
steps:
13+
14+
- uses: JarvusInnovations/infra-components@channels/github-actions/release-publish/latest
15+
with:
16+
github-token: ${{ secrets.BOT_GITHUB_TOKEN }}

.github/workflows/release-validate.yml

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,12 @@ on:
55
branches: [ main ]
66
types: [ opened, edited, reopened, synchronize ]
77

8-
env:
9-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10-
118
jobs:
129
release-validate:
10+
1311
runs-on: ubuntu-latest
1412
steps:
1513

16-
- name: Validate PR title
17-
run: |
18-
PR_TITLE=$(jq -r ".pull_request.title" $GITHUB_EVENT_PATH)
19-
20-
# check title format and extract tag
21-
if [[ "${PR_TITLE}" =~ ^Release:\ v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$ ]]; then
22-
RELEASE_TAG="${PR_TITLE:9}"
23-
echo "RELEASE_TAG=${RELEASE_TAG}" >> $GITHUB_ENV
24-
else
25-
echo 'PR title must match format "Release: vX.Y.Z(-rc.#)?"'
26-
exit 1
27-
fi
28-
29-
# check that tag doesn't exist
30-
if git ls-remote --exit-code "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}" "refs/tags/${RELEASE_TAG}"; then
31-
echo "The PR title's version exists already"
32-
exit 1
33-
fi
14+
- uses: JarvusInnovations/infra-components@channels/github-actions/release-validate/latest
15+
with:
16+
github-token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)