mirror of
https://code.forgejo.org/actions/forgejo-release.git
synced 2025-07-26 07:08:21 +02:00
fix: support slashes in tags (#62)
Some checks are pending
/ integration (push) Waiting to run
Some checks are pending
/ integration (push) Waiting to run
Resolves actions/forgejo-release#22 Co-authored-by: Felix Kröner <felix.kroener@bruker.com> Reviewed-on: https://code.forgejo.org/actions/forgejo-release/pulls/62 Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org> Co-authored-by: Crown0815 <crown0815@noreply.code.forgejo.org> Co-committed-by: Crown0815 <crown0815@noreply.code.forgejo.org>
This commit is contained in:
parent
a5a957d2ff
commit
47387821e5
3 changed files with 46 additions and 6 deletions
|
@ -8,3 +8,6 @@ end_of_line = lf
|
|||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.yml]
|
||||
indent_size = 2
|
||||
|
|
|
@ -20,6 +20,7 @@ if ${VERBOSE:-false}; then set -x; fi
|
|||
: ${DELAY:=10}
|
||||
|
||||
TAG_FILE="$TMP_DIR/tag$$.json"
|
||||
TAG_URL=$(echo "$TAG" | sed 's/\//%2F/g')
|
||||
|
||||
export GNUPGHOME
|
||||
|
||||
|
@ -35,7 +36,7 @@ setup_tea() {
|
|||
|
||||
get_tag() {
|
||||
if ! test -f "$TAG_FILE"; then
|
||||
if api GET repos/$REPO/tags/"$TAG" >"$TAG_FILE"; then
|
||||
if api GET repos/$REPO/tags/"$TAG_URL" >"$TAG_FILE"; then
|
||||
echo "tag $TAG exists"
|
||||
else
|
||||
echo "tag $TAG does not exists"
|
||||
|
@ -71,7 +72,7 @@ create_tag() {
|
|||
|
||||
delete_tag() {
|
||||
if get_tag; then
|
||||
api DELETE repos/$REPO/tags/$TAG
|
||||
api DELETE repos/$REPO/tags/"$TAG_URL"
|
||||
rm -f "$TAG_FILE"
|
||||
fi
|
||||
}
|
||||
|
@ -108,7 +109,7 @@ upload_release() {
|
|||
release_draft() {
|
||||
local state="$1"
|
||||
|
||||
local id=$(api GET repos/$REPO/releases/tags/"$TAG" | jq --raw-output .id)
|
||||
local id=$(api GET repos/$REPO/releases/tags/"$TAG_URL" | jq --raw-output .id)
|
||||
|
||||
api PATCH repos/$REPO/releases/"$id" --data-raw '{"draft": '"$state"', "hide_archive_links": '$HIDE_ARCHIVE_LINK'}'
|
||||
}
|
||||
|
@ -145,7 +146,7 @@ maybe_override() {
|
|||
if test "$OVERRIDE" = "false"; then
|
||||
return
|
||||
fi
|
||||
api DELETE repos/$REPO/releases/tags/"$TAG" >&/dev/null || true
|
||||
api DELETE repos/$REPO/releases/tags/"$TAG_URL" >&/dev/null || true
|
||||
if get_tag && ! matched_tag; then
|
||||
delete_tag
|
||||
fi
|
||||
|
@ -180,7 +181,7 @@ api() {
|
|||
wait_release() {
|
||||
local ready=false
|
||||
for i in $(seq $RETRY); do
|
||||
if api GET repos/$REPO/releases/tags/"$TAG" | jq --raw-output .draft >"$TMP_DIR"/draft; then
|
||||
if api GET repos/$REPO/releases/tags/"$TAG_URL" | jq --raw-output .draft >"$TMP_DIR"/draft; then
|
||||
if test "$(cat "$TMP_DIR"/draft)" = "false"; then
|
||||
ready=true
|
||||
break
|
||||
|
@ -209,9 +210,10 @@ download() {
|
|||
elif [[ ${DOWNLOAD_LATEST} == "false" ]]; then
|
||||
wait_release
|
||||
echo "Downloading tagged release ${TAG}"
|
||||
api GET repos/$REPO/releases/tags/"$TAG" >"$TMP_DIR"/assets.json
|
||||
api GET repos/$REPO/releases/tags/"$TAG_URL" >"$TMP_DIR"/assets.json
|
||||
fi
|
||||
jq --raw-output '.assets[] | "\(.browser_download_url) \(.name)"' <"$TMP_DIR"/assets.json | while read url name; do # `name` may contain whitespace, therefore, it must be last
|
||||
url=$(echo "$url" | sed "s#/download/${TAG}/#/download/${TAG_URL}/#")
|
||||
curl --fail -H "Authorization: token $TOKEN" -o "$name" -L "$url"
|
||||
done
|
||||
)
|
||||
|
|
|
@ -45,6 +45,28 @@ jobs:
|
|||
- \backslash escape
|
||||
- !exclamation_mark
|
||||
verbose: true
|
||||
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
|
||||
id: release-upload-slash-in-tag
|
||||
uses: SELF@vTest
|
||||
with:
|
||||
direction: upload
|
||||
tag: a/v3.0
|
||||
token: FORGEJO_TOKEN
|
||||
release-dir: upload-dir
|
||||
release-notes: "RELEASE NOTES"
|
||||
verbose: true
|
||||
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
|
||||
id: release-upload-override-slash-in-tag
|
||||
uses: SELF@vTest
|
||||
with:
|
||||
direction: upload
|
||||
tag: a/v3.0
|
||||
token: FORGEJO_TOKEN
|
||||
release-dir: upload-dir
|
||||
release-notes-assistant: true
|
||||
hide-archive-link: true
|
||||
override: true
|
||||
verbose: true
|
||||
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
|
||||
id: release-download
|
||||
uses: SELF@vTest
|
||||
|
@ -69,5 +91,18 @@ jobs:
|
|||
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
|
||||
run: |
|
||||
diff -u upload-dir-v2 download-dir-v2
|
||||
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
|
||||
id: release-download-with-slash-in-tag
|
||||
uses: SELF@vTest
|
||||
with:
|
||||
direction: download
|
||||
tag: a/v3.0
|
||||
token: FORGEJO_TEST_TOKEN
|
||||
release-dir: download-dir-v3a
|
||||
download-latest: true
|
||||
verbose: true
|
||||
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
|
||||
run: |
|
||||
diff -u upload-dir download-dir-v3a
|
||||
- if: failure()
|
||||
run: docker logs forgejo
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue