Skip to content

Nightly

Nightly #1397

Workflow file for this run

name: Nightly
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
inputs:
release_version:
description: 'Tag to use for the build. Example: v1.0.0. *Null = master'
required: false
default: ''
latest:
description: 'Tag as latest ?'
type: boolean
required: false
default: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: eu-central-1
AWS_BUCKET: gear-builds
jobs:
build:
name: Build binaries
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
docker: amazonlinux:2023
file_ext: tar.xz
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
file_ext: tar.xz
- target: x86_64-apple-darwin
os: macOS-latest
file_ext: tar.xz
- target: aarch64-apple-darwin
os: macOS-latest
file_ext: tar.xz
- target: x86_64-pc-windows-msvc
os: windows-latest
file_ext: zip
runs-on: ${{ matrix.os }}
container: ${{ matrix.docker }}
continue-on-error: true
steps:
- name: Set artifact name
run: echo "ARTIFACT_NAME=gear-${{ github.event.inputs.release_version || 'nightly' }}-${{ matrix.target }}.${{ matrix.file_ext }}" >> $GITHUB_ENV
- name: Configure Amazon Linux
if: matrix.docker == 'amazonlinux:2023'
run: |
yum update -y && yum install -y clang gcc git gzip make tar unzip wget xz
wget https://cmake.org/files/v3.24/cmake-3.24.0-linux-x86_64.sh
chmod +x cmake-3.24.0-linux-x86_64.sh
./cmake-3.24.0-linux-x86_64.sh --skip-license --prefix=/usr/local
rm cmake-3.24.0-linux-x86_64.sh
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.20.2/protoc-3.20.2-linux-x86_64.zip
unzip protoc-3.20.2-linux-x86_64.zip -d /usr/local
rm protoc-3.20.2-linux-x86_64.zip
wget https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip
unzip awscli-exe-linux-x86_64.zip
./aws/install
- name: Checkout `gear-tech/gear`
uses: actions/checkout@v3
with:
repository: gear-tech/gear
ref: ${{ github.event.inputs.release_version || 'master' }}
- name: Checkout `gear-tech/builds`
uses: actions/checkout@v3
with:
path: builds
- name: Setup toolchain on Linux
if: matrix.os == 'ubuntu-latest'
uses: dtolnay/rust-toolchain@stable
- name: Add macOS x86 target
if: matrix.target == 'x86_64-apple-darwin'
run: sed -i '' 's/"wasm32-unknown-unknown"/"x86_64-apple-darwin", "wasm32-unknown-unknown"/g' rust-toolchain.toml
- name: Add macOS ARM target
if: matrix.target == 'aarch64-apple-darwin'
run: sed -i '' 's/"wasm32-unknown-unknown"/"aarch64-apple-darwin", "wasm32-unknown-unknown"/g' rust-toolchain.toml
- name: List toolchains and targets
run: |
rustup toolchain list
rustup target list --installed
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Fix for `git rev-parse`
if: matrix.os == 'ubuntu-latest'
run: git config --global --add safe.directory `pwd`
- name: Build
if: matrix.target != 'aarch64-unknown-linux-musl'
run: cargo build -p gear-cli -F cli --profile production --target ${{ matrix.target }}
- name: Install cross
if: matrix.target == 'aarch64-unknown-linux-musl'
uses: taiki-e/install-action@cross
- name: Build for Linux on ARM
if: matrix.target == 'aarch64-unknown-linux-musl'
run: |
cp builds/gear.diff ./
git apply gear.diff
cross build -p gear-cli -F cli --profile production --target ${{ matrix.target }}
- name: Linux artifacts
if: matrix.os == 'ubuntu-latest'
run: |
cd target/${{ matrix.target }}/production
XZ_OPT=-9 tar -cvJf ../../../${{ env.ARTIFACT_NAME }} gear
- name: macOS artifacts
if: matrix.os == 'macos-latest'
run: |
cd target/${{ matrix.target }}/production
tar -cvJf ../../../${{ env.ARTIFACT_NAME }} gear
- name: Windows artifacts
if: matrix.os == 'windows-latest'
env:
ARTIFACT_NAME: gear-${{ github.event.inputs.release_version || 'nightly' }}-${{ matrix.target }}.${{ matrix.file_ext }}
run: |
cd target/${{ matrix.target }}/production
7z a "..\..\..\${{ env.ARTIFACT_NAME }}" gear.exe
- name: Upload artifacts
uses: actions/upload-artifact@v3
env:
ARTIFACT_NAME: gear-${{ github.event.inputs.release_version || 'nightly' }}-${{ matrix.target }}.${{ matrix.file_ext }}
with:
if-no-files-found: ignore
path: ${{ env.ARTIFACT_NAME }}
- name: Update latest symlink for release artifacts (Linux/macOS)
if: >
github.event.inputs.release_version != '' &&
github.event.inputs.latest == 'true' &&
runner.os != 'Windows'
run: |
latest_artifact=$(aws s3api list-objects --bucket ${{ env.AWS_BUCKET }} --query "reverse(sort_by(Contents, &LastModified))[?contains(Key, 'gear-${{ github.event.inputs.release_version }}-${{ matrix.target }}')].[Key]" --output text)
aws s3api put-object --bucket ${{ env.AWS_BUCKET }} --key gear-latest-${{ matrix.target }}.${{ matrix.file_ext }} --website-redirect-location /$latest_artifact
- name: Update latest symlink for release artifacts (Windows)
if: >
github.event.inputs.release_version != '' &&
github.event.inputs.latest == 'true' &&
runner.os == 'Windows'
run: |
$latest_artifact = aws s3api list-objects --bucket ${{ env.AWS_BUCKET }} --query "reverse(sort_by(Contents, &LastModified))[?contains(Key, 'gear-${{ github.event.inputs.release_version }}-${{ matrix.target }}')].[Key]" --output text
aws s3api put-object --bucket ${{ env.AWS_BUCKET }} --key "gear-latest-${{ matrix.target }}.${{ matrix.file_ext }}" --website-redirect-location "/$latest_artifact"
shell: pwsh
publish:
name: Publish artifacts
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout `gear-tech/builds`
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
- name: List artifacts
run: ls -la artifact/
- name: AWS login
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Delete old nightly artifacts
if: github.event.inputs.release_version == ''
run: |
aws s3 rm s3://${{ env.AWS_BUCKET }}/ --recursive --exclude "*" --include "gear-nightly*"
- name: Publish artifacts
run: |
aws s3 sync ./artifact/ s3://${{ env.AWS_BUCKET }}/ --exclude "*" --include "gear-*"
- name: Generate index page
run: |
echo "<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<title>Gear Builds</title>
<link rel="stylesheet" href="static/styles.css">
<link rel="icon" href="static/favicon.ico">
</head>
<body>
<div class='container'>
<div class='header'>
<h1>Gear Builds</h1>
</div>
<div class='builds'>
<h3 id='gear-nightly'>Nightly Builds<a href='#gear-nightly'></a></h3>
<ul>" > src/index.html
artifacts=$(aws s3api list-objects --bucket ${{ env.AWS_BUCKET }} --region ${{ env.AWS_REGION }} --query 'reverse(sort_by(Contents, &LastModified))[].Key' | jq -r '.[]' | grep gear-n)
for artifact in $artifacts; do
filename=$(basename "$artifact")
filesize_bytes=$(aws s3api head-object --bucket ${{ env.AWS_BUCKET }} --key "$artifact" --region ${{ env.AWS_REGION }} --query 'ContentLength' --output text)
filesize_mb=$(echo "$filesize_bytes / 1024 / 1024" | bc -l | xargs printf "%.2f")
last_modified=$(aws s3api head-object --bucket ${{ env.AWS_BUCKET }} --key "$artifact" --region ${{ env.AWS_REGION }} --query 'LastModified' --output text | xargs -I {} date -u -d {} "+%d.%m.%Y %H:%M:%S UTC")
echo " <li><a href='https://${{ env.AWS_BUCKET }}.s3.amazonaws.com/$filename'>$filename</a> ($filesize_mb MB, $last_modified)</li>"
done >> src/index.html
echo " </ul>
</div>" >> src/index.html
release_versions=$(aws s3api list-objects --bucket ${{ env.AWS_BUCKET }} --region ${{ env.AWS_REGION }} --query 'Contents[].Key' | jq -r '.[]' | grep 'gear-v' | sed -E 's/gear-v([0-9.]+)-.*/\1/' | sort -ur)
for version in $release_versions; do
echo " <div class='builds'>
<h3 id='gear-v$version'>Release Builds - <a href='#gear-v$version'>v$version</a></h3>
<ul>"
artifacts=$(aws s3api list-objects --bucket ${{ env.AWS_BUCKET }} --region ${{ env.AWS_REGION }} --query 'reverse(sort_by(Contents, &LastModified))[].Key' | jq -r '.[]' | grep "gear-v$version")
for artifact in $artifacts; do
filename=$(basename "$artifact")
filesize_bytes=$(aws s3api head-object --bucket ${{ env.AWS_BUCKET }} --key "$artifact" --region ${{ env.AWS_REGION }} --query 'ContentLength' --output text)
filesize_mb=$(echo "$filesize_bytes / 1024 / 1024" | bc -l | xargs printf "%.2f")
last_modified=$(aws s3api head-object --bucket ${{ env.AWS_BUCKET }} --key "$artifact" --region ${{ env.AWS_REGION }} --query 'LastModified' --output text | xargs -I {} date -u -d {} "+%d.%m.%Y %H:%M:%S UTC")
echo " <li><a href='https://${{ env.AWS_BUCKET }}.s3.amazonaws.com/$filename'>$filename</a> ($filesize_mb MB, $last_modified)</li>"
done >> src/index.html
echo " </ul>
</div>"
done >> src/index.html
echo " </div>
<div class='footer'>
&copy; 2024 Gear Technologies, Inc. All Rights Reserved.
</div>
</body>
</html>" >> src/index.html
- name: Publish index page
run: |
aws s3 sync ./src/ s3://${{ env.AWS_BUCKET }}/