Release Nightly #430
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: Release Nightly | |
on: | |
# Run nightly | |
schedule: | |
- cron: "0 0 * * *" | |
# Allow for manual dispatch on GitHub | |
workflow_dispatch: | |
jobs: | |
create-nightly-release: | |
name: Create Nightly Release | |
runs-on: ubuntu-22.04 | |
outputs: | |
activity_check: ${{ env.GHA_REPO_ALIVE }} | |
date: ${{ steps.current_time_underscores.outputs.formattedTime }} | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
package_prefix: ruffle-nightly-${{ steps.current_time_underscores.outputs.formattedTime }} | |
steps: | |
- name: Activity check | |
run: | | |
: | |
# Based off https://gh.neting.ccmunity/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) | |
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 | |
echo "Repository activity: $timestamp $author $url" | |
alive=0 | |
if [ "${{ github.event_name }}" == "repository_dispatch" ] || [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
echo "[WARNING] Ignoring activity check: workflow triggered manually." | |
alive=1 | |
elif [[ $days < 1 ]]; then | |
echo Repository active | |
alive=1 | |
else | |
echo "[WARNING] Repository not updated: event ${{ github.event_name }} not allowed to modify stale repository." | |
fi | |
if [[ $alive == 1 ]]; then | |
echo "GHA_REPO_ALIVE=true" >> $GITHUB_ENV | |
fi | |
shell: bash | |
- 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 | |
build: | |
name: Build ${{ matrix.build_name }} | |
needs: create-nightly-release | |
if: needs.create-nightly-release.outputs.activity_check == 'true' | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- build_name: linux-x86_64 | |
os: ubuntu-22.04 | |
# Mac does two Rust builds to make a universal binary | |
- build_name: macos-x86_64 | |
os: macos-latest | |
target: x86_64-apple-darwin | |
MACOSX_DEPLOYMENT_TARGET: 10.7 | |
DESKTOP_FEATURES: sandbox | |
- build_name: macos-aarch64 | |
os: macos-latest | |
target: aarch64-apple-darwin | |
MACOSX_DEPLOYMENT_TARGET: 11.0 | |
DESKTOP_FEATURES: sandbox | |
- 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: | |
- name: Clone Ruffle repo | |
uses: actions/checkout@v2 | |
- name: Install Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
target: ${{ matrix.target }} | |
- name: Install Linux dependencies | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt install -y libasound2-dev libxcb-shape0-dev libxcb-xfixes0-dev libgtk-3-dev | |
- name: Cargo build | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --package ruffle_desktop --release ${{matrix.DESKTOP_FEATURES && '--features' }} ${{matrix.DESKTOP_FEATURES}} ${{ matrix.target && '--target' }} ${{ matrix.target }} | |
env: | |
RUSTFLAGS: ${{ matrix.RUSTFLAGS }} | |
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.MACOSX_DEPLOYMENT_TARGET }} | |
- 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 | |
# We must enter the package/ directory in order to create a flat tarball (i.e. without a directory in it). | |
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: Build Safari Web Extension stub binary | |
if: runner.os == 'macOS' | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --package ruffle_web_safari --release ${{ matrix.target && '--target' }} ${{ matrix.target }} | |
env: | |
RUSTFLAGS: ${{ matrix.RUSTFLAGS }} | |
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.MACOSX_DEPLOYMENT_TARGET }} | |
- 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 | |
${{ env.CARGO_BUILD_DIR }}/ruffle_web_safari | |
package | |
build-mac-universal-binary: | |
name: Build macOS universal binary | |
needs: [create-nightly-release, build, build-web] | |
runs-on: macos-latest | |
env: | |
PACKAGE_FILE: ${{ needs.create-nightly-release.outputs.package_prefix }}-macos-universal.tar.gz | |
steps: | |
- name: Clone Ruffle repo | |
uses: actions/checkout@v2 | |
- name: Download aarch64 binary | |
uses: actions/download-artifact@v2 | |
with: | |
name: macos-aarch64 | |
- name: Download x86_64 binary | |
uses: actions/download-artifact@v2 | |
with: | |
name: macos-x86_64 | |
- name: Download Safari extension | |
uses: actions/download-artifact@v2 | |
with: | |
name: macos-safari | |
- name: Make universal desktop 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: Make universal Safari stub binary | |
continue-on-error: true | |
run: | | |
lipo -create -output package/ruffle_web_safari target/x86_64-apple-darwin/release/ruffle_web_safari target/aarch64-apple-darwin/release/ruffle_web_safari | |
chmod +x package/ruffle_web_safari | |
- name: Create app bundle | |
run: | | |
cp -r desktop/packages/macOS package/Ruffle.app | |
mkdir package/Ruffle.app/Contents/MacOS | |
mv package/ruffle package/Ruffle.app/Contents/MacOS/ruffle | |
- name: Compile asset catalog | |
run: | | |
mkdir package/Ruffle.app/Contents/Resources | |
xcrun actool --compile package/Ruffle.app/Contents/Resources desktop/assets/Assets.xcassets --minimum-deployment-target 10.0 --platform macosx --warnings --errors --notices --include-all-app-icons | |
- name: Create extension bundle | |
continue-on-error: true | |
run: | | |
mkdir package/Ruffle.app/Contents/PlugIns | |
cp -r web/packages/extension/safari/package package/Ruffle.app/Contents/PlugIns/Ruffle\ Web.appex | |
mkdir package/Ruffle.app/Contents/PlugIns/Ruffle\ Web.appex/Contents/Resources | |
mkdir package/Ruffle.app/Contents/PlugIns/Ruffle\ Web.appex/Contents/MacOS | |
mv package/ruffle_web_safari package/Ruffle.app/Contents/PlugIns/Ruffle\ Web.appex/Contents/MacOS/ruffle_web_safari | |
cp ruffle_extension.zip package/Ruffle.app/Contents/PlugIns/Ruffle\ Web.appex/Contents/Resources | |
cd package/Ruffle.app/Contents/PlugIns/Ruffle\ Web.appex/Contents/Resources | |
unzip ruffle_extension.zip | |
rm ruffle_extension.zip | |
cd ../../../../../../.. | |
- name: Sign bundle | |
continue-on-error: true | |
env: | |
APPLE_DEVELOPER_KEY: ${{ secrets.APPLE_DEVELOPER_KEY }} | |
APPLE_DEVELOPER_KEY_PASSWORD: ${{ secrets.APPLE_DEVELOPER_KEY_PASSWORD }} | |
run: | | |
echo $APPLE_DEVELOPER_KEY | base64 --decode > certificate.p12 | |
security create-keychain -p correct-horse-battery-staple build.keychain | |
security default-keychain -s build.keychain | |
security unlock-keychain -p correct-horse-battery-staple build.keychain | |
security import certificate.p12 -k build.keychain -P $APPLE_DEVELOPER_KEY_PASSWORD -T /usr/bin/codesign | |
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k correct-horse-battery-staple build.keychain | |
codesign --deep -s ${{ secrets.APPLE_DEVELOPER_IDENTITY }} -f --entitlements desktop/assets/macOSEntitlements.plist --options runtime package/Ruffle.app | |
codesign --verify -vvvv package/Ruffle.app | |
- name: Notarize bundle | |
continue-on-error: true | |
run: | | |
xcrun notarytool store-credentials "Ruffle" --apple-id ${{ secrets.APPLE_ID }} --team-id ${{ secrets.APPLE_TEAM }} --password ${{ secrets.APPLE_APP_PASSWORD }} | |
cd package | |
zip -r Ruffle.zip Ruffle.app | |
mv Ruffle.zip .. | |
cd .. | |
xcrun notarytool submit Ruffle.zip --keychain-profile Ruffle --wait | |
xcrun stapler staple package/Ruffle.app | |
- name: Package macOS | |
run: | | |
# We must enter the package/ directory in order to create a flat tarball (i.e. without a directory in it). | |
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${{ matrix.demo && ' demo' || '' }} | |
needs: create-nightly-release | |
if: needs.create-nightly-release.outputs.activity_check == 'true' | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
demo: [false, true] | |
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 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: "16" | |
registry-url: https://registry.npmjs.org | |
# 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 | |
uses: actions-rs/cargo@v1 | |
with: | |
command: install | |
args: wasm-bindgen-cli --version 0.2.83 | |
- name: Setup conda | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
activate-environment: binaryen | |
# conda is available only with "shell: bash -l {0}". | |
# See https://github.com/marketplace/actions/setup-miniconda. | |
- name: Install binaryen | |
shell: bash -l {0} | |
run: conda install -c conda-forge binaryen | |
- name: Build web | |
env: | |
BUILD_ID: ${{ github.run_number }} | |
# Build web demo with WebGPU support for testing in Chrome origin trial on ruffle.rs | |
CARGO_FEATURES: ${{ matrix.demo && 'webgpu' || '' }} | |
FIREFOX_EXTENSION_ID: ${{ secrets.FIREFOX_EXTENSION_ID }} # Needed to inject into manifest.json | |
working-directory: web | |
shell: bash -l {0} | |
run: | | |
npm ci | |
npm run build:dual-wasm | |
npm run docs | |
- name: Publish Firefox extension | |
if: env.FIREFOX_EXTENSION_ID != '' && !matrix.demo | |
id: sign-firefox | |
continue-on-error: true | |
env: | |
FIREFOX_EXTENSION_ID: ${{ secrets.FIREFOX_EXTENSION_ID }} | |
MOZILLA_API_KEY: ${{ secrets.MOZILLA_API_KEY }} | |
MOZILLA_API_SECRET: ${{ secrets.MOZILLA_API_SECRET }} | |
working-directory: web/packages/extension | |
shell: bash -l {0} | |
run: npm run sign-firefox | |
- name: Publish npm package | |
if: ${{ !matrix.demo }} | |
# npm scoped packages are private by default, explicitly make public | |
run: npm publish --access public | |
continue-on-error: true | |
working-directory: web/packages/selfhosted/dist | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Package selfhosted | |
if: ${{ !matrix.demo }} | |
run: zip -r release.zip . | |
working-directory: web/packages/selfhosted/dist | |
- name: Upload selfhosted | |
if: ${{ !matrix.demo }} | |
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 | |
asset_name: ${{ needs.create-nightly-release.outputs.package_prefix }}-web-selfhosted.zip | |
asset_content_type: application/zip | |
- name: Upload generic extension | |
if: ${{ !matrix.demo }} | |
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/ruffle_extension.zip | |
asset_name: ${{ needs.create-nightly-release.outputs.package_prefix }}-web-extension.zip | |
asset_content_type: application/zip | |
- name: Upload Safari build artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: macos-safari | |
path: ./web/packages/extension/dist/ruffle_extension.zip | |
- name: Upload Firefox extension (unsigned) | |
if: steps.sign-firefox.outcome != 'success' && !matrix.demo | |
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: Publish Chrome extension | |
if: env.CHROME_EXTENSION_ID != '' && !matrix.demo | |
id: publish-chrome-extension | |
continue-on-error: true | |
env: | |
CHROME_EXTENSION_ID: ${{ secrets.CHROME_EXTENSION_ID }} | |
uses: mnao305/chrome-extension-upload@2.2.0 | |
with: | |
extension-id: ${{ secrets.CHROME_EXTENSION_ID }} | |
client-id: ${{ secrets.CHROME_CLIENT_ID }} | |
refresh-token: ${{ secrets.CHROME_REFRESH_TOKEN }} | |
file-path: ./web/packages/extension/dist/ruffle_extension.zip | |
- name: Clone web demo | |
if: matrix.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 | |
if: matrix.demo | |
run: | | |
# 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" | |
git config user.email "ruffle@ruffle.rs" | |
git add -A | |
git commit --amend -m "Nightly build ${{ needs.create-nightly-release.outputs.date }}" | |
working-directory: demo | |
- name: Push web demo | |
if: github.repository == 'ruffle-rs/ruffle' && matrix.demo | |
uses: ad-m/github-push-action@master | |
with: | |
repository: ruffle-rs/demo | |
github_token: ${{ secrets.RUFFLE_BUILD_TOKEN }} | |
directory: demo | |
force: true | |
- name: Clone JS docs | |
if: ${{ !matrix.demo }} | |
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 | |
- name: Update JS docs | |
if: ${{ !matrix.demo }} | |
run: | | |
# Delete the old docs | |
rm -rf master/ | |
# Copy the fresh docs into this folder. | |
cp -r ../web/packages/core/docs master | |
# Create git commit. Amend previous commit to avoid daily commit spam. | |
git config user.name "RuffleBuild" | |
git config user.email "ruffle@ruffle.rs" | |
git add -A | |
git commit --amend -m "Nightly build ${{ needs.create-nightly-release.outputs.date }}" | |
working-directory: js-docs | |
- name: Push JS docs | |
if: github.repository == 'ruffle-rs/ruffle' && !matrix.demo | |
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: | |
name: Publish AUR package | |
needs: build | |
runs-on: ubuntu-22.04 | |
if: github.repository == 'ruffle-rs/ruffle' | |
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 }} |