feat: 重構 nuget push 工具

This commit is contained in:
Jeffery
2026-03-20 15:21:40 +08:00
parent 7405c7ea2d
commit 81cedc70d9
3 changed files with 99 additions and 32 deletions

View File

@@ -1,38 +1,20 @@
name: 'NUGET PUSH'
description: '打包套件'
description: '推送 NUGET 套件'
author: 'Jeffery'
inputs:
token:
default: ''
version:
RELEASE_VERSION:
required: true
source:
required: true
api_key:
required: true
index:
description: '要推送的版本號ex: ${{ needs.calculate.outputs.version }}'
RELEASE_INDEX:
default: 0
description: '要推送的版本中第幾個成品,預設為 0'
runs:
using: "composite"
steps:
- run: |
HEADER="Authorization: token ${{ inputs.token }}"
SOURCE="${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases/tags/v${{ inputs.version }}"
echo "HEADER: $HEADER"
echo "SOURCE: $SOURCE"
RELEASE_JSON="$(curl -s -H "$HEADER" "$SOURCE")"
DOWNLOAD_NAME="$(echo "$RELEASE_JSON" | jq -r ".assets[${{ inputs.index }}].name")"
DOWNLOAD_URL="$(echo "$RELEASE_JSON" | jq -r ".assets[${{ inputs.index }}].browser_download_url")"
echo "DOWNLOAD_NAME: $DOWNLOAD_NAME"
echo "DOWNLOAD_URL: $DOWNLOAD_URL"
echo "ARTIFACT DOWNLOADING..."
curl -s -H "$HEADER" "$DOWNLOAD_URL" -o "$DOWNLOAD_NAME"
echo "ARTIFACT UNZIPPING..."
unzip "$DOWNLOAD_NAME" -d output
echo "ARTIFACT PUSHING..."
dotnet nuget push "output/*.nupkg" --source "${{ inputs.source }}" --api-key "${{ inputs.api_key }}" --skip-duplicate --allow-insecure-connections
using: 'docker'
image: 'Dockerfile'
env:
GITEA_SERVER_URL: ${{ gitea.server_url }}
GITEA_REPOSITORY: ${{ gitea.repository }}
RELEASE_VERSION: ${{ inputs.RELEASE_VERSION }}
RELEASE_INDEX: ${{ inputs.RELEASE_INDEX }}
RUNNER_TOKEN: ${{ secrets.RUNNER_TOKEN }}
NUGET_AUTHOR: ${{ gitea.author }}