mirror of
https://code.forgejo.org/actions/forgejo-release.git
synced 2026-02-16 23:23:11 +00:00
Compare commits
9 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c747b97f9 | ||
|
|
8fb94f88a4 | ||
|
|
94a60cb661 | ||
|
|
b5fa0f2e61 | ||
|
|
21f672cae6 | ||
|
|
454bc2681f | ||
|
|
4b5fdf8538 | ||
|
|
5c6400d871 | ||
|
|
a1314c9c65 |
|
|
@ -5,7 +5,7 @@ on:
|
||||||
- "**"
|
- "**"
|
||||||
|
|
||||||
env:
|
env:
|
||||||
FORGEJO_VERSION: 11.0.10 # renovate: datasource=docker depName=code.forgejo.org/forgejo/forgejo
|
FORGEJO_VERSION: 11.0.10 # renovate: datasource=docker depName=data.forgejo.org/forgejo/forgejo
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
integration:
|
integration:
|
||||||
|
|
@ -14,7 +14,7 @@ jobs:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
- id: forgejo
|
- id: forgejo
|
||||||
uses: https://code.forgejo.org/actions/setup-forgejo@v3.1.1
|
uses: https://code.forgejo.org/actions/setup-forgejo@v3.1.4
|
||||||
with:
|
with:
|
||||||
user: testuser
|
user: testuser
|
||||||
password: admin1234
|
password: admin1234
|
||||||
|
|
@ -48,6 +48,37 @@ jobs:
|
||||||
|
|
||||||
test $(cat /tmp/v1.json | jq -r .hide_archive_links) = true
|
test $(cat /tmp/v1.json | jq -r .hide_archive_links) = true
|
||||||
|
|
||||||
|
- name: testdata/release-notes-file
|
||||||
|
run: |
|
||||||
|
export LOOP_DELAY=30
|
||||||
|
export FORGEJO_RUNNER_LOGS="${{ steps.forgejo.outputs.runner-logs }}"
|
||||||
|
forgejo-test-helper.sh run_workflow testdata/release-notes-file http://testuser:admin1234@${{ steps.forgejo.outputs.host-port }} testuser release-notes-file forgejo-release "${{ steps.forgejo.outputs.token }}"
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
export FORGEJO="${{ steps.forgejo.outputs.url }}"
|
||||||
|
curl --fail -sS $FORGEJO/api/v1/repos/testuser/release-notes-file/releases/tags/v1.0 > /tmp/v1.json
|
||||||
|
curl --fail -sS $FORGEJO/api/v1/repos/testuser/release-notes-file/releases/tags/v2.0 > /tmp/v2.json
|
||||||
|
curl --fail -sS $FORGEJO/api/v1/repos/testuser/release-notes-file/releases/tags/v3.0 > /tmp/v3.json
|
||||||
|
|
||||||
|
EXPECTED='# This is a Release Note
|
||||||
|
|
||||||
|
Some *formatted*,
|
||||||
|
|
||||||
|
multiline
|
||||||
|
|
||||||
|
Markdown content.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
echo "Even a code block"
|
||||||
|
```'
|
||||||
|
test "$EXPECTED" = "$(jq -r .body < /tmp/v1.json)"
|
||||||
|
|
||||||
|
test "$EXPECTED" = "$(jq -r .body < /tmp/v2.json)"
|
||||||
|
test "I wont be there" != "$(jq -r .body < /tmp/v2.json)"
|
||||||
|
|
||||||
|
test "$EXPECTED" != "$(jq -r .body < /tmp/v3.json)"
|
||||||
|
test "I will be there" = "$(jq -r .body < /tmp/v3.json)"
|
||||||
|
|
||||||
- name: testdata/upload-download-private
|
- name: testdata/upload-download-private
|
||||||
run: |
|
run: |
|
||||||
export LOOP_DELAY=30
|
export LOOP_DELAY=30
|
||||||
|
|
|
||||||
26
README.md
26
README.md
|
|
@ -18,6 +18,7 @@ Upload or download the assets of a release to a Forgejo instance.
|
||||||
| `token` | <p>Forgejo application token (must have <code>write:repository</code>)</p> | `false` | `${{ forge.token }}` |
|
| `token` | <p>Forgejo application token (must have <code>write:repository</code>)</p> | `false` | `${{ forge.token }}` |
|
||||||
| `release-dir` | <p>Directory in which release assets are uploaded or downloaded</p> | `false` | `dist/release` |
|
| `release-dir` | <p>Directory in which release assets are uploaded or downloaded</p> | `false` | `dist/release` |
|
||||||
| `release-notes` | <p>Release notes</p> | `false` | `""` |
|
| `release-notes` | <p>Release notes</p> | `false` | `""` |
|
||||||
|
| `release-notes-file` | <p>Path to a file containing your release notes (takes priority over <code>release-notes</code>)</p> | `false` | `""` |
|
||||||
| `direction` | <p>Can either be <code>download</code> or <code>upload</code></p> | `true` | `""` |
|
| `direction` | <p>Can either be <code>download</code> or <code>upload</code></p> | `true` | `""` |
|
||||||
| `gpg-private-key` | <p>GPG Private Key to sign the release artifacts</p> | `false` | `""` |
|
| `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` | `""` |
|
| `gpg-passphrase` | <p>Passphrase of the GPG Private Key</p> | `false` | `""` |
|
||||||
|
|
@ -43,7 +44,7 @@ jobs:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/forgejo-release@v2.8.0
|
- uses: actions/forgejo-release@v2.9.1
|
||||||
with:
|
with:
|
||||||
direction: upload
|
direction: upload
|
||||||
url: https://my-forgejo-instance.net
|
url: https://my-forgejo-instance.net
|
||||||
|
|
@ -54,6 +55,27 @@ jobs:
|
||||||
release-notes: "MY RELEASE NOTES"
|
release-notes: "MY RELEASE NOTES"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Upload a release with custom release notes located in a file:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
upload-release:
|
||||||
|
runs-on: docker
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Generate Changelog
|
||||||
|
run: ./generate-changelog.sh > dist/changelog.md
|
||||||
|
- uses: actions/forgejo-release@v2.7.3
|
||||||
|
with:
|
||||||
|
direction: upload
|
||||||
|
url: https://my-forgejo-instance.net
|
||||||
|
repo: myuser/myrepo
|
||||||
|
token: ${{ secrets.WRITE_TOKEN_TO_MYREPO }}
|
||||||
|
tag: v13.0.2
|
||||||
|
release-dir: dist/release
|
||||||
|
release-notes-file: dist/changelog.md
|
||||||
|
```
|
||||||
|
|
||||||
### Download
|
### Download
|
||||||
|
|
||||||
Example downloading the forgejo release v1.21.4-0 into the working directory:
|
Example downloading the forgejo release v1.21.4-0 into the working directory:
|
||||||
|
|
@ -64,7 +86,7 @@ jobs:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/forgejo-release@v2.8.0
|
- uses: actions/forgejo-release@v2.9.1
|
||||||
with:
|
with:
|
||||||
direction: download
|
direction: download
|
||||||
url: https://my-forgejo-instance.net
|
url: https://my-forgejo-instance.net
|
||||||
|
|
|
||||||
12
action.yml
12
action.yml
|
|
@ -26,6 +26,8 @@ inputs:
|
||||||
default: 'dist/release'
|
default: 'dist/release'
|
||||||
release-notes:
|
release-notes:
|
||||||
description: 'Release notes'
|
description: 'Release notes'
|
||||||
|
release-notes-file:
|
||||||
|
description: 'Path to a file containing your release notes (takes priority over `release-notes`)'
|
||||||
direction:
|
direction:
|
||||||
description: 'Can either be `download` or `upload`'
|
description: 'Can either be `download` or `upload`'
|
||||||
required: true
|
required: true
|
||||||
|
|
@ -100,6 +102,16 @@ runs:
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
|
RELEASENOTES_FILE="${{ inputs.release-notes-file }}"
|
||||||
|
if [ ! -z "$RELEASENOTES_FILE" ]; then
|
||||||
|
if [ ! -f "$RELEASENOTES_FILE" ]; then
|
||||||
|
echo "! Release notes file $RELEASENOTES_FILE does not exist."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
export RELEASENOTES=$(cat "$RELEASENOTES_FILE")
|
||||||
|
fi
|
||||||
|
|
||||||
export SHA="${{ inputs.sha }}"
|
export SHA="${{ inputs.sha }}"
|
||||||
|
|
||||||
export OVERRIDE="${{ inputs.override }}"
|
export OVERRIDE="${{ inputs.override }}"
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,9 @@ if ${VERBOSE:-false}; then set -x; fi
|
||||||
: ${HIDE_ARCHIVE_LINK:=false}
|
: ${HIDE_ARCHIVE_LINK:=false}
|
||||||
: ${RETRY:=1}
|
: ${RETRY:=1}
|
||||||
: ${DELAY:=10}
|
: ${DELAY:=10}
|
||||||
|
: ${SKIP_ASSETS:=false}
|
||||||
|
|
||||||
RELEASE_NOTES_ASSISTANT_VERSION=v1.5.1 # renovate: datasource=forgejo-releases depName=forgejo/release-notes-assistant registryUrl=https://code.forgejo.org
|
RELEASE_NOTES_ASSISTANT_VERSION=v1.5.2 # renovate: datasource=forgejo-releases depName=forgejo/release-notes-assistant registryUrl=https://code.forgejo.org
|
||||||
|
|
||||||
TAG_FILE="$TMP_DIR/tag$$.json"
|
TAG_FILE="$TMP_DIR/tag$$.json"
|
||||||
TAG_URL=$(echo "$TAG" | sed 's/\//%2F/g')
|
TAG_URL=$(echo "$TAG" | sed 's/\//%2F/g')
|
||||||
|
|
@ -84,7 +85,7 @@ upload_release() {
|
||||||
# It is expanded using "${assets[@]}" which preserves the separation of arguments and not split whitespace containing values.
|
# 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
|
# For reference, see https://github.com/koalaman/shellcheck/wiki/SC2086#exceptions
|
||||||
local assets=()
|
local assets=()
|
||||||
if ! "$SKIP_ASSETS"; then
|
if [ "$SKIP_ASSETS" == 'false' ]; then
|
||||||
for file in "$RELEASE_DIR"/*; do
|
for file in "$RELEASE_DIR"/*; do
|
||||||
assets=("${assets[@]}" -a "$file")
|
assets=("${assets[@]}" -a "$file")
|
||||||
done
|
done
|
||||||
|
|
@ -209,7 +210,7 @@ download() {
|
||||||
(
|
(
|
||||||
mkdir -p $RELEASE_DIR
|
mkdir -p $RELEASE_DIR
|
||||||
cd $RELEASE_DIR
|
cd $RELEASE_DIR
|
||||||
if [[ ${DOWNLOAD_LATEST} == "true" ]]; then
|
if [[ ${DOWNLOAD_LATEST} = "true" ]]; then
|
||||||
echo "Downloading the latest release"
|
echo "Downloading the latest release"
|
||||||
api GET repos/$REPO/releases/latest >"$TMP_DIR"/assets.json
|
api GET repos/$REPO/releases/latest >"$TMP_DIR"/assets.json
|
||||||
elif [[ ${DOWNLOAD_LATEST} == "false" ]]; then
|
elif [[ ${DOWNLOAD_LATEST} == "false" ]]; then
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- id: forgejo
|
- id: forgejo
|
||||||
uses: https://code.forgejo.org/actions/setup-forgejo@v3.1.1
|
uses: https://code.forgejo.org/actions/setup-forgejo@v3.1.4
|
||||||
with:
|
with:
|
||||||
user: testuser
|
user: testuser
|
||||||
password: admin1234
|
password: admin1234
|
||||||
|
|
|
||||||
44
testdata/release-notes-file/.forgejo/workflows/test.yml
vendored
Normal file
44
testdata/release-notes-file/.forgejo/workflows/test.yml
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
name: Upload a release with Release Notes to the project that runs the workflow
|
||||||
|
on: [push]
|
||||||
|
jobs:
|
||||||
|
upload-download:
|
||||||
|
runs-on: lxc-bookworm
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
|
||||||
|
id: release-notes-file
|
||||||
|
uses: SELF@vTest
|
||||||
|
with:
|
||||||
|
direction: upload
|
||||||
|
tag: v1.0
|
||||||
|
token: FORGEJO_TEST_TOKEN
|
||||||
|
release-dir: upload-dir
|
||||||
|
release-notes-file: upload-dir/RELEASE_NOTES.md
|
||||||
|
verbose: true
|
||||||
|
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
|
||||||
|
id: release-notes-file-takes-precedence
|
||||||
|
uses: SELF@vTest
|
||||||
|
with:
|
||||||
|
direction: upload
|
||||||
|
tag: v2.0
|
||||||
|
token: FORGEJO_TEST_TOKEN
|
||||||
|
release-dir: upload-dir
|
||||||
|
release-notes: "I wont be there"
|
||||||
|
release-notes-file: upload-dir/RELEASE_NOTES.md
|
||||||
|
verbose: true
|
||||||
|
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
|
||||||
|
id: release-notes
|
||||||
|
uses: SELF@vTest
|
||||||
|
with:
|
||||||
|
direction: upload
|
||||||
|
tag: v3.0
|
||||||
|
token: FORGEJO_TEST_TOKEN
|
||||||
|
release-dir: upload-dir
|
||||||
|
release-notes: "I will be there"
|
||||||
|
verbose: true
|
||||||
1
testdata/release-notes-file/.gitignore
vendored
Normal file
1
testdata/release-notes-file/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
*~
|
||||||
12
testdata/release-notes-file/upload-dir/RELEASE_NOTES.md
vendored
Normal file
12
testdata/release-notes-file/upload-dir/RELEASE_NOTES.md
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
# This is a Release Note
|
||||||
|
|
||||||
|
Some *formatted*,
|
||||||
|
|
||||||
|
multiline
|
||||||
|
|
||||||
|
Markdown content.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
echo "Even a code block"
|
||||||
|
```
|
||||||
|
|
||||||
1
testdata/release-notes-file/upload-dir/file 3.txt
vendored
Normal file
1
testdata/release-notes-file/upload-dir/file 3.txt
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
FILE3
|
||||||
1
testdata/release-notes-file/upload-dir/file1.txt
vendored
Normal file
1
testdata/release-notes-file/upload-dir/file1.txt
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
FILE1
|
||||||
1
testdata/release-notes-file/upload-dir/file2.txt
vendored
Normal file
1
testdata/release-notes-file/upload-dir/file2.txt
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
FILE2
|
||||||
Loading…
Reference in a new issue