diff --git a/.forgejo/workflows/integration.yml b/.forgejo/workflows/integration.yml index f3dd035..c8c5f1e 100644 --- a/.forgejo/workflows/integration.yml +++ b/.forgejo/workflows/integration.yml @@ -1,16 +1,24 @@ -on: [ pull_request, push ] +on: + pull_request: + push: + branches: + - "**" + +env: + FORGEJO_VERSION: 11.0.10 # renovate: datasource=docker depName=code.forgejo.org/forgejo/forgejo + jobs: integration: - runs-on: self-hosted + runs-on: lxc-trixie steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - id: forgejo - uses: https://code.forgejo.org/actions/setup-forgejo@v3.0.4 + uses: https://code.forgejo.org/actions/setup-forgejo@v3.1.1 with: user: testuser password: admin1234 - image-version: 9 + image-version: ${{ env.FORGEJO_VERSION }} - name: push self run: | @@ -62,7 +70,7 @@ jobs: testdata/forgejo-release-test.sh test_run testuser otherrepo - if: always() - name: '[RUNNER] and [FORGEJO] logs' + name: "[RUNNER] and [FORGEJO] logs" run: | runner_logs="${{ steps.forgejo.outputs.runner-logs }}" if test -f "$runner_logs"; then diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml new file mode 100644 index 0000000..e3c5bca --- /dev/null +++ b/.forgejo/workflows/release.yml @@ -0,0 +1,23 @@ +on: + push: + tags: + - v* + +jobs: + publish: + runs-on: docker + + steps: + # needs to be in a different dir, so binary and rna cache don't conflict + - uses: https://data.forgejo.org/actions/checkout@v6 + with: + path: forgejo-release + + - name: publish release + uses: ./forgejo-release + with: + direction: upload + override: ${{ vars.OVERRIDE || 'false' }} + verbose: ${{ vars.VERBOSE || 'false' }} + release-notes-assistant: true + skip-assets: true diff --git a/.forgejo/workflows/tests.yml b/.forgejo/workflows/tests.yml index a493847..d521c77 100644 --- a/.forgejo/workflows/tests.yml +++ b/.forgejo/workflows/tests.yml @@ -1,9 +1,26 @@ -on: [ pull_request, push ] +on: + pull_request: + push: + branches: + - "**" + jobs: tests: runs-on: docker + container: + image: data.forgejo.org/oci/node:24-trixie + steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 + + - name: lint action-docs + run: | + npx --yes action-docs -u + git diff --quiet || { + echo "[ERROR] Please apply the changes action-docs suggests:" + git diff --color=always + exit 1 + } - name: Unit tests of the supporting script forgejo-release.sh run: | diff --git a/README.md b/README.md index 23bb315..d14ee28 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,13 @@ Upload or download the assets of a release to a Forgejo instance. | name | description | required | default | | --- | --- | --- | --- | -| `url` |

URL of the Forgejo instance

| `false` | `${{ env.GITHUB_SERVER_URL }}` | -| `repo` |

owner/project relative to the URL

| `false` | `${{ github.repository }}` | -| `tag` |

Tag of the release

| `false` | `${{ github.ref_name }}` | +| `url` |

URL of the Forgejo instance

| `false` | `${{ env.FORGEJO_SERVER_URL }}` | +| `repo` |

owner/project relative to the URL

| `false` | `${{ forge.repository }}` | +| `tag` |

Tag of the release

| `false` | `${{ forge.ref_name }}` | | `title` |

Title of the release (defaults to tag)

| `false` | `""` | -| `sha` |

SHA of the release

| `false` | `${{ github.sha }}` | -| `token` |

Forgejo application token

| `false` | `${{ secrets.GITHUB_TOKEN }}` | -| `release-dir` |

Directory in whichs release assets are uploaded or downloaded

| `true` | `""` | +| `sha` |

SHA of the release

| `false` | `${{ forge.sha }}` | +| `token` |

Forgejo application token (must have write:repository)

| `false` | `${{ forge.token }}` | +| `release-dir` |

Directory in which release assets are uploaded or downloaded

| `false` | `dist/release` | | `release-notes` |

Release notes

| `false` | `""` | | `release-notes-file` |

Path to a file containing your release notes (takes priority over `release-notes`)

| `false` | `""` | | `direction` |

Can either be download or upload

| `true` | `""` | @@ -29,6 +29,7 @@ Upload or download the assets of a release to a Forgejo instance. | `prerelease` |

