+13
-7
@@ -1,11 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
#
|
||||||
# Create a Gitea release for a tag and upload everything in out/.
|
# Create a Gitea release and upload everything in out/.
|
||||||
# Mirrors the repo's existing Gitea-API release convention.
|
# Mirrors the repo's existing Gitea-API release convention.
|
||||||
#
|
#
|
||||||
# Config via env (or a local .env next to this script):
|
# Config via env (or a local .env next to this script):
|
||||||
# GITEA_SERVER_URL, GITEA_REPOSITORY, GITEA_TOKEN
|
# GITEA_SERVER_URL, GITEA_REPOSITORY, PAT_GITEA
|
||||||
# Tag: passed as $1 (in CI: gitea.ref_name), else derived from the current commit.
|
# Tag: $1 if given, else the tag on HEAD, else derived as v<server-version>-<shortsha>.
|
||||||
#
|
#
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
@@ -15,17 +15,23 @@ cd "$(dirname "$0")"
|
|||||||
|
|
||||||
: "${GITEA_SERVER_URL:?}"
|
: "${GITEA_SERVER_URL:?}"
|
||||||
: "${GITEA_REPOSITORY:?}"
|
: "${GITEA_REPOSITORY:?}"
|
||||||
: "${GITEA_TOKEN:?}"
|
: "${PAT_GITEA:?}"
|
||||||
|
|
||||||
|
ROOT="$(git rev-parse --show-toplevel)"
|
||||||
|
|
||||||
|
# Resolve a release tag:
|
||||||
TAG="${1:-$(git tag --points-at HEAD | head -n1)}"
|
TAG="${1:-$(git tag --points-at HEAD | head -n1)}"
|
||||||
[ -n "$TAG" ] || { echo "No tag (pass as arg, or run on a tagged commit)"; exit 1; }
|
if [ -z "$TAG" ]; then
|
||||||
|
VER="$(jq -r .version "$ROOT/httptoolkit-server/package.json")"
|
||||||
|
TAG="v${VER}-$(git rev-parse --short HEAD)"
|
||||||
|
fi
|
||||||
|
|
||||||
OUT_DIR="$(pwd)/out"
|
OUT_DIR="$(pwd)/out"
|
||||||
API="${GITEA_SERVER_URL}/api/v1/repos/${GITEA_REPOSITORY}/releases"
|
API="${GITEA_SERVER_URL}/api/v1/repos/${GITEA_REPOSITORY}/releases"
|
||||||
|
|
||||||
echo "==> Creating release $TAG"
|
echo "==> Creating release $TAG"
|
||||||
RESP=$(curl -s -X POST "$API" \
|
RESP=$(curl -s -X POST "$API" \
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
-H "Authorization: token ${PAT_GITEA}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"tag_name\": \"${TAG}\", \"name\": \"HTTP Toolkit ${TAG}\", \"body\": \"Self-hosted single-file build.\"}")
|
-d "{\"tag_name\": \"${TAG}\", \"name\": \"HTTP Toolkit ${TAG}\", \"body\": \"Self-hosted single-file build.\"}")
|
||||||
|
|
||||||
@@ -41,7 +47,7 @@ for f in "$OUT_DIR"/*; do
|
|||||||
name=$(basename "$f")
|
name=$(basename "$f")
|
||||||
echo "==> Uploading $name"
|
echo "==> Uploading $name"
|
||||||
curl -s -X POST "${API}/${RID}/assets?name=${name}" \
|
curl -s -X POST "${API}/${RID}/assets?name=${name}" \
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
-H "Authorization: token ${PAT_GITEA}" \
|
||||||
-H "Content-Type: application/octet-stream" \
|
-H "Content-Type: application/octet-stream" \
|
||||||
--data-binary "@${f}" > /dev/null
|
--data-binary "@${f}" > /dev/null
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -22,9 +22,8 @@ jobs:
|
|||||||
run: docker compose run --rm prod
|
run: docker compose run --rm prod
|
||||||
|
|
||||||
- name: Create Gitea release & upload assets
|
- name: Create Gitea release & upload assets
|
||||||
if: startsWith(gitea.ref, 'refs/tags/')
|
|
||||||
env:
|
env:
|
||||||
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
||||||
GITEA_REPOSITORY: ${{ gitea.repository }}
|
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||||
GITEA_TOKEN: ${{ secrets.PAT_GITEA }}
|
PAT_GITEA: ${{ secrets.PAT_GITEA }}
|
||||||
run: bash .build/prod/release.sh "${{ gitea.ref_name }}"
|
run: bash .build/prod/release.sh
|
||||||
|
|||||||
Reference in New Issue
Block a user