blob: fb79412bb13b65955565e4d690c346f71aec722e [file] [log] [blame]
Joey Armstrong4d612a92024-04-24 15:30:49 -04001#!/usr/bin/env bash
2# -----------------------------------------------------------------------
3# Copyright 2018-2024 Open Networking Foundation Contributors
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# SPDX-FileCopyrightText: 2018-2024 Open Networking Foundation Contributors
18# SPDX-License-Identifier: Apache-2.0
19# -----------------------------------------------------------------------
20# Intent:
21# builds (with make) and uploads release artifacts (binaries, etc.) to github
22# given a tag also create checksums files and release notes from the commit
23# message
24# -----------------------------------------------------------------------
25
26## ---------------------------------------------------------------------------
27## Intent: Parse script command line arguments
28## ---------------------------------------------------------------------------
29function parse_args()
30{
31 while [ $# -gt 0 ]; do
32 local arg="$1"; shift
33 func_echo "ARGV: $arg"
34
35 # shellcheck disable=SC2034
36 case "$arg" in
37
38 -*debug) declare -i -g debug=1 ;;
39 --draft) declare -i -g draft_release=1 ;;
40 --dry-run) declare -i -g dry_run=1 ;;
41
42 --version-file)
43 # [TODO] pass arg and infer path from that
44 declare -i -g argv_version_file=1
45
46 if [[ $# -gt 0 ]] && [[ "$1" == *"/VERSION" ]]; then
47 arg="$1"; shift
48 [[ ! -e "$arg" ]] && { error "--version-file $arg does not exist"; }
49 local path="${arg%/*}"
50 cd "$path" || { error "cd $path: directory does not exist"; }
51 fi
52 ;;
53
54 -*gen-version)
55 declare -g -i argv_gen_version=1
56 ;;
57
58 -*git-hostname)
59 __githost="$1"; shift
60 ;;
61
62 -*release-notes)
63 [[ ! -f "$1" ]] && error "--release-notes: file path required (arg=\"$arg\")"
64 declare -g release_notes="$1"; shift
65 ;;
66
67 -*repo-name)
68 __repo_name="$1"; shift
69 ;;
70
71 -*repo-org)
72 __repo_org="$1"; shift
73 ;;
74
75 -*pac)
76 declare -g pac="$1"; shift
77 readonly pac
78 [[ ! -f "$pac" ]] && error "--token= does not exist ($pac)"
79 : # nop/true
80 ;;
81
82 -*todo) todo ;;
83
84 --self-check) declare -g -i argv_self_check=1 ;;
85
86 -*help) usage; exit 0 ;;
87
88 *) error "Detected unknown argument $arg" ;;
89 esac
90 done
91
92 return
93}
94
95: # assign $?=0 for source $script
96
97# [EOF]