ci: use package secret for upload
Some checks failed
Cross Build Windows Release on Linux / cross-build-windows (push) Failing after 5m30s
Some checks failed
Cross Build Windows Release on Linux / cross-build-windows (push) Failing after 5m30s
This commit is contained in:
@@ -130,6 +130,8 @@ jobs:
|
||||
7z l dist-windows-cross/chengnan-windows-x86_64-cross.zip | grep 'platforms/'
|
||||
|
||||
- name: Upload package to Gitea Packages
|
||||
env:
|
||||
PACKAGE_TOKEN: ${{ secrets.PACKAGE_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
PACKAGE_NAME="chengnan-windows-x86_64-cross"
|
||||
@@ -137,14 +139,24 @@ jobs:
|
||||
VERSION="${VERSION:0:10}"
|
||||
OWNER="${GITHUB_REPOSITORY%%/*}"
|
||||
API_BASE="${GITHUB_SERVER_URL:-https://git.luochen570.cn}/api/packages/${OWNER}/generic/chengnan/${VERSION}"
|
||||
TOKEN="${GITEA_TOKEN:-${GITHUB_TOKEN:-}}"
|
||||
TOKEN="${PACKAGE_TOKEN:-${GITHUB_TOKEN:-}}"
|
||||
test -n "$TOKEN"
|
||||
curl --fail --show-error --silent --location \
|
||||
--header "Authorization: token ${TOKEN}" \
|
||||
--upload-file "dist-windows-cross/${PACKAGE_NAME}.zip" \
|
||||
"${API_BASE}/${PACKAGE_NAME}.zip"
|
||||
curl --fail --show-error --silent --location \
|
||||
--header "Authorization: token ${TOKEN}" \
|
||||
--upload-file "dist-windows-cross/${PACKAGE_NAME}.zip.sha256" \
|
||||
"${API_BASE}/${PACKAGE_NAME}.zip.sha256"
|
||||
upload_file() {
|
||||
local src="$1"
|
||||
local url="$2"
|
||||
local status
|
||||
status="$(curl --show-error --silent --location \
|
||||
--header "Authorization: token ${TOKEN}" \
|
||||
--upload-file "$src" \
|
||||
--write-out '%{http_code}' \
|
||||
--output /tmp/gitea-upload-response.txt \
|
||||
"$url")"
|
||||
if [ "$status" != "201" ] && [ "$status" != "200" ]; then
|
||||
echo "Upload failed with HTTP ${status}: ${url}" >&2
|
||||
cat /tmp/gitea-upload-response.txt >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
upload_file "dist-windows-cross/${PACKAGE_NAME}.zip" "${API_BASE}/${PACKAGE_NAME}.zip"
|
||||
upload_file "dist-windows-cross/${PACKAGE_NAME}.zip.sha256" "${API_BASE}/${PACKAGE_NAME}.zip.sha256"
|
||||
echo "Package uploaded to: ${API_BASE}/"
|
||||
|
||||
Reference in New Issue
Block a user