name: PLONDS Publisher concurrency: group: plonds-publish-${{ github.event_name }}-${{ github.event.workflow_run.id || github.event.inputs.tag || github.run_id }} cancel-in-progress: false on: workflow_run: workflows: - PLONDS Comparator types: - completed workflow_dispatch: inputs: tag: description: 'Release tag' required: true type: string env: DOTNET_VERSION: '10.0.x' PLONDS_S3_PREFIX: lanmountain/update/plonds PLONDS_S3_PUBLIC_BASE_KEY_PREFIX: lanmountain/update PLONDS_S3_DIRECTORY_UPLOAD_CONCURRENCY: '4' PLONDS_S3_MULTIPART_THRESHOLD_MB: '10' PLONDS_S3_MULTIPART_PART_SIZE_MB: '10' PLONDS_S3_MULTIPART_CONCURRENCY: '4' jobs: publish: if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} runs-on: ubuntu-latest timeout-minutes: 45 permissions: contents: write actions: read steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 submodules: recursive - name: Resolve release tag env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} shell: bash run: | set -euo pipefail if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then RAW_TAG="${{ github.event.inputs.tag }}" if [[ "$RAW_TAG" == v* ]]; then TAG="$RAW_TAG" else TAG="v$RAW_TAG" fi else gh run download "${{ github.event.workflow_run.id }}" -n plonds-run-metadata -D plonds-run-metadata TAG="$(tr -d '\r\n' < plonds-run-metadata/tag.txt)" fi gh release view "$TAG" --repo "${{ github.repository }}" --json tagName >/dev/null echo "RELEASE_TAG=${TAG}" >> "$GITHUB_ENV" - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: ${{ env.DOTNET_VERSION }} dotnet-quality: preview - name: Build PLONDS tool run: dotnet build PenguinLogisticsOnlineNetworkDistributionSystem/src/Plonds.Tool/Plonds.Tool.csproj -c Release - name: Download PLONDS release assets env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} shell: bash run: | set -euo pipefail rm -rf plonds-assets mkdir -p plonds-assets gh release download "$RELEASE_TAG" -p changed.zip -p PLONDS.json -p files-windows-x64.zip -D plonds-assets --clobber test -f plonds-assets/changed.zip test -f plonds-assets/PLONDS.json test -f plonds-assets/files-windows-x64.zip jq -e . plonds-assets/PLONDS.json >/dev/null - name: Publish PLONDS assets to Rainyun S3 env: S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }} S3_ENDPOINT: ${{ vars.S3_ENDPOINT }} S3_REGION: ${{ vars.S3_REGION }} S3_BUCKET: ${{ vars.S3_BUCKET }} S3_PUBLIC_BASE_URL: ${{ vars.S3_PUBLIC_BASE_URL }} shell: bash run: | set -euo pipefail if [[ -z "${S3_ACCESS_KEY:-}" || -z "${S3_SECRET_KEY:-}" || -z "${S3_ENDPOINT:-}" || -z "${S3_BUCKET:-}" ]]; then echo "S3_ACCESS_KEY, S3_SECRET_KEY, S3_ENDPOINT, and S3_BUCKET must be configured." exit 1 fi REGION="${S3_REGION:-us-east-1}" PUBLIC_BASE="${S3_PUBLIC_BASE_URL:-https://cn-nb1.rains3.com/lmdesktop}" PUBLIC_BASE="${PUBLIC_BASE%/}" dotnet run --project PenguinLogisticsOnlineNetworkDistributionSystem/src/Plonds.Tool/Plonds.Tool.csproj --configuration Release -- \ publish-s3 \ --release-tag "$RELEASE_TAG" \ --repository "${{ github.repository }}" \ --manifest "$PWD/plonds-assets/PLONDS.json" \ --changed-zip "$PWD/plonds-assets/changed.zip" \ --files-zip "$PWD/plonds-assets/files-windows-x64.zip" \ --work-dir "$PWD/plonds-publish-work" \ --s3-prefix "$PLONDS_S3_PREFIX" \ --s3-endpoint "$S3_ENDPOINT" \ --s3-region "$REGION" \ --s3-bucket "$S3_BUCKET" \ --s3-access-key "$S3_ACCESS_KEY" \ --s3-secret-key "$S3_SECRET_KEY" \ --s3-public-base-url "$PUBLIC_BASE" \ --s3-public-base-key-prefix "$PLONDS_S3_PUBLIC_BASE_KEY_PREFIX" \ --directory-upload-concurrency "$PLONDS_S3_DIRECTORY_UPLOAD_CONCURRENCY" \ --multipart-threshold-mb "$PLONDS_S3_MULTIPART_THRESHOLD_MB" \ --multipart-part-size-mb "$PLONDS_S3_MULTIPART_PART_SIZE_MB" \ --multipart-concurrency "$PLONDS_S3_MULTIPART_CONCURRENCY" jq -e '.downloads.github.changedZipUrl and .downloads.github.filesZipUrl and .downloads.s3.changedFolderUrl and .downloads.s3.filesFolderUrl' plonds-assets/PLONDS.json >/dev/null - name: Upload enriched PLONDS manifest to GitHub Release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} shell: bash run: | set -euo pipefail gh release upload "$RELEASE_TAG" plonds-assets/PLONDS.json --clobber