mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-04 04:17:44 +00:00
109 lines
3.7 KiB
YAML
109 lines
3.7 KiB
YAML
name: Build
|
||
|
||
on:
|
||
workflow_dispatch:
|
||
schedule:
|
||
- cron: '0 0 * * 0' # at midnight of each sunday
|
||
push:
|
||
branches:
|
||
- main
|
||
|
||
jobs:
|
||
build-rustfs:
|
||
runs-on: ubuntu-latest
|
||
|
||
strategy:
|
||
matrix:
|
||
variant:
|
||
- { profile: dev, target: x86_64-unknown-linux-gnu, glibc: "default" }
|
||
- { profile: release, target: x86_64-unknown-linux-gnu, glibc: "default" }
|
||
- { profile: release, target: x86_64-unknown-linux-gnu, glibc: "2.31" }
|
||
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
- uses: ./.github/actions/setup
|
||
with:
|
||
cache-shared-key: rustfs.${{ matrix.variant.profile }}.${{ matrix.variant.target }}.${{ matrix.variant.glibc }}
|
||
|
||
- name: Build
|
||
run: |
|
||
./scripts/build.py \
|
||
--profile ${{ matrix.variant.profile }} \
|
||
--target ${{ matrix.variant.target }} \
|
||
--glibc ${{ matrix.variant.glibc }}
|
||
|
||
# Download the zip file(Linux/macOS used bash)
|
||
- name: Download Static Assets (Linux/macOS)
|
||
run: |
|
||
url="https://dl.rustfs.com/console/rustfs-console-latest.zip"
|
||
file=$(basename "$url")
|
||
curl -L -o "$file" "$url"
|
||
if [ ! -f "$file" ]; then
|
||
echo "Error: Failed to download $file"
|
||
exit 1
|
||
fi
|
||
echo "Downloaded $file successfully"
|
||
ls -l "$file"
|
||
ls -la
|
||
|
||
# Unzip the zip file(Linux/macOS used bash)
|
||
- name: Extract Static Assets (Linux/macOS)
|
||
run: |
|
||
ls -la
|
||
# Find the first .zip or .tar.gz file
|
||
file=""
|
||
for f in *.zip *.tar.gz; do
|
||
if [ -f "$f" ]; then
|
||
file="$f"
|
||
break
|
||
fi
|
||
done
|
||
if [ -z "$file" ]; then
|
||
echo "Error: No .zip or .tar.gz file found in the current directory"
|
||
ls -la # Displays the contents of the current directory for debugging
|
||
exit 1
|
||
fi
|
||
# Outputs the name of the file found
|
||
echo "Found file: $file"
|
||
mkdir -p static
|
||
if [[ "$file" == *.zip ]]; then
|
||
echo "Unzipping $file to static/"
|
||
unzip "$file" -d static || { echo "Error: Failed to unzip $file"; exit 1; }
|
||
elif [[ "$file" == *.tar.gz ]]; then
|
||
echo "Extracting $file to static/"
|
||
tar -xzf "$file" -C static || { echo "Error: Failed to extract $file"; exit 1; }
|
||
else
|
||
echo "Error: Unsupported file format: $file"
|
||
exit 1
|
||
fi
|
||
# Check whether the decompression is successful
|
||
if [ $? -ne 0 ]; then
|
||
echo "Error: Failed to extract $file"
|
||
exit 2
|
||
fi
|
||
rm "$file"
|
||
ls -la static
|
||
# Packing binaries and static directory(Linux/macOS used bash)
|
||
- name: Package Binary and Static Assets (Linux/macOS)
|
||
run: |
|
||
ls -la target/artifacts
|
||
mkdir -p release-package
|
||
cp target/artifacts/rustfs.${{ matrix.variant.profile }}.${{ matrix.variant.target }}.${{ matrix.variant.glibc }} release-package/
|
||
cp -r static release-package/
|
||
zip -r rustfs${{ matrix.variant.profile }}-${{ matrix.variant.target }}-${{ matrix.variant.glibc }}.zip release-package/*
|
||
ls -la
|
||
|
||
- uses: actions/upload-artifact@v4
|
||
with:
|
||
name: rustfs.${{ matrix.variant.profile }}.${{ matrix.variant.target }}.${{ matrix.variant.glibc }}
|
||
path: ./release-package/rustfs.${{ matrix.variant.profile }}.${{ matrix.variant.target }}.${{ matrix.variant.glibc }}.zip
|
||
|
||
merge:
|
||
runs-on: ubuntu-latest
|
||
needs: build-rustfs
|
||
steps:
|
||
- uses: actions/upload-artifact/merge@v4
|
||
with:
|
||
name: rustfs
|
||
delete-merged: true
|