Main Linux Workflow #281
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: Main Linux Workflow | |
on: | |
push: | |
branches: | |
- release* | |
tags: | |
- v* | |
pull_request: | |
types: [opened, synchronize, reopened, labeled] | |
branches: | |
- main | |
paths-ignore: | |
- "**/*.md" | |
schedule: | |
- cron: "0 0 * * *" # nightly build | |
workflow_dispatch: # manual trigger | |
jobs: | |
build-x86_64: | |
if: "github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'linux')" | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-20.04] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
fetch-depth: 0 | |
- name: Install | |
shell: bash | |
run: scripts/install.sh -m local-install | |
- name: Pack | |
shell: bash | |
run: scripts/pack.sh -o home-cli-x86_64.run | |
- name: Uninstall | |
shell: bash | |
run: scripts/uninstall.sh | |
- name: Unpack | |
shell: bash | |
run: bash ./home-cli-x86_64.run -- -m install --install-dir ${{ github.workspace }}/home-cli-x86_64 | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: home-cli-pack-x86_64 | |
path: home-cli-x86_64.run | |
build-arm64: | |
if: "github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'linux')" | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-20.04] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
fetch-depth: 0 | |
- uses: uraimo/run-on-arch-action@v2 | |
name: Run commands | |
with: | |
arch: aarch64 | |
distro: ubuntu20.04 | |
# Mount the artifacts directory as /artifacts in the container | |
dockerRunArgs: | | |
--volume "${PWD}:/workspace" | |
env: | | |
HOMECLI_PRINT_PROGRESS: false | |
install: | | |
apt update -y | |
apt install -y python3 python3-pip curl libfuse-dev git | |
# Set an output parameter `uname` for use in subsequent steps | |
run: | | |
uname -a | |
cd /workspace | |
scripts/install.sh -m local-install | |
scripts/pack.sh -o home-cli-arm64.run | |
scripts/uninstall.sh | |
bash home-cli-arm64.run -- -m install --install-dir /workspace/home-cli-arm64 | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: home-cli-pack-arm64 | |
path: home-cli-arm64.run | |
pre-release: | |
runs-on: ubuntu-20.04 | |
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' | |
needs: | |
- build-x86_64 | |
- build-arm64 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Ensure we have access to all commit history | |
- name: Set up Git | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Fetch all tags and branches | |
run: | | |
git fetch --all | |
- name: Check if nightly tag is on the latest main commit | |
id: check_nightly | |
run: | | |
# Get the latest commit hash on the main branch | |
MAIN_LATEST=$(git rev-parse origin/main) | |
# Get the commit hash of the nightly tag, if it exists | |
if git rev-parse nightly >/dev/null 2>&1; then | |
NIGHTLY_COMMIT=$(git rev-parse nightly) | |
else | |
NIGHTLY_COMMIT="" | |
fi | |
# Compare the hashes | |
if [ "$MAIN_LATEST" = "$NIGHTLY_COMMIT" ]; then | |
echo "Nightly tag is already up-to-date with the latest main commit." | |
echo "::set-output name=should_run::false" | |
else | |
echo "Nightly tag is not up-to-date with the latest main commit." | |
echo "::set-output name=should_run::true" | |
fi | |
- name: Delete Legacy Pre-Release | |
if: steps.check_nightly.outputs.should_run == 'true' | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const { data: releases } = await github.repos.listReleases({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
}); | |
for (const release of releases) { | |
if (release.prerelease) { | |
await github.repos.deleteRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: release.id, | |
}); | |
} | |
} | |
- name: Delete old nightly tag | |
if: steps.check_nightly.outputs.should_run == 'true' | |
run: | | |
if git rev-parse nightly >/dev/null 2>&1; then | |
git tag -d nightly | |
git push origin :refs/tags/nightly | |
else | |
echo "No existing nightly tag found" | |
fi | |
- name: Create new nightly tag | |
if: steps.check_nightly.outputs.should_run == 'true' | |
run: | | |
git tag nightly | |
git push origin nightly | |
- name: Create Pre-Release | |
if: steps.check_nightly.outputs.should_run == 'true' | |
id: create_pre_release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: nightly | |
release_name: Pre-Release | |
draft: false | |
prerelease: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/download-artifact@v3 | |
if: steps.check_nightly.outputs.should_run == 'true' | |
with: | |
name: home-cli-pack-x86_64 | |
- uses: actions/download-artifact@v3 | |
if: steps.check_nightly.outputs.should_run == 'true' | |
with: | |
name: home-cli-pack-arm64 | |
- name: Upload Pre-Release Assets x86_64 | |
if: steps.check_nightly.outputs.should_run == 'true' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_pre_release.outputs.upload_url }} | |
asset_path: ./home-cli-x86_64.run | |
asset_name: home-cli-x86_64.run | |
asset_content_type: application/octet-stream | |
- name: Upload Pre-Release Assets arm64 | |
if: steps.check_nightly.outputs.should_run == 'true' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_pre_release.outputs.upload_url }} | |
asset_path: ./home-cli-arm64.run | |
asset_name: home-cli-arm64.run | |
asset_content_type: application/octet-stream | |
release: | |
runs-on: ubuntu-20.04 | |
needs: | |
- build-x86_64 | |
- build-arm64 | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/download-artifact@v3 | |
with: | |
name: home-cli-pack-x86_64 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: home-cli-pack-arm64 | |
- name: Upload Assets x86_64 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./home-cli-x86_64.run | |
asset_name: home-cli-x86_64.run | |
asset_content_type: application/octet-stream | |
- name: Upload Assets arm64 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./home-cli-arm64.run | |
asset_name: home-cli-arm64.run | |
asset_content_type: application/octet-stream | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.x" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install huggingface_hub | |
- name: Authenticate with Hugging Face | |
env: | |
HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
run: | | |
huggingface-cli login --token $HF_TOKEN --add-to-git-credential | |
- name: Upload file to Hugging Face | |
run: | | |
huggingface-cli upload BrightXiaoHan/HOME home-cli-x86_64.run home-cli-x86_64.run | |
huggingface-cli upload BrightXiaoHan/HOME home-cli-arm64.run home-cli-arm64.run | |
env: | |
HF_TOKEN: ${{ secrets.HF_TOKEN }} |