Skip to content

Commit 4686f94

Browse files
committed
Add basic release workflow
Signed-off-by: Evan Lezar <[email protected]>
1 parent 3f481cd commit 4686f94

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed

.github/workflows/release.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright 2024 NVIDIA CORPORATION
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Run this workflow on new tags
16+
name: Release
17+
18+
on:
19+
push:
20+
tags:
21+
- v*
22+
23+
jobs:
24+
release:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
name: Check out code
29+
- name: Create Draft Release
30+
env:
31+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
OWNER: ${{ github.repository_owner }}
33+
REPO: ${{ github.event.repository.name }}
34+
run: |
35+
GH_EXTRA_ARGS=""
36+
if [[ ${{ github.ref }} == *-rc.* ]]; then
37+
GH_EXTRA_ARGS="--prerelease"
38+
fi
39+
gh release create ${{ github.ref }} \
40+
--draft \
41+
-t "${{ github.ref }}" \
42+
-R $OWNER/$REPO \
43+
--verify-tag \
44+
$GH_EXTRA_ARGS
45+
46+
- name: Upload Release Artifacts
47+
env:
48+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
OWNER: ${{ github.repository_owner }}
50+
REPO: ${{ github.event.repository.name }}
51+
run: |
52+
gh release upload ${{ github.ref }} CHANGELOG.md -R $OWNER/$REPO

hack/generate-changelog.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o pipefail
18+
this=`basename $0`
19+
20+
usage () {
21+
cat << EOF
22+
Generate a changelog for the specified tag
23+
Usage: $this --reference <tag> [--remote <remote_name>]
24+
25+
Options:
26+
--since specify the tag to start the changelog from (default: latest tag)
27+
--remote specify the remote to fetch tags from (default: upstream)
28+
--version specify the version to be released
29+
--help/-h show this help and exit
30+
31+
EOF
32+
}
33+
34+
REMOTE="upstream"
35+
VERSION=""
36+
REFERENCE=
37+
38+
# Parse command line options
39+
while [[ $# -gt 0 ]]; do
40+
key="$1"
41+
case $key in
42+
--since)
43+
REFERENCE="$2"
44+
shift # past argument
45+
shift # past value
46+
;;
47+
--remote)
48+
REMOTE="$2"
49+
shift # past argument
50+
shift # past value
51+
;;
52+
--version)
53+
VERSION="$2"
54+
shift # past argument
55+
shift # past value
56+
;;
57+
--help/-h) usage
58+
exit 0
59+
;;
60+
*) usage
61+
exit 1
62+
;;
63+
esac
64+
done
65+
66+
# Fetch the latest tags from the remote
67+
git fetch $REMOTE --tags
68+
69+
# if REFERENCE is not set, get the latest tag
70+
if [ -z "$REFERENCE" ]; then
71+
REFERENCE=$(git describe --tags $(git rev-list --tags --max-count=1))
72+
fi
73+
74+
# Print the changelog
75+
echo "## Changelog"
76+
echo ""
77+
echo "### Version $VERSION"
78+
79+
# Iterate over the commit messages and ignore the ones that start with "Merge" or "Bump"
80+
git log --pretty=format:"%s" $REFERENCE..@ | grep -Ev "(^Merge )|(^Bump)" | sed 's/^\(.*\)/- \1/g'

0 commit comments

Comments
 (0)