Publish releases with a curl script; the Go-based action cannot run on this runner
This commit is contained in:
@@ -72,7 +72,6 @@ jobs:
|
||||
cp src-tauri/target/x86_64-pc-windows-msvc/release/gites.exe "release/gites_${GITHUB_REF_NAME#v}_x64_portable.exe"
|
||||
ls -la release
|
||||
- name: Publish release
|
||||
uses: https://gitea.com/actions/release-action@main
|
||||
with:
|
||||
files: release/*
|
||||
api_key: "${{ secrets.GITHUB_TOKEN }}"
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: scripts/publish-release.sh release/*
|
||||
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
# Creates the Gitea release for the current tag (or reuses it) and uploads every file
|
||||
# given as an argument, replacing files of the same name from an earlier run.
|
||||
# Needs GITEA_TOKEN plus the GITHUB_* variables every Actions job gets.
|
||||
set -euo pipefail
|
||||
|
||||
api="$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY"
|
||||
tag="$GITHUB_REF_NAME"
|
||||
auth=(-H "Authorization: token $GITEA_TOKEN")
|
||||
json() { node -e "let s='';process.stdin.on('data',d=>s+=d).on('end',()=>{const v=JSON.parse(s);console.log($1)})"; }
|
||||
|
||||
if release=$(curl -sf "${auth[@]}" "$api/releases/tags/$tag"); then
|
||||
echo "Using the existing release for $tag"
|
||||
else
|
||||
echo "Creating the release for $tag"
|
||||
release=$(curl -sf "${auth[@]}" -H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\": \"$tag\", \"name\": \"$tag\"}" "$api/releases")
|
||||
fi
|
||||
id=$(echo "$release" | json 'v.id')
|
||||
|
||||
for file in "$@"; do
|
||||
name=$(basename "$file")
|
||||
old=$(echo "$release" | NAME="$name" json "(v.assets||[]).filter(a=>a.name===process.env.NAME).map(a=>a.id).join(' ')")
|
||||
for asset in $old; do
|
||||
curl -sf "${auth[@]}" -X DELETE "$api/releases/$id/assets/$asset"
|
||||
done
|
||||
echo "Uploading $name"
|
||||
curl -sf "${auth[@]}" -F "attachment=@$file" "$api/releases/$id/assets?name=$name" >/dev/null
|
||||
done
|
||||
Reference in New Issue
Block a user