Compare commits

..

No commits in common. "main" and "v2" have entirely different histories.
main ... v2

10 changed files with 34 additions and 127 deletions

View file

@ -21,12 +21,6 @@ jobs:
export FORGEJO_RUNNER_LOGS="${{ steps.forgejo.outputs.runner-logs }}"
forgejo-test-helper.sh run_workflow testdata/upload-download http://testuser:admin1234@${{ steps.forgejo.outputs.host-port }} testuser upload-download forgejo-release "${{ steps.forgejo.outputs.token }}"
- name: testdata/upload-download-private
run: |
export FORGEJO_RUNNER_LOGS="${{ steps.forgejo.outputs.runner-logs }}"
curl -X 'POST' 'http://testuser:admin1234@${{ steps.forgejo.outputs.host-port }}/api/v1/user/repos' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{"name": "upload-download-private","private": true}'
forgejo-test-helper.sh run_workflow testdata/upload-download http://testuser:admin1234@${{ steps.forgejo.outputs.host-port }} testuser upload-download-private forgejo-release "${{ steps.forgejo.outputs.token }}"
- name: testdata/nested-upload-download
run: |
export FORGEJO_RUNNER_LOGS="${{ steps.forgejo.outputs.runner-logs }}"

View file

@ -1,32 +1,30 @@
# forgejo-release
<!-- action-docs-description source="action.yml" -->
<!-- action-docs-description -->
## Description
Upload or download the assets of a release to a Forgejo instance.
<!-- action-docs-description source="action.yml" -->
<!-- action-docs-inputs source="action.yml" -->
<!-- action-docs-description -->
<!-- action-docs-inputs -->
## Inputs
| name | description | required | default |
| parameter | description | required | default |
| --- | --- | --- | --- |
| `url` | <p>URL of the Forgejo instance</p> | `false` | `""` |
| `repo` | <p>owner/project relative to the URL</p> | `false` | `""` |
| `tag` | <p>Tag of the release</p> | `false` | `""` |
| `title` | <p>Title of the release</p> | `false` | `""` |
| `sha` | <p>SHA of the release</p> | `false` | `""` |
| `token` | <p>Forgejo application token</p> | `true` | `""` |
| `release-dir` | <p>Directory in whichs release assets are uploaded or downloaded</p> | `true` | `""` |
| `release-notes` | <p>Release notes</p> | `false` | `""` |
| `direction` | <p>Can either be download or upload</p> | `true` | `""` |
| `gpg-private-key` | <p>GPG Private Key to sign the release artifacts</p> | `false` | `""` |
| `gpg-passphrase` | <p>Passphrase of the GPG Private Key</p> | `false` | `""` |
| `download-retry` | <p>Number of times to retry if the release is not ready (default 1)</p> | `false` | `""` |
| `download-latest` | <p>Download the latest release</p> | `false` | `false` |
| `verbose` | <p>Increase the verbosity level</p> | `false` | `false` |
| `override` | <p>Override an existing release by the same {tag}</p> | `false` | `false` |
| `prerelease` | <p>Mark Release as Pre-Release</p> | `false` | `false` |
<!-- action-docs-inputs source="action.yml" -->
| url | URL of the Forgejo instance | `false` | |
| repo | owner/project relative to the URL | `false` | |
| tag | Tag of the release | `false` | |
| sha | SHA of the release | `false` | |
| token | Forgejo application token | `true` | |
| release-dir | Directory in whichs release assets are uploaded or downloaded | `true` | |
| release-notes | Release notes | `false` | |
| 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 |
| override | Override an existing release by the same {tag} | `false` | false |
| prerelease | Mark Release as Pre-Release | `false` | false |
<!-- action-docs-inputs -->
## Example
@ -41,8 +39,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/forgejo-release@v1
with:
direction: upload
url: https://code.forgejo.org
direction: upload
url: https://code.forgejo.org
release-dir: dist/release
release-notes: "MY RELEASE NOTES"
```
@ -60,8 +58,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/forgejo-release@v1
with:
direction: download
url: https://code.forgejo.org
direction: download
url: https://code.forgejo.org
repo: forgejo/forgejo
tag: v1.21.4-0
release-dir: ./ # by default, files are downloaded into dist/release

View file

@ -10,8 +10,6 @@ inputs:
description: 'owner/project relative to the URL'
tag:
description: 'Tag of the release'
title:
description: 'Title of the release (defaults to tag)'
sha:
description: 'SHA of the release'
token:
@ -31,9 +29,6 @@ inputs:
description: 'Passphrase of the GPG Private Key'
download-retry:
description: 'Number of times to retry if the release is not ready (default 1)'
download-latest:
description: 'Download the latest release'
default: 'false'
verbose:
description: 'Increase the verbosity level'
default: 'false'
@ -71,20 +66,13 @@ runs:
TAG=${TAG##refs/tags/}
fi
export TITLE="${{ inputs.title }}"
export DOWNLOAD_LATEST="${{ inputs.download-latest }}"
export PRERELEASE="${{ inputs.prerelease }}"
export TOKEN="${{ inputs.token }}"
export RELEASE_DIR="${{ inputs.release-dir }}"
export RELEASENOTES=$(cat << 'EOF'
${{ inputs.release-notes }}
EOF
)
export RELEASENOTES="${{ inputs.release-notes }}"
export SHA="${{ inputs.sha }}"
if test -z "$SHA"; then

View file

@ -7,9 +7,7 @@ if ${VERBOSE:-false}; then set -x; fi
: ${FORGEJO:=https://codeberg.org}
: ${REPO:=forgejo-integration/forgejo}
: ${TITLE:=$TAG}
: ${RELEASE_DIR:=dist/release}
: ${DOWNLOAD_LATEST:=false}
: ${TMP_DIR:=$(mktemp -d)}
: ${GNUPGHOME:=$TMP_DIR}
: ${BIN_DIR:=$TMP_DIR}
@ -22,8 +20,7 @@ export GNUPGHOME
setup_tea() {
if ! test -f $BIN_DIR/tea ; then
ARCH=$(dpkg --print-architecture)
curl -sL https://dl.gitea.io/tea/$TEA_VERSION/tea-$TEA_VERSION-linux-$ARCH > $BIN_DIR/tea
curl -sL https://dl.gitea.io/tea/$TEA_VERSION/tea-$TEA_VERSION-linux-amd64 > $BIN_DIR/tea
chmod +x $BIN_DIR/tea
fi
}
@ -48,11 +45,11 @@ upload_release() {
test ${releasetype+false} || echo "Uploading as Stable"
ensure_tag
anchor=$(echo $TAG | sed -e 's/^v//' -e 's/[^a-zA-Z0-9]/-/g')
if ! $BIN_DIR/tea release create $assets --repo $REPO --note "$RELEASENOTES" --tag $TAG --title "$TITLE" --draft ${releasetype} >& $TMP_DIR/tea.log ; then
if ! $BIN_DIR/tea release create $assets --repo $REPO --note "$RELEASENOTES" --tag $TAG --title $TAG --draft ${releasetype} >& $TMP_DIR/tea.log ; then
if grep --quiet 'Unknown API Error: 500' $TMP_DIR/tea.log && grep --quiet services/release/release.go:194 $TMP_DIR/tea.log ; then
echo "workaround v1.20 race condition https://codeberg.org/forgejo/forgejo/issues/1370"
sleep 10
$BIN_DIR/tea release create $assets --repo $REPO --note "$RELEASENOTES" --tag $TAG --title "$TITLE" --draft ${releasetype}
$BIN_DIR/tea release create $assets --repo $REPO --note "$RELEASENOTES" --tag $TAG --title $TAG --draft ${releasetype}
else
cat $TMP_DIR/tea.log
return 1
@ -109,7 +106,7 @@ upload() {
setup_api() {
if ! which jq curl ; then
apt-get -qq update
apt-get install -y -qq jq curl
apt-get install -y -qq jq curl wget
fi
}
@ -145,23 +142,18 @@ wait_release() {
download() {
setup_api
wait_release
(
mkdir -p $RELEASE_DIR
cd $RELEASE_DIR
if [[ ${DOWNLOAD_LATEST} == "true" ]] ; then
echo "Downloading the latest release"
api GET repos/$REPO/releases/latest > $TMP_DIR/assets.json
elif [[ ${DOWNLOAD_LATEST} == "false" ]] ; then
wait_release
echo "Downloading tagged release ${TAG}"
api GET repos/$REPO/releases/tags/$TAG > $TMP_DIR/assets.json
fi
api GET repos/$REPO/releases/tags/$TAG > $TMP_DIR/assets.json
jq --raw-output '.assets[] | "\(.name) \(.browser_download_url)"' < $TMP_DIR/assets.json | while read name url ; do
curl --fail -H "Authorization: token $TOKEN" -o $name -L $url
wget --quiet -O $name $url
done
)
}
missing() {
echo need upload or download argument got nothing
exit 1

View file

@ -35,31 +35,6 @@ jobs:
release-dir: upload-dir
release-notes: "RELEASE NOTES"
verbose: true
- id: release-upload-override
uses: SELF@vTest
with:
direction: upload
url: ${{ steps.forgejo.outputs.url }}
repo: testuser/testrepo
tag: v1.0
sha: ${{ steps.testrepo.outputs.sha }}
token: ${{ steps.forgejo.outputs.token }}
release-dir: upload-dir
release-notes: "RELEASE NOTES"
override: true
verbose: true
- id: release-upload-v2
uses: SELF@vTest
with:
direction: upload
url: ${{ steps.forgejo.outputs.url }}
repo: testuser/testrepo
tag: v2.0
sha: ${{ steps.testrepo.outputs.sha }}
token: ${{ steps.forgejo.outputs.token }}
release-dir: upload-dir-v2
release-notes: "RELEASE NOTES V2"
verbose: true
- id: release-download
uses: SELF@vTest
with:
@ -72,17 +47,5 @@ jobs:
verbose: true
- run: |
diff -u upload-dir download-dir
- id: release-download-latest
uses: SELF@vTest
with:
direction: download
url: ${{ steps.forgejo.outputs.url }}
repo: testuser/testrepo
token: ${{ steps.forgejo.outputs.token }}
release-dir: download-dir-v2
download-latest: true
verbose: true
- run: |
diff -u upload-dir-v2 download-dir-v2
- if: failure()
run: docker logs forgejo

View file

@ -1 +0,0 @@
FILE1-V2

View file

@ -1 +0,0 @@
FILE2-V2

View file

@ -18,7 +18,7 @@ jobs:
release-notes: "RELEASE NOTES"
verbose: true
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
id: release-upload-override
id: release-upload
uses: SELF@vTest
with:
direction: upload
@ -26,17 +26,7 @@ jobs:
token: FORGEJO_TOKEN
release-dir: upload-dir
release-notes: "RELEASE NOTES"
override: true
verbose: true
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
id: release-upload-v2
uses: SELF@vTest
with:
direction: upload
tag: v2.0
token: FORGEJO_TOKEN
release-dir: upload-dir-v2
release-notes: "RELEASE NOTES V2"
override: "true"
verbose: true
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
id: release-download
@ -50,17 +40,3 @@ jobs:
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
run: |
diff -u upload-dir download-dir
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
id: release-download-latest
uses: SELF@vTest
with:
direction: download
token: FORGEJO_TOKEN
release-dir: download-dir-v2
download-latest: true
verbose: true
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
run: |
diff -u upload-dir-v2 download-dir-v2
- if: failure()
run: docker logs forgejo

View file

@ -1 +0,0 @@
FILE1-V2

View file

@ -1 +0,0 @@
FILE2-V2