From a6e3fdb19e717c1541300e0db39f14f22d03fa19 Mon Sep 17 00:00:00 2001 From: dorianim Date: Mon, 7 Apr 2025 06:35:43 +0000 Subject: [PATCH 1/4] feat: add default token and document default values (#44) This PR adds `${{ secrets.GITHUB_TOKEN }}` as the default value for the token and documents all default values in the readme. Fixes #43 Co-authored-by: Dorian Zedler Reviewed-on: https://code.forgejo.org/actions/forgejo-release/pulls/44 Reviewed-by: earl-warren Co-authored-by: dorianim Co-committed-by: dorianim --- README.md | 10 +++++----- action.yml | 21 +++++---------------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index eb93cf2..3a52c29 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,12 @@ Upload or download the assets of a release to a Forgejo instance. | name | description | required | default | | --- | --- | --- | --- | -| `url` |

URL of the Forgejo instance

| `false` | `""` | -| `repo` |

owner/project relative to the URL

| `false` | `""` | -| `tag` |

Tag of the release

| `false` | `""` | +| `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 }}` | | `title` |

Title of the release (defaults to tag)

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

SHA of the release

| `false` | `""` | -| `token` |

Forgejo application token

| `true` | `""` | +| `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` | `""` | | `release-notes` |

Release notes

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

Can either be download or upload

| `true` | `""` | diff --git a/action.yml b/action.yml index 847c886..7e09788 100644 --- a/action.yml +++ b/action.yml @@ -6,17 +6,21 @@ description: | inputs: url: description: 'URL of the Forgejo instance' + default: '${{ env.GITHUB_SERVER_URL }}' repo: description: 'owner/project relative to the URL' + default: '${{ github.repository }}' tag: description: 'Tag of the release' + default: '${{ github.ref_name }}' title: description: 'Title of the release (defaults to tag)' sha: description: 'SHA of the release' + default: '${{ github.sha }}' token: description: 'Forgejo application token' - required: true + default: '${{ secrets.GITHUB_TOKEN }}' release-dir: description: 'Directory in whichs release assets are uploaded or downloaded' required: true @@ -57,9 +61,6 @@ runs: shell: bash - run: | export FORGEJO="${{ inputs.url }}" - if test -z "$FORGEJO"; then - export FORGEJO="${{ env.GITHUB_SERVER_URL }}" - fi # 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%%/} @@ -67,17 +68,8 @@ runs: export HOST=${FORGEJO#*://} export REPO="${{ inputs.repo }}" - if test -z "$REPO"; then - export REPO="${{ github.repository }}" - fi export TAG="${{ inputs.tag }}" - if test -z "$TAG"; then - export TAG="${{ github.ref_name }}" - # until https://code.forgejo.org/forgejo/runner/issues/9 is fixed - # trim refs/tags/ - TAG=${TAG##refs/tags/} - fi export TITLE="${{ inputs.title }}" @@ -99,9 +91,6 @@ runs: ) export SHA="${{ inputs.sha }}" - if test -z "$SHA"; then - export SHA="${{ github.sha }}" - fi export OVERRIDE="${{ inputs.override }}" From a198449381c1c8feb1e0f1b63a2a23a7b9283a92 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 12 Apr 2025 13:20:25 +0200 Subject: [PATCH 2/4] chore: update the example to refer to v2.6.0 and be explicit about the parameters to improve readability --- README.md | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 3a52c29..f532c6b 100644 --- a/README.md +++ b/README.md @@ -37,16 +37,18 @@ Upload or download the assets of a release to a Forgejo instance. Upload the release located in `release-dir` to the release section of a repository (`url` and `repo`): ```yaml -on: [tag] jobs: upload-release: - runs-on: ubuntu-latest + runs-on: docker steps: - - uses: actions/checkout@v3 - - uses: actions/forgejo-release@v2 + - uses: actions/checkout@v4 + - uses: actions/forgejo-release@v2.6.0 with: direction: upload - url: https://code.forgejo.org + url: https://my-forgejo-instance.net + repo: myuser/myrepo + token: ${{ secrets.WRITE_TOKEN_TO_MYREPO }} + tag: v1.0.0 release-dir: dist/release release-notes: "MY RELEASE NOTES" ``` @@ -56,24 +58,24 @@ jobs: Example downloading the forgejo release v1.21.4-0 into the working directory: ```yaml -on: [tag] jobs: download-release: - runs-on: ubuntu-latest + runs-on: docker steps: - - uses: actions/checkout@v3 - - uses: actions/forgejo-release@v2 + - uses: actions/checkout@v4 + - uses: actions/forgejo-release@v2.6.0 with: direction: download - url: https://code.forgejo.org - repo: forgejo/forgejo - tag: v1.21.4-0 + url: https://my-forgejo-instance.net + repo: myuser/myrepo + token: ${{ secrets.READ_TOKEN_TO_MYREPO }} + tag: v1.0.0 release-dir: ./ # by default, files are downloaded into dist/release ``` ### Real world example -This action is used to [publish](https://code.forgejo.org/forgejo/release-notes-assistant/src/branch/main/.forgejo/workflows/release.yml) the release notes assistant assets. +This action is used to [publish](https://code.forgejo.org/forgejo/release-notes-assistant/src/commit/09f2c22d80d5ee655783cfeb2c1d4bab4afec3e4/.forgejo/workflows/release.yml) the release notes assistant assets. ## Update the `input` section of the README From dccbd17bd860737c9cdebd1d081a7c81d31b40e4 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 12 Apr 2025 13:33:43 +0200 Subject: [PATCH 3/4] chore: teach renovate to update the example version --- renovate.json | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/renovate.json b/renovate.json index e95bd65..b676ef6 100644 --- a/renovate.json +++ b/renovate.json @@ -1,6 +1,18 @@ { - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "local>actions/renovate-config" - ] + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["local>actions/renovate-config"], + "customManagers": [ + { + "customType": "regex", + "description": "update example in README.md", + "fileMatch": ["^README.md$"], + "matchStrings": [ + "uses: actions/forgejo-release@(?v\\d+\\.\\d+\\.\\d+)" + ], + "datasourceTemplate": "gitea-tags", + "depNameTemplate": "actions/forgejo-release", + "versioningTemplate": "semver", + "registryUrlTemplate": "https://code.forgejo.org" + } + ] } From f0a9704521e65840e818ab30cbc842540f671c1f Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sun, 13 Apr 2025 08:31:13 +0000 Subject: [PATCH 4/4] Update https://code.forgejo.org/actions/setup-forgejo action to v2.0.11 --- .forgejo/workflows/integration.yml | 2 +- testdata/nested-upload-download/.forgejo/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/integration.yml b/.forgejo/workflows/integration.yml index ced0ae6..343fa7b 100644 --- a/.forgejo/workflows/integration.yml +++ b/.forgejo/workflows/integration.yml @@ -6,7 +6,7 @@ jobs: - uses: actions/checkout@v3 - id: forgejo - uses: https://code.forgejo.org/actions/setup-forgejo@v2.0.4 + uses: https://code.forgejo.org/actions/setup-forgejo@v2.0.11 with: user: testuser password: admin1234 diff --git a/testdata/nested-upload-download/.forgejo/workflows/test.yml b/testdata/nested-upload-download/.forgejo/workflows/test.yml index e315714..293fa40 100644 --- a/testdata/nested-upload-download/.forgejo/workflows/test.yml +++ b/testdata/nested-upload-download/.forgejo/workflows/test.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v3 - id: forgejo - uses: https://code.forgejo.org/actions/setup-forgejo@v1.0.1 + uses: https://code.forgejo.org/actions/setup-forgejo@v2.0.11 with: user: testuser password: admin1234