Mark Release as Pre-Release

| `false` | `false` | | `release-notes-assistant` |

Generate release notes with Release Notes Assistant

| `false` | `false` | | `hide-archive-link` |

Hide the archive links

| `false` | `false` | +| `skip-assets` |

Skip uploading release assets

| `false` | `false` | ## Examples @@ -43,7 +44,7 @@ jobs: runs-on: docker steps: - uses: actions/checkout@v4 - - uses: actions/forgejo-release@v2.7.3 + - uses: actions/forgejo-release@v2.9.0 with: direction: upload url: https://my-forgejo-instance.net @@ -85,7 +86,7 @@ jobs: runs-on: docker steps: - uses: actions/checkout@v4 - - uses: actions/forgejo-release@v2.7.3 + - uses: actions/forgejo-release@v2.9.0 with: direction: download url: https://my-forgejo-instance.net @@ -105,5 +106,5 @@ Using [action-docs](https://github.com/npalm/action-docs): ```shell # Edit the action.yml file and run: -action-docs --update-readme +npx action-docs --update-readme ``` diff --git a/action.yml b/action.yml index 3ecf3ed..0faccfa 100644 --- a/action.yml +++ b/action.yml @@ -19,11 +19,11 @@ inputs: description: 'SHA of the release' default: '${{ forge.sha }}' token: - description: 'Forgejo application token' + description: 'Forgejo application token (must have `write:repository`)' default: '${{ forge.token }}' release-dir: - description: 'Directory in whichs release assets are uploaded or downloaded' - required: true + description: 'Directory in which release assets are uploaded or downloaded' + default: 'dist/release' release-notes: description: 'Release notes' release-notes-file: @@ -40,22 +40,25 @@ inputs: description: 'Number of times to retry if the release is not ready (default 1)' download-latest: description: 'Download the latest release' - default: false + default: 'false' verbose: description: 'Increase the verbosity level' - default: false + default: 'false' override: description: 'Override an existing release by the same `{tag}`' - default: false + default: 'false' prerelease: description: 'Mark Release as Pre-Release' - default: false + default: 'false' release-notes-assistant: description: 'Generate release notes with Release Notes Assistant' - default: false + default: 'false' hide-archive-link: description: 'Hide the archive links' - default: false + default: 'false' + skip-assets: + description: Skip uploading release assets + default: 'false' runs: using: "composite" @@ -126,5 +129,7 @@ runs: echo -n "${{ inputs.gpg-passphrase }}" > $TMP_DIR/gpg-passphrase export GPG_PASSPHRASE="$TMP_DIR/gpg-passphrase" + export SKIP_ASSETS="${{ inputs.skip-assets }}" + forgejo-release.sh ${{ inputs.direction }} shell: bash diff --git a/forgejo-release.sh b/forgejo-release.sh index 5ba1c6e..22bdbab 100755 --- a/forgejo-release.sh +++ b/forgejo-release.sh @@ -19,7 +19,7 @@ if ${VERBOSE:-false}; then set -x; fi : ${RETRY:=1} : ${DELAY:=10} -RELEASE_NOTES_ASSISTANT_VERSION=v1.4.1 # renovate: datasource=forgejo-releases depName=forgejo/release-notes-assistant registryUrl=https://code.forgejo.org +RELEASE_NOTES_ASSISTANT_VERSION=v1.5.1 # renovate: datasource=forgejo-releases depName=forgejo/release-notes-assistant registryUrl=https://code.forgejo.org TAG_FILE="$TMP_DIR/tag$$.json" TAG_URL=$(echo "$TAG" | sed 's/\//%2F/g') @@ -84,9 +84,11 @@ upload_release() { # It is expanded using "${assets[@]}" which preserves the separation of arguments and not split whitespace containing values. # For reference, see https://github.com/koalaman/shellcheck/wiki/SC2086#exceptions local assets=() - for file in "$RELEASE_DIR"/*; do - assets=("${assets[@]}" -a "$file") - done + if ! "$SKIP_ASSETS"; then + for file in "$RELEASE_DIR"/*; do + assets=("${assets[@]}" -a "$file") + done + fi if $PRERELEASE || echo "${TAG}" | grep -qi '\-rc'; then releaseType="--prerelease" echo "Uploading as Pre-Release" diff --git a/renovate.json b/renovate.json index 1fd35ff..b0a5d5e 100644 --- a/renovate.json +++ b/renovate.json @@ -3,6 +3,14 @@ "extends": [ "local>actions/renovate-config" ], + "packageRules": [ + { + "description": "separate multiple major and minor for forgejo", + "matchDepNames": ["code.forgejo.org/forgejo/forgejo"], + "separateMultipleMajor": true, + "separateMultipleMinor": true + } + ], "customManagers": [ { "customType": "regex", diff --git a/testdata/nested-upload-download/.forgejo/workflows/test.yml b/testdata/nested-upload-download/.forgejo/workflows/test.yml index 39031fd..29d118d 100644 --- a/testdata/nested-upload-download/.forgejo/workflows/test.yml +++ b/testdata/nested-upload-download/.forgejo/workflows/test.yml @@ -6,18 +6,22 @@ # name: two Forgejo on: [push] + +env: + FORGEJO_VERSION: 11.0.9 # renovate: datasource=docker depName=code.forgejo.org/forgejo/forgejo + jobs: setup-forgejo: runs-on: self-hosted steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - id: forgejo - uses: https://code.forgejo.org/actions/setup-forgejo@v3.0.4 + uses: https://code.forgejo.org/actions/setup-forgejo@v3.1.1 with: user: testuser password: admin1234 lxc-ip-prefix: 10.0.15 - image-version: 1.20 + image-version: ${{ env.FORGEJO_VERSION }} - id: testrepo run: | url=http://testuser:admin1234@${{ steps.forgejo.outputs.host-port }} diff --git a/testdata/upload-download/.forgejo/workflows/gpg-no-passphrase.yml b/testdata/upload-download/.forgejo/workflows/gpg-no-passphrase.yml index a0cf926..bfd5469 100644 --- a/testdata/upload-download/.forgejo/workflows/gpg-no-passphrase.yml +++ b/testdata/upload-download/.forgejo/workflows/gpg-no-passphrase.yml @@ -90,9 +90,9 @@ jobs: upload-gpg-no-passphrase: runs-on: docker container: - image: 'data.forgejo.org/oci/node:22-bookworm' + image: 'data.forgejo.org/oci/node:24-bookworm' steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - if: ${{ !startsWith(github.ref, 'refs/tags/v') }} id: release-upload uses: SELF@vTest diff --git a/testdata/upload-download/.forgejo/workflows/gpg.yml b/testdata/upload-download/.forgejo/workflows/gpg.yml index c33af75..ea94668 100644 --- a/testdata/upload-download/.forgejo/workflows/gpg.yml +++ b/testdata/upload-download/.forgejo/workflows/gpg.yml @@ -27,7 +27,7 @@ jobs: upload-gpg: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - if: ${{ !startsWith(github.ref, 'refs/tags/v') }} id: release-upload uses: SELF@vTest diff --git a/testdata/upload-download/.forgejo/workflows/test.yml b/testdata/upload-download/.forgejo/workflows/test.yml index e77982e..518e019 100644 --- a/testdata/upload-download/.forgejo/workflows/test.yml +++ b/testdata/upload-download/.forgejo/workflows/test.yml @@ -6,7 +6,7 @@ jobs: upload-download: runs-on: lxc-bookworm steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - if: ${{ !startsWith(github.ref, 'refs/tags/v') }} id: release-upload uses: SELF@vTest @@ -92,5 +92,35 @@ jobs: - if: ${{ !startsWith(github.ref, 'refs/tags/v') }} run: | diff -u upload-dir-v3 download-dir-v3 + + - if: ${{ !startsWith(github.ref, 'refs/tags/v') }} + id: release-upload-v4 + uses: SELF@vTest + with: + direction: upload + tag: v4.0 + token: FORGEJO_TEST_TOKEN + skip-assets: true + verbose: true + + - if: ${{ !startsWith(github.ref, 'refs/tags/v') }} + id: release-download-v4 + uses: SELF@vTest + with: + direction: download + tag: v4.0 + token: FORGEJO_TEST_TOKEN + release-dir: download-dir-v4 + - if: ${{ !startsWith(github.ref, 'refs/tags/v') }} + run: | + if [ ! -d download-dir-v4 ]; then + echo "Missing download dir" + exit 1 + fi + if [ ! -z "$( ls -A download-dir-v4 )" ]; then + echo "Unexpected download files: $( ls -A download-dir-v4 )" + exit 1 + fi + - if: failure() run: docker logs forgejo