ruffle/.github/workflows/release_nightly.yml

295 lines
10 KiB
YAML
Raw Normal View History

name: Release Nightly
on:
schedule:
- cron: "0 0 * * *"
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 }}
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" ]; 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:
name: Build ${{ matrix.os }}
needs: create-nightly-release
if: needs.create-nightly-release.outputs.activity_check == 'true'
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
runs-on: ${{ matrix.os }}
steps:
2021-02-01 03:07:36 +00:00
- 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
target: wasm32-unknown-unknown
2021-02-01 03:07:36 +00:00
- name: Install Linux dependencies
if: matrix.os == 'ubuntu-latest'
2021-02-01 03:07:36 +00:00
run: sudo apt install -y libasound2-dev libxcb-shape0-dev libxcb-xfixes0-dev
- name: Setup Node.js
if: matrix.os == 'ubuntu-latest'
uses: actions/setup-node@v1
with:
node-version: '14'
# wasm-bindgen-cli version must match wasm-bindgen crate version
# Be sure to update in test_web.yml, web/Cargo.toml, web/README.md
- name: Install wasm-bindgen
run: cargo install wasm-bindgen-cli --version 0.2.69
- name: Setup conda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: binaryen
- name: Install binaryen
run: conda install -c conda-forge binaryen
2020-11-26 14:29:52 +00:00
2021-02-01 03:07:36 +00:00
- name: Build Web
if: matrix.os == 'ubuntu-latest'
working-directory: web
run: |
npm run bootstrap
npm run build
2020-11-18 10:58:56 +00:00
npm run docs
2021-02-01 03:07:36 +00:00
- name: Build Windows
if: matrix.os == 'windows-latest'
uses: actions-rs/cargo@v1
with:
command: build
args: --release
env:
RUSTFLAGS: -Ctarget-feature=+crt-static
2021-02-01 03:07:36 +00:00
- name: Build macOS / Linux
if: matrix.os == 'macOS-latest' || matrix.os == 'ubuntu-latest'
uses: actions-rs/cargo@v1
with:
command: build
args: --release
- name: Package common
run: |
2021-02-01 03:07:36 +00:00
mkdir package
cp README.md package/README.md
cp LICENSE_APACHE package/LICENSE_APACHE
cp LICENSE_MIT package/LICENSE_MIT
2021-02-01 03:07:36 +00:00
- name: Package Windows
if: matrix.os == 'windows-latest'
run: |
2021-02-01 03:07:36 +00:00
cp target/release/ruffle_desktop.exe package/ruffle.exe
7z a release.zip ./package/*
2021-02-01 03:07:36 +00:00
- name: Package macOS / Linux
if: matrix.os == 'macOS-latest' || matrix.os == 'ubuntu-latest'
run: |
2021-02-01 03:07:36 +00:00
cp target/release/ruffle_desktop package/ruffle
cd package/
tar -czvf ../release.tar.gz *
- name: Package selfhosted
if: matrix.os == 'ubuntu-latest'
run: |
2021-02-01 03:07:36 +00:00
cd web/packages/selfhosted/dist/
zip -r release.zip .
2021-02-01 03:07:36 +00:00
- name: Upload Windows
if: matrix.os == 'windows-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-nightly-release.outputs.upload_url }}
asset_path: ./release.zip
asset_name: ruffle_nightly_${{ needs.create-nightly-release.outputs.date }}_windows.zip
asset_content_type: application/zip
2021-02-01 03:07:36 +00:00
- name: Upload macOS
if: matrix.os == 'macOS-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-nightly-release.outputs.upload_url }}
asset_path: ./release.tar.gz
asset_name: ruffle_nightly_${{ needs.create-nightly-release.outputs.date }}_mac.tar.gz
asset_content_type: application/gzip
2021-02-01 03:07:36 +00:00
- name: Upload Linux
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-nightly-release.outputs.upload_url }}
asset_path: ./release.tar.gz
asset_name: ruffle_nightly_${{ needs.create-nightly-release.outputs.date }}_linux.tar.gz
asset_content_type: application/gzip
- name: Upload selfhosted
if: matrix.os == 'ubuntu-latest'
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: ruffle_nightly_${{ needs.create-nightly-release.outputs.date }}_selfhosted.zip
asset_content_type: application/zip
2021-02-01 03:07:36 +00:00
- name: Upload generic extension
if: matrix.os == 'ubuntu-latest'
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
asset_name: ruffle_nightly_${{ needs.create-nightly-release.outputs.date }}_extension.zip
asset_content_type: application/zip
2021-02-01 03:07:36 +00:00
- name: Upload Firefox extension
if: matrix.os == 'ubuntu-latest'
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/firefox_unsigned.xpi
asset_name: ruffle_nightly_${{ needs.create-nightly-release.outputs.date }}_firefox.xpi
asset_content_type: application/x-xpinstall
- name: Clone web demo
if: matrix.os == 'ubuntu-latest'
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.os == 'ubuntu-latest'
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
if: matrix.os == 'ubuntu-latest'
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
if: matrix.os == 'ubuntu-latest'
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
if: matrix.os == 'ubuntu-latest'
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
if: matrix.os == 'ubuntu-latest'
uses: ad-m/github-push-action@master
with:
repository: ruffle-rs/js-docs
github_token: ${{ secrets.RUFFLE_BUILD_TOKEN }}
directory: js-docs
force: true