Skip to content

Commit 3083bb7

Browse files
committed
chore(release): update release script
1 parent 5dc44f8 commit 3083bb7

File tree

3 files changed

+108
-89
lines changed

3 files changed

+108
-89
lines changed

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,11 @@ Pull requests are welcome. This project uses [conventional commits](https://www.
166166

167167
We rely on [standard-version](https://github.com/conventional-changelog/standard-version) which is part of the JavaScript ecosystem but works well with any project.
168168

169+
```sh
170+
./script/github-release
169171
```
170-
npx standard-version --sign
171-
git push --follow-tags
172-
# Do the release on Github with manual steps, then:
173-
./script/sign-post-release
174-
```
172+
173+
Make sure everything is valid in the Draft release, then publish the draft.
175174

176175
Release tarballs are signed with this PGP key: `F44D05A50F6C9EB5C81BCF966A6B35DBE9442683`
177176

script/github-release

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
declare -r git_root=$(git rev-parse --show-toplevel)
6+
declare -r app_name="swappy"
7+
declare -r release_folder="$git_root/release"
8+
9+
declare version=""
10+
11+
die() {
12+
echo "$*" 1>&2
13+
exit 1
14+
}
15+
16+
init() {
17+
command -v git >/dev/null 2>&1 || { echo >&2 "git required: pacman -S git"; exit 1; }
18+
command -v gh >/dev/null 2>&1 || { echo >&2 "github cli tool required to publish the release: pacman -S github-cli"; exit 1; }
19+
command -v npx >/dev/null 2>&1 || { echo >&2 "npx required for standard versionning the release: pacman -S npm"; exit 1; }
20+
command -v gpg >/dev/null 2>&1 || { echo >&2 "gpg required to sign the archive: pacman -S gnupg"; exit 1; }
21+
22+
mkdir -p $release_folder
23+
}
24+
25+
git_get_release_version() {
26+
version=$(git describe --tags --abbrev=0 | sed 's/^v//')
27+
28+
if [ -z "$version" ]
29+
then
30+
die "version not found, is the git tag valid?"
31+
fi
32+
33+
echo "found latest version: $version"
34+
}
35+
36+
npx_standard_version() {
37+
echo "setting up new standard version with npx..."
38+
npx standard-version --sign
39+
}
40+
41+
git_push_tags() {
42+
echo "pushing git tags..."
43+
git push --follow-tags
44+
}
45+
46+
47+
git_build_archive() {
48+
echo "building source archives..."
49+
cd $git_root
50+
git archive -o "$release_folder/$app_name-$version.tar.gz" --format tar.gz --prefix "$app_name-$version/" "v$version"
51+
}
52+
53+
download_source_for_release() {
54+
echo "downloading source assets..."
55+
cd $release_folder
56+
curl --location --output github-$app_name-$version.tar.gz https://github.com/jtheoof/$app_name/archive/v$version.tar.gz
57+
}
58+
59+
verify_sha256_checksums() {
60+
echo "verifying signatures..."
61+
cd $release_folder
62+
sha256sum $app_name-$version.tar.gz | awk '{ print $1 }' > $app_name-$version.tar.gz.sha256
63+
64+
# sha256sum --check will exit if the checksums do not match
65+
echo "$(cat $app_name-$version.tar.gz.sha256) github-$app_name-$version.tar.gz" | sha256sum --check
66+
}
67+
68+
gpg_sign_archive() {
69+
echo "signing source assets..."
70+
cd $release_folder
71+
gpg --output $app_name-$version.tar.gz.sig --detach-sign $app_name-$version.tar.gz
72+
}
73+
74+
git_generate_changelog() {
75+
echo "generating changelog..."
76+
git diff "v$version"^ -- CHANGELOG.md | tail -n +9 | head -n -4 | sed 's/^+//g' > $release_folder/CHANGELOG.md
77+
}
78+
79+
github_create_release() {
80+
echo "creating github release..."
81+
gh release create --draft "v$version" \
82+
-F "$release_folder/CHANGELOG.md" \
83+
"$release_folder/$app_name-$version.tar.gz" \
84+
"$release_folder/$app_name-$version.tar.gz.sig" \
85+
"$release_folder/CHANGELOG.md"
86+
}
87+
88+
main() {
89+
init
90+
91+
npx_standard_version
92+
git_push_tags
93+
git_get_release_version
94+
git_build_archive
95+
# Turning off manual downloading from github
96+
# doing all the steps, including archive, ourselves.
97+
#download_source_for_release
98+
#verify_sha256_checksums
99+
git_generate_changelog
100+
gpg_sign_archive
101+
github_create_release
102+
}
103+
104+
main "$@"

script/sign-post-release

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

0 commit comments

Comments
 (0)