Split large archives #15
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Mirror SDK | |
on: | |
push: | |
tags: | |
- "v*.*" | |
jobs: | |
download: | |
strategy: | |
matrix: | |
artifact_name: | |
- ohos-sdk-windows_linux-public.tar.gz | |
- L2-SDK-MAC-M1-PUBLIC.tar.gz | |
- ohos-sdk-mac-public.tar.gz | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download OpenHarmony SDK | |
run: ./download_sdk.sh | |
shell: bash | |
env: | |
# Relies on this job only running on tags! | |
INPUT_VERSION_TAG: "${{ github.ref_name }}" | |
INPUT_FILENAME: ${{ matrix.artifact_name}} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.artifact_name}} | |
path: ${{ matrix.artifact_name}}* | |
compression-level: 0 | |
create_release: | |
permissions: write-all | |
runs-on: ubuntu-latest | |
needs: ["download"] | |
steps: | |
# `gh` will fail if we don't checkout. | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- run: mkdir artifacts | |
- uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
path: ./artifacts | |
# Files attached to GitHub releases have a size limit of 2GiB | |
- name: Split large files | |
env: | |
GH_TOKEN: ${{ github.token }} | |
working-directory: artifacts | |
# Note: will not work on macos, but we can run the release job on ubuntu only. | |
run: | | |
MAX_ARCHIVE_SIZE=2147483648 | |
for archive in ./*.tar.gz; do | |
archive_size=$(stat -c%s "${archive}") | |
if (( archive_size >= MAX_ARCHIVE_SIZE )); then | |
split -b 2GB "${archive}" "${archive}." | |
rm "${archive}" | |
fi | |
done | |
- name: Publish release | |
id: publish-release | |
env: | |
GH_TOKEN: ${{ github.token }} | |
working-directory: artifacts | |
run: | | |
artifacts=(./*) | |
gh release create ${{github.ref_name}} --notes "OpenHarmony SDK mirror release for ${{github.ref_name}}" "${artifacts[@]}" |