2023-04-01 09:12:56 +00:00
|
|
|
# SPDX-License-Identifier: MIT
|
2023-03-29 15:16:26 +00:00
|
|
|
name: 'Forgejo release download and upload'
|
2023-03-26 15:41:37 +00:00
|
|
|
author: 'Forgejo authors'
|
|
|
|
description: |
|
2023-03-29 15:16:26 +00:00
|
|
|
Upload or download the assets of a release to a Forgejo instance.
|
|
|
|
inputs:
|
|
|
|
url:
|
|
|
|
description: 'URL of the Forgejo instance'
|
|
|
|
repo:
|
|
|
|
description: 'owner/project relative to the URL'
|
|
|
|
tag:
|
|
|
|
description: 'Tag of the release'
|
2024-07-27 12:06:55 +00:00
|
|
|
title:
|
|
|
|
description: 'Title of the release (defaults to tag)'
|
2023-03-29 17:29:24 +00:00
|
|
|
sha:
|
|
|
|
description: 'SHA of the release'
|
2023-03-29 15:16:26 +00:00
|
|
|
token:
|
|
|
|
description: 'Forgejo application token'
|
|
|
|
required: true
|
|
|
|
release-dir:
|
|
|
|
description: 'Directory in whichs release assets are uploaded or downloaded'
|
|
|
|
required: true
|
2023-03-29 21:59:02 +00:00
|
|
|
release-notes:
|
|
|
|
description: 'Release notes'
|
2023-03-29 15:16:26 +00:00
|
|
|
direction:
|
2024-10-29 10:59:58 +00:00
|
|
|
description: 'Can either be `download` or `upload`'
|
2023-03-29 15:16:26 +00:00
|
|
|
required: true
|
2023-05-23 11:04:53 +00:00
|
|
|
gpg-private-key:
|
|
|
|
description: 'GPG Private Key to sign the release artifacts'
|
|
|
|
gpg-passphrase:
|
|
|
|
description: 'Passphrase of the GPG Private Key'
|
2023-05-23 23:01:51 +00:00
|
|
|
download-retry:
|
|
|
|
description: 'Number of times to retry if the release is not ready (default 1)'
|
2024-07-08 18:49:13 +00:00
|
|
|
download-latest:
|
|
|
|
description: 'Download the latest release'
|
2024-11-19 15:38:34 +00:00
|
|
|
default: false
|
2023-03-29 15:16:26 +00:00
|
|
|
verbose:
|
|
|
|
description: 'Increase the verbosity level'
|
2024-11-19 15:38:34 +00:00
|
|
|
default: false
|
2024-02-11 22:40:17 +00:00
|
|
|
override:
|
2024-10-29 10:59:58 +00:00
|
|
|
description: 'Override an existing release by the same `{tag}`'
|
2024-11-19 15:38:34 +00:00
|
|
|
default: false
|
2024-01-03 18:23:39 +00:00
|
|
|
prerelease:
|
|
|
|
description: 'Mark Release as Pre-Release'
|
2024-11-19 15:38:34 +00:00
|
|
|
default: false
|
2024-10-29 15:08:41 +00:00
|
|
|
release-notes-assistant:
|
|
|
|
description: 'Generate release notes with Release Notes Assistant'
|
2024-11-19 15:38:34 +00:00
|
|
|
default: false
|
|
|
|
hide-archive-link:
|
|
|
|
description: 'Hide the archive links'
|
|
|
|
default: false
|
2024-01-03 18:23:39 +00:00
|
|
|
|
2023-03-26 15:41:37 +00:00
|
|
|
runs:
|
|
|
|
using: "composite"
|
|
|
|
steps:
|
|
|
|
- run: echo "${{ github.action_path }}" >> $GITHUB_PATH
|
|
|
|
shell: bash
|
2023-03-29 15:16:26 +00:00
|
|
|
- run: |
|
|
|
|
export FORGEJO="${{ inputs.url }}"
|
2023-03-30 06:52:59 +00:00
|
|
|
if test -z "$FORGEJO"; then
|
2023-03-30 13:37:51 +00:00
|
|
|
export FORGEJO="${{ env.GITHUB_SERVER_URL }}"
|
2023-03-30 06:52:59 +00:00
|
|
|
fi
|
2023-03-30 13:37:51 +00:00
|
|
|
# A trailing / will mean http://forgejo//api/v1 is used
|
|
|
|
# and it always 401 as of v1.19, because of the double slash
|
|
|
|
FORGEJO=${FORGEJO%%/}
|
2024-10-29 15:08:41 +00:00
|
|
|
export SCHEME=${FORGEJO%://*}
|
|
|
|
export HOST=${FORGEJO#*://}
|
2023-05-23 11:04:39 +00:00
|
|
|
|
2023-03-29 15:16:26 +00:00
|
|
|
export REPO="${{ inputs.repo }}"
|
2023-03-30 06:52:59 +00:00
|
|
|
if test -z "$REPO"; then
|
|
|
|
export REPO="${{ github.repository }}"
|
|
|
|
fi
|
2023-05-23 11:04:39 +00:00
|
|
|
|
2023-03-29 15:16:26 +00:00
|
|
|
export TAG="${{ inputs.tag }}"
|
2023-03-30 12:18:23 +00:00
|
|
|
if test -z "$TAG"; then
|
|
|
|
export TAG="${{ github.ref_name }}"
|
2023-03-30 22:36:06 +00:00
|
|
|
# until https://code.forgejo.org/forgejo/runner/issues/9 is fixed
|
|
|
|
# trim refs/tags/
|
|
|
|
TAG=${TAG##refs/tags/}
|
2023-03-30 12:18:23 +00:00
|
|
|
fi
|
2023-05-23 11:04:39 +00:00
|
|
|
|
2024-07-27 12:06:55 +00:00
|
|
|
export TITLE="${{ inputs.title }}"
|
|
|
|
|
2024-07-08 18:49:13 +00:00
|
|
|
export DOWNLOAD_LATEST="${{ inputs.download-latest }}"
|
|
|
|
|
2024-01-03 18:23:39 +00:00
|
|
|
export PRERELEASE="${{ inputs.prerelease }}"
|
|
|
|
|
2024-10-29 15:08:41 +00:00
|
|
|
export RELEASE_NOTES_ASSISTANT="${{ inputs.release-notes-assistant }}"
|
|
|
|
|
2024-11-19 15:38:34 +00:00
|
|
|
export HIDE_ARCHIVE_LINK="${{ inputs.hide-archive-link }}"
|
|
|
|
|
2023-03-29 15:16:26 +00:00
|
|
|
export TOKEN="${{ inputs.token }}"
|
2023-05-23 11:04:39 +00:00
|
|
|
|
2023-03-29 15:16:26 +00:00
|
|
|
export RELEASE_DIR="${{ inputs.release-dir }}"
|
2023-05-23 11:04:39 +00:00
|
|
|
|
2024-07-27 12:07:22 +00:00
|
|
|
export RELEASENOTES=$(cat << 'EOF'
|
|
|
|
${{ inputs.release-notes }}
|
|
|
|
EOF
|
|
|
|
)
|
2023-03-30 06:52:59 +00:00
|
|
|
|
2023-03-29 17:29:24 +00:00
|
|
|
export SHA="${{ inputs.sha }}"
|
|
|
|
if test -z "$SHA"; then
|
|
|
|
export SHA="${{ github.sha }}"
|
|
|
|
fi
|
2023-05-23 11:04:39 +00:00
|
|
|
|
2024-02-11 22:40:17 +00:00
|
|
|
export OVERRIDE="${{ inputs.override }}"
|
|
|
|
|
2023-05-23 11:04:39 +00:00
|
|
|
export VERBOSE="${{ inputs.verbose }}"
|
|
|
|
|
2023-05-23 23:01:51 +00:00
|
|
|
export RETRY="${{ inputs.download-retry }}"
|
|
|
|
|
2023-05-26 12:48:58 +00:00
|
|
|
export TMP_DIR=$(mktemp -d)
|
|
|
|
trap "rm -fr $TMP_DIR" EXIT
|
|
|
|
|
|
|
|
echo -n "${{ inputs.gpg-private-key }}" > $TMP_DIR/gpg-private-key
|
|
|
|
export GPG_PRIVATE_KEY=$TMP_DIR/gpg-private-key
|
|
|
|
echo -n "${{ inputs.gpg-passphrase }}" > $TMP_DIR/gpg-passphrase
|
|
|
|
export GPG_PASSPHRASE="$TMP_DIR/gpg-passphrase"
|
|
|
|
|
2023-03-29 15:16:26 +00:00
|
|
|
forgejo-release.sh ${{ inputs.direction }}
|
|
|
|
shell: bash
|