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-latest outputs: activity_check: ${{ env.GHA_REPO_ALIVE }} 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) 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.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: - uses: actions/checkout@v2 - name: Install Rust toolchain uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable target: wasm32-unknown-unknown - name: Install Linux dependencies if: matrix.os == 'ubuntu-latest' 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 and web/README.md. - name: Install wasm-bindgen run: cargo install wasm-bindgen-cli --version 0.2.73 - 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 if: matrix.os == 'ubuntu-latest' env: FIREFOX_EXTENSION_ID: ${{ secrets.FIREFOX_EXTENSION_ID }} MOZILLA_API_KEY: ${{ secrets.MOZILLA_API_KEY }} MOZILLA_API_SECRET: ${{ secrets.MOZILLA_API_SECRET }} BUILD_ID: ${{ github.run_number }} working-directory: web shell: bash -l {0} run: | npm run bootstrap npm run build npm run docs - name: Build Windows if: matrix.os == 'windows-latest' uses: actions-rs/cargo@v1 with: command: build args: --release env: RUSTFLAGS: -Ctarget-feature=+crt-static - 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: | mkdir package cp README.md package/README.md cp LICENSE.md package/LICENSE.md - name: Package Windows if: matrix.os == 'windows-latest' run: | cp target/release/ruffle_desktop.exe package/ruffle.exe 7z a release.zip ./package/* - name: Package macOS / Linux if: matrix.os == 'macOS-latest' || matrix.os == 'ubuntu-latest' run: | cp target/release/ruffle_desktop package/ruffle cd package/ tar -czvf ../release.tar.gz * - name: Package selfhosted if: matrix.os == 'ubuntu-latest' run: | cd web/packages/selfhosted/dist/ zip -r release.zip . - 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 - 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 - 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 - 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 }} 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 - 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 }} asset_path: ./web/packages/extension/dist/firefox.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: | 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" 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 - name: Clone JS docs 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 - name: Update JS docs if: matrix.os == 'ubuntu-latest' run: | cd js-docs/ # 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 }}" - name: Push JS docs 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 publish-aur-package: 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.3 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 }}