Skip to content

Commit 8ccfec6

Browse files
authored
Merge pull request #424 from igaw/add-release-script
Add release script
2 parents 0108463 + bf3bde3 commit 8ccfec6

2 files changed

Lines changed: 103 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Releases
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
tags:
7+
- '**'
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
if: startsWith(github.ref, 'refs/tags/v')
13+
permissions:
14+
contents: write
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: ncipollo/release-action@v1
18+
with:
19+
token: ${{ secrets.GITHUB_TOKEN }}

release.sh

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
3+
usage() {
4+
echo "release.sh: VERSION"
5+
echo ""
6+
echo "The script does all necessary steps to create a new release."
7+
echo ""
8+
echo "Note: The version number needs to be exactly"
9+
echo " '^v[\d]+.[\d]+(-rc[0-9]+)?$'"
10+
echo ""
11+
echo "example:"
12+
echo " release.sh v2.1-rc0 # v2.1 release candidate 0 -> sets the project "
13+
echo " # version to '1.1' and sets the tag"
14+
echo " release.sh v2.1-rc1 # v2.1 release canditate 1 -> only sets the tag"
15+
echo " release.sh v2.1 # v2.1 release -> sets the final tag"
16+
}
17+
18+
VERSION=$1
19+
20+
if [ -z "$VERSION" ] ; then
21+
usage
22+
exit 1
23+
fi
24+
25+
new_ver=""
26+
rc=""
27+
28+
re='^v([0-9]+\.[0-9]+)(-rc[0-9]+)?$'
29+
if [[ "$VERSION" =~ $re ]]; then
30+
echo "Valid version $VERSION string"
31+
new_ver=${BASH_REMATCH[1]}
32+
rc=${BASH_REMATCH[2]}
33+
else
34+
echo "Invalid version string $VERSION"
35+
echo ""
36+
usage
37+
exit 1
38+
fi
39+
40+
if [[ -n $(git status -s) ]]; then
41+
echo "tree is dirty. abort."
42+
exit 1
43+
fi
44+
45+
if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ] ; then
46+
echo "currently not on master branch. abort."
47+
exit 1
48+
fi
49+
50+
# update all docs
51+
doc_dir=""
52+
if [ -d "Documentation" ]; then
53+
doc_dir="Documentation"
54+
elif [ -d "doc" ]; then
55+
doc_dir="doc"
56+
else
57+
echo "documenation directory not found"
58+
exit 1
59+
fi
60+
61+
./$doc_dir/update-docs.sh
62+
git add $doc_dir
63+
git commit -s -m "Regenerate all documentation" \
64+
-m "Regenerate documentation for $VERSION release"
65+
66+
# update meson.build
67+
old_ver=$(sed -n "0,/[ \t]\+version: /s/[ \t]\+version: '\([0-9]\+.[0-9]\+\)',$/\1/p" meson.build)
68+
if [ "$old_ver" != "$new_ver" ]; then
69+
# Only update project version once, that is either
70+
# - for the first RC phase or
71+
# - for the release when there was no RC
72+
sed -i -e "0,/[ \t]version: /s/\([ \t]version: \).*/\1\'$new_ver\',/" meson.build
73+
git add meson.build
74+
fi
75+
76+
git commit -s -m "Release $VERSION"
77+
git tag -s -m "Release $VERSION" "$VERSION"
78+
git push --dry-run origin "$VERSION"^{}:master tag "$VERSION"
79+
80+
read -p "All good? Ready to push changes to remote? [Yy]" -n 1 -r
81+
echo
82+
if [[ $REPLY =~ ^[Yy]$ ]]; then
83+
git push origin "$VERSION"^{}:master tag "$VERSION"
84+
fi

0 commit comments

Comments
 (0)