commit 624a8a8bb96dd917f75b7506a024809686f38ec0 Author: Jeffery Date: Thu Sep 18 14:22:02 2025 +0800 first commit diff --git a/.gitea/workflows/master.yaml b/.gitea/workflows/master.yaml new file mode 100644 index 0000000..4a53e4b --- /dev/null +++ b/.gitea/workflows/master.yaml @@ -0,0 +1,28 @@ +on: + push: + branches: + - master +jobs: + cd: + name: "CD > 發布專案" + runs-on: docker + env: + RUNNER_TOOL_CACHE: /toolcache + steps: + - name: 計算版本號 + id: version + uses: https://gitea.jsc.idv.tw/jiantw83/calculate-version-action@v${{ vars.CALCULATE_VERSION }} + with: + gitea-server: ${{ gitea.server_url }} + repository: ${{ gitea.repository }} + token: ${{ secrets.GITEA_TOKEN }} + - name: 發布專案 + uses: akkuman/gitea-release-action@v1 + with: + tag_name: "v${{ steps.version.outputs.VERSION }}" + - name: 清理舊版本 (保留最新2個) + uses: https://gitea.jsc.idv.tw/jiantw83/cleanup-release-action@v${{ vars.CLEANUP_RELEASE_VERSION }} + with: + gitea-server: ${{ gitea.server_url }} + repository: ${{ gitea.repository }} + token: ${{ secrets.GITEA_TOKEN }} \ No newline at end of file diff --git a/action.yaml b/action.yaml new file mode 100644 index 0000000..19d3a13 --- /dev/null +++ b/action.yaml @@ -0,0 +1,38 @@ +name: 'NUGET PUSH' +description: '打包套件' +author: 'Jeffery' +inputs: + token: + default: '' + version: + required: true + source: + required: true + api_key: + required: true + index: + default: 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 \ No newline at end of file