-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·67 lines (57 loc) · 2.39 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
set -e
# this script assumes
# * you have docker, curl & jq installed and available in path.
# * github api token is configured in environment variable GH_TOKEN.
# * internet access is available to access nushell cargo installation.
# * a new gitlab release is created with tag in the format "vx.y.z" where x.y.z is the nu shell version.
if [ -z "${GH_TOKEN}" ]; then
echo "GitHub authentication information is not set."
exit 1
fi
# delete any existing packages
echo "deleting existing packages if any..."
rm -f *.rpm *.deb
# Fedora
for release in {39..40}; do
docker run --rm -it -v $(pwd):/code fedora:${release} /code/create_nushell_package.sh
done
# RockyLinux
for release in {8..9}; do
docker run --rm -it -v $(pwd):/code rockylinux/rockylinux:${release} /code/create_nushell_package.sh
done
# Debian
for release in "bookworm" "trixie"; do
docker run --rm -it -v $(pwd):/code debian:${release} /code/create_nushell_package.sh
done
# NU_SHELL_VERSION=$(find . -maxdepth 1 -name "*fc*" | head -1 | cut -d '-' -f2)
NU_SHELL_VERSION=$(ls *fc* | head -1 | cut -d '-' -f2)
TAG="v${NU_SHELL_VERSION}"
# Create a github release to upload the packages to.
gh_release_id=$(curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GH_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-d "{\"tag_name\":\"${TAG}\",\"target_commitish\":\"main\",\"name\":\"Release ${NU_SHELL_VERSION}\",\"draft\":false,\"prerelease\":false}" \
https://api.github.com/repos/emailstorbala/nushell-packages/releases | jq '.id')
# # Search release by tag name
# gh_release_id=$(curl -L \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer ${GH_TOKEN}" \
# -H "X-GitHub-Api-Version: 2022-11-28" \
# https://api.github.com/repos/emailstorbala/nushell-packages/releases/tags/${TAG} | jq '.id')
# upload the generated packages
for package in $(ls *.rpm *.deb); do
echo "uploading ${package} to release ${gh_release_id} with tag ${TAG}"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GH_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"https://uploads.github.com/repos/emailstorbala/nushell-packages/releases/${gh_release_id}/assets?name=${package}" \
--data-binary "@${package}"
# print a new line to seperate the curl output and next line
echo ""
done