From 59d006123bbe678ec1ab7d2516767378c36d3f7f Mon Sep 17 00:00:00 2001 From: natct Date: Tue, 29 Oct 2024 16:08:41 +0100 Subject: [PATCH 1/3] feat(ci): use Release Notes Assistant --- README.md | 1 + action.yml | 7 +++++++ forgejo-release.sh | 25 +++++++++++++++++-------- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e879520..eb2cd79 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ Upload or download the assets of a release to a Forgejo instance. | `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` | +| `release-notes-assistant` |

Generate release notes with Release Notes Assistant

| `false` | `false` | ## Examples diff --git a/action.yml b/action.yml index db93c7c..f903b1c 100644 --- a/action.yml +++ b/action.yml @@ -43,6 +43,9 @@ inputs: prerelease: description: 'Mark Release as Pre-Release' default: 'false' + release-notes-assistant: + description: 'Generate release notes with Release Notes Assistant' + default: 'false' runs: using: "composite" @@ -57,6 +60,8 @@ runs: # 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%%/} + export SCHEME=${FORGEJO%://*} + export HOST=${FORGEJO#*://} export REPO="${{ inputs.repo }}" if test -z "$REPO"; then @@ -77,6 +82,8 @@ runs: export PRERELEASE="${{ inputs.prerelease }}" + export RELEASE_NOTES_ASSISTANT="${{ inputs.release-notes-assistant }}" + export TOKEN="${{ inputs.token }}" export RELEASE_DIR="${{ inputs.release-dir }}" diff --git a/forgejo-release.sh b/forgejo-release.sh index 70c57cf..13c9493 100755 --- a/forgejo-release.sh +++ b/forgejo-release.sh @@ -52,15 +52,16 @@ upload_release() { 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 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} - else - cat $TMP_DIR/tea.log - return 1 - fi + 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} + else + cat $TMP_DIR/tea.log + return 1 + fi fi + maybe_use_release_note_assistant release_draft false } @@ -71,6 +72,14 @@ release_draft() { api PATCH repos/$REPO/releases/$id --data-raw '{"draft": '$state'}' } +maybe_use_release_note_assistant() { + if "$RELEASE_NOTES_ASSISTANT"; then + curl --fail -s -S -o rna https://code.forgejo.org/forgejo/release-notes-assistant/releases/download/v1.2.3/release-notes-assistant + chmod +x ./rna + ./rna --storage release --storage-location $TAG --forgejo-url $SCHEME://placeholder:$TOKEN@$HOST --repository $REPO --token $TOKEN release $TAG + fi +} + sign_release() { local passphrase if test -s "$GPG_PASSPHRASE"; then From 0ac99a8b42e1ef35382ab699ceda6b87482a73cf Mon Sep 17 00:00:00 2001 From: natct Date: Mon, 18 Nov 2024 11:31:53 +0100 Subject: [PATCH 2/3] feat(ci): add test for `rna` --- .forgejo/workflows/integration.yml | 3 +++ testdata/upload-download/.forgejo/workflows/test.yml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/integration.yml b/.forgejo/workflows/integration.yml index b92a2db..d3f2543 100644 --- a/.forgejo/workflows/integration.yml +++ b/.forgejo/workflows/integration.yml @@ -32,6 +32,9 @@ jobs: - !exclamation_mark' test "$EXPECTED" = "$(jq -r .body < /tmp/release.json)" + curl --fail -sS $FORGEJO/api/v1/repos/testuser/upload-download/releases/tags/v1.0 > /tmp/v1.json + cat /tmp/v1.json | jq -r .body | grep '' + - name: testdata/upload-download-private run: | export FORGEJO_RUNNER_LOGS="${{ steps.forgejo.outputs.runner-logs }}" diff --git a/testdata/upload-download/.forgejo/workflows/test.yml b/testdata/upload-download/.forgejo/workflows/test.yml index 39d8a62..be2a6a8 100644 --- a/testdata/upload-download/.forgejo/workflows/test.yml +++ b/testdata/upload-download/.forgejo/workflows/test.yml @@ -25,7 +25,7 @@ jobs: tag: v1.0 token: FORGEJO_TOKEN release-dir: upload-dir - release-notes: "RELEASE NOTES" + release-notes-assistant: true override: true verbose: true - if: ${{ !startsWith(github.ref, 'refs/tags/v') }} From 63e4d05f9d9f3b5e838d74a60b682a5da1ef8683 Mon Sep 17 00:00:00 2001 From: natct Date: Mon, 18 Nov 2024 11:25:18 +0100 Subject: [PATCH 3/3] feat(ci): update `setup-forgejo` version --- .forgejo/workflows/integration.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/integration.yml b/.forgejo/workflows/integration.yml index d3f2543..9d81aae 100644 --- a/.forgejo/workflows/integration.yml +++ b/.forgejo/workflows/integration.yml @@ -6,11 +6,11 @@ jobs: - uses: actions/checkout@v3 - id: forgejo - uses: https://code.forgejo.org/actions/setup-forgejo@v1 + uses: https://code.forgejo.org/actions/setup-forgejo@v2.0.2 with: user: testuser password: admin1234 - image-version: 1.20 + image-version: 9 - name: push self run: |