1
1
#! /bin/bash
2
- # to run use bash ipm_package.bash --version x.x.x --ip_name name
3
- # More safety, by turning some bugs into errors.
2
+ # To run use: bash ipm_package.bash --version x.x.x --ip_name name
3
+
4
+ # Enable safety options to turn some bugs into errors
4
5
set -o errexit -o pipefail -o nounset
5
6
6
- # now enjoy the options in order and nicely split until we see --
7
- # option --output/-o requires 1 argument
8
- LONGOPTS=version:ip_name:
7
+ # Define the options for getopt
8
+ LONGOPTS=version:,ip_name:
9
9
OPTIONS=
10
10
11
- # -temporarily store output to be able to check for errors
12
- # -activate quoting/enhanced mode (e.g. by writing out "--options")
13
- # -pass arguments only via -- "$@" to separate them correctly
14
- # -if getopt fails, it complains itself to stdout
11
+ # Parse the options using getopt
15
12
PARSED=$( getopt --options=$OPTIONS --longoptions=$LONGOPTS --name " $0 " -- " $@ " ) || exit 2
16
- # read getopt's output this way to handle the quoting right:
13
+
14
+ # Read getopt's output to handle quoting correctly
17
15
eval set -- " $PARSED "
18
- unset PARSED
19
16
17
+ # Initialize variables
18
+ version=" "
19
+ ip_name=" "
20
20
21
+ # Process the options
21
22
while true ; do
22
23
case " $1 " in
23
24
--version)
24
25
version=" $2 "
25
26
shift 2
26
27
;;
27
- --)
28
28
--ip_name)
29
29
ip_name=" $2 "
30
30
shift 2
@@ -34,33 +34,97 @@ while true; do
34
34
break
35
35
;;
36
36
* )
37
- echo " Programming error"
37
+ echo " Programming error: unknown option $1 "
38
38
exit 3
39
39
;;
40
40
esac
41
41
done
42
42
43
+ # Ensure required arguments are set
44
+ if [[ -z " $version " || -z " $ip_name " ]]; then
45
+ echo " Error: Both --version and --ip_name options are required."
46
+ exit 1
47
+ fi
48
+
49
+ # Output the parsed arguments
43
50
echo " + version=$version "
51
+ echo " + ip_name=$ip_name "
52
+
53
+
54
+ set -x
55
+
56
+ # Generate the list of files to include in the tarball
57
+ files_to_compress=$( find . \
58
+ ! -path " ./hdl" \
59
+ ! -path " ./hdl/rtl" \
60
+ ! -path " ./hdl/rtl/bus_wrappers" \
61
+ ! -path " ./hdl/rtl/bus_wrappers/dft" \
62
+ | grep -v " \./verify" \
63
+ | grep -v " \./ipm_package.bash" \
64
+ | grep -v " .*\.dev\.v" \
65
+ | grep -v " \.git" \
66
+ | grep -v " \.tar\.gz" \
67
+ | grep -v " \./ip" \
68
+ | grep -v " \./docs" \
69
+ | grep -v " \./README.md" \
70
+ | grep -v " \.\$ " )
71
+
72
+ # Print the files that will be compressed
73
+ echo " Files to be compressed:"
74
+ echo " $files_to_compress "
75
+
76
+ # Write the list of files to a temporary file
77
+ temp_file=$( mktemp)
78
+ echo " $files_to_compress " > " $temp_file "
44
79
45
- # zip needed files
80
+ # Create the tarball using the temporary file
81
+ tar czf v$version .tar.gz --files-from=" $temp_file "
46
82
83
+ # Clean up the temporary file
84
+ rm -f " $temp_file "
47
85
48
- tar czf v$version .tar.gz --files-from <( find . | grep -v " \./verify" | grep -v " \./fw/Doxyfile" | grep -v " \./ipm_package.bash" | grep -v " .*\.dev\.v" | grep -v " \./hdl/rtl/bus_wrappers/dft" | grep -v " \.git" | grep -v " \.tar\.gz" | grep -v " \./ip" | grep -v " \./docs" | grep -v " \.\$ " ; ls " ./ip/dependencies.json" )
49
- # tar czf v$version.tar.gz \
50
- # --exclude='verify' \
51
- # --exclude='hdl/rtl/bus_wrappers/dft' \
52
- # --exclude='hdl/rtl/bus_wrappers/*.dev.v' \
53
- # --exclude='ipm_package.bash' \
54
- # --exclude='fw/Doxyfile' \
55
- # --include='*.c' \
56
- # *
57
86
# get checksum
58
87
shasum -a 256 v$version .tar.gz > v$version .tar.gz.sha256
59
88
60
89
# update yaml
61
90
sed -i " s/version.*/version: v$version /" * .yaml
62
91
sed -i " s/date.*/date: $( date +" %Y-%m-%d" ) /" * .yaml
63
92
93
+ # Extract information from YAML using sed
94
+ date=$( sed -n ' s/^[[:space:]]*date:[[:space:]]*//p' $ip_name .yaml)
95
+ maturity=$( sed -n ' s/^[[:space:]]*status:[[:space:]]*//p' $ip_name .yaml)
96
+ bus=$( sed -n ' /^[[:space:]]*bus:/,/^[[:space:]]*type:/p' $ip_name .yaml | sed -n ' s/^[[:space:]]*-[[:space:]]*//p' | paste -sd " ," -)
97
+ type=$( sed -n ' s/^[[:space:]]*type:[[:space:]]*//p' $ip_name .yaml)
98
+ width=$( sed -n ' s/^[[:space:]]*width":[[:space:]]*//p' $ip_name .yaml)
99
+ height=$( sed -n ' s/^[[:space:]]*height":[[:space:]]*//p' $ip_name .yaml)
100
+ cell_count=$( sed -n ' /^[[:space:]]*cell_count:/,/^[[:space:]]*width:/p' $ip_name .yaml | sed -n ' s/^[[:space:]]*-[[:space:]]*//p' | paste -sd " ," -)
101
+ clock_freq_mhz=$( sed -n ' /^[[:space:]]*clock_freq_mhz:/,/^[[:space:]]*digital_supply_voltage:/p' $ip_name .yaml | sed -n ' s/^[[:space:]]*-[[:space:]]*//p' | paste -sd " ," -)
102
+ supply_voltage=$( sed -n ' s/^[[:space:]]*digital_supply_voltage:[[:space:]]*//p' $ip_name .yaml)
103
+ sha256=$( cat v$version .tar.gz.sha256 | awk ' {print $1}' )
104
+
105
+ # Format JSON section
106
+ json_section=$( cat << EOF
107
+ ,"release": {
108
+ "v$version ": {
109
+ "date": "$date ",
110
+ "maturity": "$maturity ",
111
+ "bus": [
112
+ "$bus "
113
+ ],
114
+ "type": "$type ",
115
+ "width": "$width ",
116
+ "height": "$height ",
117
+ "cell_count": "$cell_count ",
118
+ "clock_freq_mhz": "$clock_freq_mhz ",
119
+ "supply_voltage": [
120
+ "$supply_voltage "
121
+ ],
122
+ "sha256": "$sha256 "
123
+ }
124
+ EOF
125
+ )
126
+
127
+
64
128
# create tag
65
129
git tag -a $ip_name -v$version -m " Release version $version "
66
130
git push origin $ip_name -v$version
@@ -71,5 +135,5 @@ if gh release view $ip_name-v$version > /dev/null 2>&1; then
71
135
echo " Release $ip_name -v$version already exists. Skipping..."
72
136
else
73
137
echo " Creating release $ip_name -v$version ..."
74
- gh release create $ip_name -v$version v$version .tar.gz -t " $ip_name -v$version " --notes " sha256: $( cat v $version .tar.gz.sha256 ) "
138
+ gh release create $ip_name -v$version v$version .tar.gz -t " $ip_name -v$version " --notes " $json_section "
75
139
fi
0 commit comments