Skip to content

Commit b3d7e9f

Browse files
committed
feat: Adding compatibility of release script for codeberg
Signed-off-by: Vincent Boutour <bob@vibioh.fr>
1 parent 72d2554 commit b3d7e9f

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

executables/release.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,21 @@ release_upload() {
139139
var_warning "Nothing to upload!"
140140
fi
141141

142-
http_init_client --header "Authorization: token ${GITHUB_TOKEN}"
142+
if [[ -n ${GITHUB_REPOSITORY:-} ]]; then
143+
RELEASE_API="${GITHUB_API_URL}"
144+
RELEASE_REPOSITORY="${GITHUB_REPOSITORY}"
145+
RELEASE_TOKEN="${GITHUB_TOKEN}"
146+
elif [[ -n ${FORGEJO_REPOSITORY:-} ]]; then
147+
RELEASE_API="${FORGEJO_SERVER_URL}"
148+
RELEASE_REPOSITORY="${FORGEJO_REPOSITORY}"
149+
RELEASE_TOKEN="${FORGEJO_TOKEN}"
150+
fi
151+
152+
http_init_client --header "Authorization: token ${RELEASE_TOKEN}"
143153
HTTP_CLIENT_ARGS+=("--max-time" "120")
144154

145155
var_read GIT_TAG
146-
http_request --header "Content-Type: application/json" "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${GIT_TAG}"
156+
http_request --header "Content-Type: application/json" "https://${RELEASE_API}/repos/${RELEASE_REPOSITORY}/releases/tags/${GIT_TAG}"
147157
if [[ ${HTTP_STATUS} != "200" ]]; then
148158
http_handle_error "Unable to get release"
149159
http_reset
@@ -166,14 +176,16 @@ release_upload() {
166176

167177
rm "${HTTP_OUTPUT}"
168178
done
179+
180+
http_reset
169181
}
170182

171183
release_usage() {
172184
printf -- "Usage of %s\n" "${0}"
173185
printf -- "clean\n\tClean output dir %s\n" "${OUTPUT_DIR}"
174186
printf -- "build\n\tBuild artifacts\n"
175187
printf -- "docker\n\tBuild docker images\n"
176-
printf -- "assets\n\tUpload output dir content to GitHub release\n"
188+
printf -- "assets\n\tUpload output dir content to repository release\n"
177189
printf -- "clean\n\tClean created output directory\n"
178190
}
179191

0 commit comments

Comments
 (0)