ruffle/.github/workflows/release_nightly.yml

401 lines
14 KiB
YAML
Raw Normal View History

name: Release Nightly
on:
# Run nightly
schedule:
2021-09-09 03:19:15 +00:00
- cron: "0 0 * * *"
# Allow for manual dispatch on GitHub
workflow_dispatch:
jobs:
create-nightly-release:
2021-02-01 03:07:36 +00:00
name: Create Nightly Release
runs-on: ubuntu-latest
outputs:
activity_check: ${{ env.GHA_REPO_ALIVE }}
2021-02-01 03:07:36 +00:00
date: ${{ steps.current_time_underscores.outputs.formattedTime }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
2021-04-24 02:28:35 +00:00
package_prefix: ruffle-nightly-${{ steps.current_time_underscores.outputs.formattedTime }}
steps:
- name: Activity check
run: |
:
# Based off https://github.community/t/trigger-workflow-if-there-is-commit-in-last-24-hours/17074/3
curl -sL https://api.github.com/repos/$GITHUB_REPOSITORY/commits | jq -r '[.[]][0]' > $HOME/commit.json
date="$(jq -r '.commit.committer.date' $HOME/commit.json)"
timestamp=$(date --utc -d "$date" +%s)
2021-02-01 03:07:36 +00:00
days=$(( ( $(date --utc +%s) - $timestamp ) / 86400 ))
author="$(jq -r '.commit.committer.name' $HOME/commit.json)"
url="$(jq -r '.html_url' $HOME/commit.json)"
rm -f $HOME/commit.json
2021-02-01 03:07:36 +00:00
echo "Repository activity: $timestamp $author $url"
alive=0
if [ "${{ github.event_name }}" == "repository_dispatch" ] || [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
2021-02-01 03:07:36 +00:00
echo "[WARNING] Ignoring activity check: workflow triggered manually."
alive=1
elif [[ $days < 1 ]]; then
echo Repository active
alive=1
else
2021-02-01 03:07:36 +00:00
echo "[WARNING] Repository not updated: event ${{ github.event_name }} not allowed to modify stale repository."
fi
2021-02-01 03:07:36 +00:00
if [[ $alive == 1 ]]; then
echo "GHA_REPO_ALIVE=true" >> $GITHUB_ENV
fi
shell: bash
2021-02-01 03:07:36 +00:00
- name: Get current time with dashes
uses: 1466587594/get-current-time@v2
id: current_time_dashes
with:
format: YYYY-MM-DD
- name: Get current time with underscores
uses: 1466587594/get-current-time@v2
id: current_time_underscores
with:
format: YYYY_MM_DD
- name: Create release
if: env.GHA_REPO_ALIVE == 'true'
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: nightly-${{ steps.current_time_dashes.outputs.formattedTime }}
release_name: Nightly ${{ steps.current_time_dashes.outputs.formattedTime }}
prerelease: true
2021-02-01 03:07:36 +00:00
build:
2021-04-24 02:28:35 +00:00
name: Build ${{ matrix.build_name }}
needs: create-nightly-release
if: needs.create-nightly-release.outputs.activity_check == 'true'
strategy:
fail-fast: false
matrix:
2021-04-24 02:28:35 +00:00
include:
- build_name: linux-x86_64
os: ubuntu-latest
# Mac does two Rust builds to make a universal binary
- build_name: macos-x86_64
os: macos-latest
target: x86_64-apple-darwin
- build_name: macos-aarch64
os: macos-latest
target: aarch64-apple-darwin
- build_name: windows-x86_32
os: windows-latest
target: i686-pc-windows-msvc
RUSTFLAGS: -Ctarget-feature=+crt-static
- build_name: windows-x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
RUSTFLAGS: -Ctarget-feature=+crt-static
env:
PACKAGE_FILE: ${{ needs.create-nightly-release.outputs.package_prefix }}-${{ matrix.build_name }}.${{ startsWith(matrix.build_name, 'win') && 'zip' || 'tar.gz' }}
CARGO_BUILD_DIR: target/${{ matrix.target }}/release
runs-on: ${{ matrix.os }}
steps:
2021-04-24 02:28:35 +00:00
- name: Clone Ruffle repo
uses: actions/checkout@v2
2021-02-01 03:07:36 +00:00
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
2021-04-24 02:28:35 +00:00
target: ${{ matrix.target }}
2021-02-01 03:07:36 +00:00
- name: Install Linux dependencies
2021-04-24 02:28:35 +00:00
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt install -y libasound2-dev libxcb-shape0-dev libxcb-xfixes0-dev
2021-02-01 03:07:36 +00:00
2021-04-24 02:28:35 +00:00
# We need macOS SDK 11.0 to build for aarch64.
# GitHub Actions runners have the 11.0 SDK installed, but are still stuck on macOS 10.15.
# Various efforts of changing SDKPATH, CFLAGS, etc. to use the proper SDK have not compiled or linked correctly.
# This hack deletes all other SDKs which forces the build tools to use the proper version.
# Remove this hack when macOS 11 is publicly available on GitHub Actions.
# From https://github.com/actions/virtual-environments/issues/2211
- name: Set SDK for macOS aarch64
if: matrix.target == 'aarch64-apple-darwin'
run: |
sudo xcode-select -s "/Applications/Xcode_12.4.app"
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*
- name: Cargo build
uses: actions-rs/cargo@v1
with:
command: build
args: --package ruffle_desktop --release ${{ matrix.target && '--target' }} ${{ matrix.target }}
env:
RUSTFLAGS: ${{ matrix.RUSTFLAGS }}
- name: Package common
run: |
mkdir package
cp README.md package/README.md
cp LICENSE.md package/LICENSE.md
- name: Package Windows
if: runner.os == 'Windows'
run: |
cp ${{ env.CARGO_BUILD_DIR }}/ruffle_desktop.exe package/ruffle.exe
7z a ${{ env.PACKAGE_FILE }} ./package/*
- name: Package Linux
if: runner.os == 'Linux'
run: |
cp ${{ env.CARGO_BUILD_DIR }}/ruffle_desktop package/ruffle
cd package/
tar -czvf ../${{ env.PACKAGE_FILE }} *
- name: Upload package
if: runner.os != 'macOS'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-nightly-release.outputs.upload_url }}
asset_path: ./${{ env.PACKAGE_FILE }}
asset_name: ${{ env.PACKAGE_FILE }}
asset_content_type: ${{ endsWith(env.PACKAGE_FILE, 'tar.gz') && 'application/gzip' || 'application/zip' }}
- name: Upload macOS build artifact
if: runner.os == 'macOS'
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.build_name }}
path: |
${{ env.CARGO_BUILD_DIR }}/ruffle_desktop
package
build-mac-universal-binary:
name: Build macOS universal binary
needs: [create-nightly-release, build]
runs-on: macos-latest
env:
PACKAGE_FILE: ${{ needs.create-nightly-release.outputs.package_prefix }}-macos-universal.tar.gz
steps:
2021-04-26 06:51:24 +00:00
- name: Download aarch64 binary
2021-04-24 02:28:35 +00:00
uses: actions/download-artifact@v2
with:
name: macos-aarch64
2021-04-26 06:51:24 +00:00
- name: Download x86_64 binary
2021-04-24 02:28:35 +00:00
uses: actions/download-artifact@v2
with:
name: macos-x86_64
- name: Make universal binary
run: |
lipo -create -output package/ruffle target/x86_64-apple-darwin/release/ruffle_desktop target/aarch64-apple-darwin/release/ruffle_desktop
chmod +x package/ruffle
- name: Package macOS
run: |
cd package
tar -czvf ../${{ env.PACKAGE_FILE }} *
- name: Upload package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-nightly-release.outputs.upload_url }}
asset_path: ./${{ env.PACKAGE_FILE }}
asset_name: ${{ env.PACKAGE_FILE }}
asset_content_type: application/gzip
build-web:
name: Build web
needs: create-nightly-release
if: needs.create-nightly-release.outputs.activity_check == 'true'
runs-on: ubuntu-latest
steps:
- name: Clone Ruffle repo
uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: wasm32-unknown-unknown
2021-02-01 03:07:36 +00:00
- name: Setup Node.js
uses: actions/setup-node@v1
with:
2021-09-09 03:19:15 +00:00
node-version: "14"
2021-02-03 18:45:44 +00:00
# wasm-bindgen-cli version must match wasm-bindgen crate version.
# Be sure to update in test_web.yml, web/Cargo.toml and web/README.md.
- name: Install wasm-bindgen
2021-04-24 02:28:35 +00:00
uses: actions-rs/cargo@v1
with:
command: install
args: wasm-bindgen-cli --version 0.2.78
- name: Setup conda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: binaryen
2021-02-03 18:45:44 +00:00
# conda is available only with "shell: bash -l {0}".
# See https://github.com/marketplace/actions/setup-miniconda.
- name: Install binaryen
2021-02-03 18:45:44 +00:00
shell: bash -l {0}
run: conda install -c conda-forge binaryen
2020-11-26 14:29:52 +00:00
2021-09-18 09:29:35 +00:00
- name: Build web
env:
BUILD_ID: ${{ github.run_number }}
working-directory: web
2021-02-03 18:45:44 +00:00
shell: bash -l {0}
run: |
npm run bootstrap
npm run build
2020-11-18 10:58:56 +00:00
npm run docs
- name: Package selfhosted
run: |
2021-02-01 03:07:36 +00:00
cd web/packages/selfhosted/dist/
zip -r release.zip .
- name: Upload selfhosted
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-nightly-release.outputs.upload_url }}
asset_path: ./web/packages/selfhosted/dist/release.zip
2021-04-24 02:28:35 +00:00
asset_name: ${{ needs.create-nightly-release.outputs.package_prefix }}-web-selfhosted.zip
asset_content_type: application/zip
2021-02-01 03:07:36 +00:00
- name: Upload generic extension
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-nightly-release.outputs.upload_url }}
2021-02-01 03:07:36 +00:00
asset_path: ./web/packages/extension/dist/ruffle_extension.zip
2021-04-24 02:28:35 +00:00
asset_name: ${{ needs.create-nightly-release.outputs.package_prefix }}-web-extension.zip
2021-02-01 03:07:36 +00:00
asset_content_type: application/zip
- name: Upload Firefox extension (unsigned)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-nightly-release.outputs.upload_url }}
asset_path: ./web/packages/extension/dist/firefox_unsigned.xpi
asset_name: ${{ needs.create-nightly-release.outputs.package_prefix }}-web-extension-firefox-unsigned.xpi
asset_content_type: application/x-xpinstall
- name: Clone web demo
uses: actions/checkout@v2
with:
repository: ruffle-rs/demo
path: demo
ref: master
fetch-depth: 0
persist-credentials: false # Needed to allow commit via RUFFLE_BUILD_TOKEN below
- name: Update web demo
run: |
2021-02-01 03:07:36 +00:00
cd demo/
# Delete the old build.
rm -f *.js *.wasm *.html
# Copy the fresh build into this folder.
cp -f ../web/packages/demo/dist/* .
# Create git commit. Amend previous commit to avoid daily commit spam.
git config user.name "RuffleBuild"
2021-02-01 03:07:36 +00:00
git config user.email "ruffle@ruffle.rs"
git add -A
git commit --amend -m "Nightly build ${{ needs.create-nightly-release.outputs.date }}"
- name: Push web demo
uses: ad-m/github-push-action@master
with:
repository: ruffle-rs/demo
github_token: ${{ secrets.RUFFLE_BUILD_TOKEN }}
directory: demo
force: true
2020-11-18 10:58:56 +00:00
2021-02-01 03:07:36 +00:00
- name: Clone JS docs
2020-11-18 10:58:56 +00:00
uses: actions/checkout@v2
with:
repository: ruffle-rs/js-docs
path: js-docs
ref: master
fetch-depth: 0
persist-credentials: false # Needed to allow commit via RUFFLE_BUILD_TOKEN below
2021-02-01 03:07:36 +00:00
- name: Update JS docs
2020-11-18 10:58:56 +00:00
run: |
2021-02-01 03:07:36 +00:00
cd js-docs/
2020-11-18 10:58:56 +00:00
# Delete the old docs
2021-02-01 03:07:36 +00:00
rm -rf master/
2020-11-18 10:58:56 +00:00
# Copy the fresh docs into this folder.
2021-02-01 03:07:36 +00:00
cp -r ../web/packages/core/docs master
2020-11-18 10:58:56 +00:00
# Create git commit. Amend previous commit to avoid daily commit spam.
git config user.name "RuffleBuild"
2021-02-01 03:07:36 +00:00
git config user.email "ruffle@ruffle.rs"
2020-11-18 10:58:56 +00:00
git add -A
2021-02-01 03:07:36 +00:00
git commit --amend -m "Nightly build ${{ needs.create-nightly-release.outputs.date }}"
2020-11-18 10:58:56 +00:00
2021-02-01 03:07:36 +00:00
- name: Push JS docs
2020-11-18 10:58:56 +00:00
uses: ad-m/github-push-action@master
with:
repository: ruffle-rs/js-docs
github_token: ${{ secrets.RUFFLE_BUILD_TOKEN }}
directory: js-docs
force: true
publish-aur-package:
2021-02-02 18:21:56 +00:00
name: Publish AUR package
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get current time with dashes
uses: 1466587594/get-current-time@v2
id: current_time_dashes
with:
format: YYYY-MM-DD
- name: Get current time with dots
uses: 1466587594/get-current-time@v2
id: current_time_dots
with:
format: YYYY.MM.DD
- name: Update PKGBUILD
run: sed -e "s/@VERSION@/${{ steps.current_time_dots.outputs.formattedTime }}/" -i ./PKGBUILD
- name: Publish AUR package
uses: KSXGitHub/github-actions-deploy-aur@v2.2.5
with:
pkgname: ruffle-nightly-bin
pkgbuild: ./PKGBUILD
commit_username: RuffleBuild
commit_email: ruffle@ruffle.rs
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: Update to Nightly ${{ steps.current_time_dashes.outputs.formattedTime }}