name: Update version.json from Release on: release: types: [published, edited] workflow_dispatch: inputs: source_tag: description: "Existing version tag whose assets and metadata should be uploaded to the server." required: true type: string permissions: contents: read jobs: update-version-json: name: Upload release downloads and update version.json if: github.event_name == 'workflow_dispatch' || (github.event.release.tag_name != 'latest' && !github.event.release.prerelease) runs-on: ubuntu-24.04 concurrency: group: publish-release-metadata cancel-in-progress: false env: GH_TOKEN: ${{ github.token }} RELEASE_TAG: ${{ inputs.source_tag || github.event.release.tag_name }} steps: - name: Checkout publishing scripts uses: actions/checkout@v5 with: ref: ${{ github.event.repository.default_branch }} - name: Download release information and assets shell: bash run: | python3 - <<'PY' import os import re if not re.fullmatch(r'(?:ios-|android-)?v[0-9]+(?:\.[0-9]+){1,3}(?:-[0-9]+)*', os.environ['RELEASE_TAG']): raise ValueError('Use a desktop, iOS or Android version tag') PY gh release view "${RELEASE_TAG}" --repo "${GITHUB_REPOSITORY}" \ --json tagName,name,body,publishedAt,isDraft,isPrerelease > release.json python3 - <<'PY' import json from pathlib import Path release = json.loads(Path('release.json').read_text()) if release['isDraft'] or release['isPrerelease']: raise ValueError('Only published stable releases update version.json') PY gh release download "${RELEASE_TAG}" --repo "${GITHUB_REPOSITORY}" \ --pattern 'crossdesk-*' --dir release - name: Upload release assets to download server uses: burnett01/rsync-deployments@5.2 with: switches: -avzr --progress path: release/* remote_path: /var/www/html/downloads/ remote_host: ${{ secrets.SERVER_HOST }} remote_user: ${{ secrets.SERVER_USER }} remote_key: ${{ secrets.SERVER_KEY }} - name: Download current version.json shell: bash run: | curl --fail --silent --show-error --retry 3 --max-time 30 \ -H 'Cache-Control: no-cache' \ https://version.crossdesk.cn/version.json -o current-version.json - name: Merge release version and download URLs shell: bash run: | python3 .github/scripts/update_version_manifest.py \ --current current-version.json --output version.json --artifacts release \ --release-json release.json - name: Upload version.json to server uses: burnett01/rsync-deployments@5.2 with: switches: -avzr path: version.json remote_path: /var/www/html/version/ remote_host: ${{ secrets.SERVER_HOST }} remote_user: ${{ secrets.SERVER_USER }} remote_key: ${{ secrets.SERVER_KEY }}