mirror of
https://code.forgejo.org/actions/forgejo-release.git
synced 2024-12-22 07:35:48 +02:00
wait for a release to no longer be draft before downloading
This commit is contained in:
parent
56c1c975a3
commit
358b55efd4
4 changed files with 44 additions and 0 deletions
|
@ -18,6 +18,9 @@ Upload or download the assets of a release to a Forgejo instance.
|
||||||
| release-dir | Directory in whichs release assets are uploaded or downloaded | `true` | |
|
| release-dir | Directory in whichs release assets are uploaded or downloaded | `true` | |
|
||||||
| release-notes | Release notes | `false` | |
|
| release-notes | Release notes | `false` | |
|
||||||
| direction | Can either be download or upload | `true` | |
|
| direction | Can either be download or upload | `true` | |
|
||||||
|
| gpg-private-key | GPG Private Key to sign the release artifacts | `false` | |
|
||||||
|
| gpg-passphrase | Passphrase of the GPG Private Key | `false` | |
|
||||||
|
| download-retry | Number of times to retry if the release is not ready (default 1) | `false` | |
|
||||||
| verbose | Increase the verbosity level | `false` | false |
|
| verbose | Increase the verbosity level | `false` | false |
|
||||||
<!-- action-docs-inputs -->
|
<!-- action-docs-inputs -->
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,8 @@ inputs:
|
||||||
description: 'GPG Private Key to sign the release artifacts'
|
description: 'GPG Private Key to sign the release artifacts'
|
||||||
gpg-passphrase:
|
gpg-passphrase:
|
||||||
description: 'Passphrase of the GPG Private Key'
|
description: 'Passphrase of the GPG Private Key'
|
||||||
|
download-retry:
|
||||||
|
description: 'Number of times to retry if the release is not ready (default 1)'
|
||||||
verbose:
|
verbose:
|
||||||
description: 'Increase the verbosity level'
|
description: 'Increase the verbosity level'
|
||||||
default: 'false'
|
default: 'false'
|
||||||
|
@ -71,5 +73,7 @@ runs:
|
||||||
|
|
||||||
export VERBOSE="${{ inputs.verbose }}"
|
export VERBOSE="${{ inputs.verbose }}"
|
||||||
|
|
||||||
|
export RETRY="${{ inputs.download-retry }}"
|
||||||
|
|
||||||
forgejo-release.sh ${{ inputs.direction }}
|
forgejo-release.sh ${{ inputs.direction }}
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
|
@ -10,6 +10,8 @@ if ${VERBOSE:-false}; then set -x; fi
|
||||||
: ${RELEASE_DIR:=dist/release}
|
: ${RELEASE_DIR:=dist/release}
|
||||||
: ${BIN_DIR:=$(mktemp -d)}
|
: ${BIN_DIR:=$(mktemp -d)}
|
||||||
: ${TEA_VERSION:=0.9.0}
|
: ${TEA_VERSION:=0.9.0}
|
||||||
|
: ${RETRY:=1}
|
||||||
|
: ${DELAY:=10}
|
||||||
|
|
||||||
setup_tea() {
|
setup_tea() {
|
||||||
if ! test -f $BIN_DIR/tea ; then
|
if ! test -f $BIN_DIR/tea ; then
|
||||||
|
@ -72,8 +74,30 @@ api() {
|
||||||
curl --fail -X $method -sS -H "Content-Type: application/json" -H "Authorization: token $TOKEN" "$@" $FORGEJO/api/v1/$path
|
curl --fail -X $method -sS -H "Content-Type: application/json" -H "Authorization: token $TOKEN" "$@" $FORGEJO/api/v1/$path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wait_release() {
|
||||||
|
local ready=false
|
||||||
|
for i in $(seq $RETRY); do
|
||||||
|
if api GET repos/$REPO/releases/tags/$TAG | jq --raw-output .draft > /tmp/draft; then
|
||||||
|
if test "$(cat /tmp/draft)" = "false"; then
|
||||||
|
ready=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo "release $TAG is still a draft"
|
||||||
|
else
|
||||||
|
echo "release $TAG does not exist yet"
|
||||||
|
fi
|
||||||
|
echo "waiting $DELAY seconds"
|
||||||
|
sleep $DELAY
|
||||||
|
done
|
||||||
|
if ! $ready ; then
|
||||||
|
echo "no release for $TAG"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
download() {
|
download() {
|
||||||
setup_api
|
setup_api
|
||||||
|
wait_release
|
||||||
(
|
(
|
||||||
mkdir -p $RELEASE_DIR
|
mkdir -p $RELEASE_DIR
|
||||||
cd $RELEASE_DIR
|
cd $RELEASE_DIR
|
||||||
|
|
13
testdata/forgejo-release-test.sh
vendored
13
testdata/forgejo-release-test.sh
vendored
|
@ -32,6 +32,16 @@ test_setup() {
|
||||||
touch $RELEASE_DIR/file-two.txt
|
touch $RELEASE_DIR/file-two.txt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_wait_release_fail() {
|
||||||
|
! wait_release
|
||||||
|
}
|
||||||
|
|
||||||
|
test_wait_release() {
|
||||||
|
wait_release
|
||||||
|
release_draft true
|
||||||
|
! wait_release
|
||||||
|
}
|
||||||
|
|
||||||
test_ensure_tag() {
|
test_ensure_tag() {
|
||||||
api DELETE repos/$REPO/tags/$TAG || true
|
api DELETE repos/$REPO/tags/$TAG || true
|
||||||
#
|
#
|
||||||
|
@ -62,12 +72,15 @@ test_run() {
|
||||||
REPO=$user/$project
|
REPO=$user/$project
|
||||||
test_setup $project
|
test_setup $project
|
||||||
test_ensure_tag
|
test_ensure_tag
|
||||||
|
DELAY=0
|
||||||
|
test_wait_release_fail
|
||||||
echo "================================ TEST BEGIN"
|
echo "================================ TEST BEGIN"
|
||||||
upload
|
upload
|
||||||
RELEASE_DIR=$pulled
|
RELEASE_DIR=$pulled
|
||||||
download
|
download
|
||||||
diff -r $to_push $pulled
|
diff -r $to_push $pulled
|
||||||
echo "================================ TEST END"
|
echo "================================ TEST END"
|
||||||
|
test_wait_release
|
||||||
}
|
}
|
||||||
|
|
||||||
: ${TAG:=v17.8.20-1}
|
: ${TAG:=v17.8.20-1}
|
||||||
|
|
Loading…
Reference in a new issue