From 0ec17640f615cb11e4d844ab195a79d532bea2af Mon Sep 17 00:00:00 2001 From: AmeKnite <104745335+ameknite@users.noreply.github.com> Date: Mon, 16 Oct 2023 19:46:53 -0600 Subject: [PATCH] fix rebase :/ --- .github/workflows/release.yaml | 407 ++++++++++++++++++--------------- README.md | 71 +++--- 2 files changed, 258 insertions(+), 220 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 9462369..a72ab44 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -4,31 +4,36 @@ name: Release env: # If your repo name differs from your binary name, change it. # Check you Cargo.toml -> package -> name - binary: ${{ github.event.repository.name }} + binary: ${{ github.event.repository.name }} # Build platforms - add_web: true - add_linux: true - add_windows: true - add_macos_intel: true - add_macos_apple_silicon: true + + # Valid platforms: "web, linux, windows, macos_intel, macos_apple_silicon" + # - Write "intel" and "apple" to abbreviate "macos_intel" and "macos_apple_silicon," respectively. + # - Write "macos" to build for both "intel" and "apple" + # - Write "web" or "wasm" to build for the web + build_for: "web, linux, windows, macos" # Releases - - # Github release - add_github_release: true - # Itch.io - add_itchio_release: false + # Valid platforms: "github_releases, itchio, github_pages" + # - For brevity you can write: "releases, itchio, pages" + publish_to: "github_releases" + + # Itch.io configuration + + # itchio_target is REQUIRED for publish to itch.io to work. + itchio_target: #/ # Example of itchio_target: cart/build-a-better-buddy # Check the url of your game page in itch.io - # itchio_target: / - - # Github pages - add_github_pages_release: false permissions: + # To upload files to GitHub Releases contents: write + # To deploy to Pages + pages: write + # To verify the deployment originates from an appropriate source + id-token: write on: push: @@ -37,77 +42,53 @@ on: workflow_dispatch: inputs: tag: - description: 'Add tag version: (e.g. -> v3.6.1)' + description: "Add tag version: (e.g. -> v3.6.1)" required: true type: string - add_web: - description: 'Build for Web:' - type: boolean - add_linux: - description: 'Build for Linux:' - type: boolean - add_windows: - description: 'Build for Windows:' - type: boolean - add_macos_intel: - description: 'Build for MacOS Intel' - type: boolean - add_macos_apple_silicon: - description: 'Build for MacOS Apple Silicon' - type: boolean - add_github_release: - description: 'Publish to Github Release' - type: boolean - add_github_pages_release: - description: 'Publish to Github Pages' - type: boolean - add_itchio_release: - description: 'Publish to Itch.io' - type: boolean + build_for: + description: "Build for:" + default: web,linux,windows,macos + publish_to: + description: "Publish to:" + default: github_releases itchio_target: - description: 'Itchio target: /' + description: "Itchio target: /" type: string jobs: load-env: runs-on: ubuntu-latest steps: - - name: check if itchio target exist - id : check-itchio-target - run: | - echo ${{env.binary}} - if [[ -z ${{env.itchio_target || inputs.itchio_target}} ]]; then - echo "target_exists=false" >> $GITHUB_OUTPUT - else - echo "target_exists=true" >> $GITHUB_OUTPUT - fi - - id: get_version uses: olegtarasov/get-tag@v2.1.2 outputs: - run-build-web: ${{(inputs.tag && inputs.add_web) || (!inputs.tag && env.add_web)}} - run-build-linux: ${{(inputs.tag && inputs.add_linux) || (!inputs.tag && env.add_linux)}} - run-build-windows: ${{(inputs.tag && inputs.add_windows) || (!inputs.tag && env.add_windows)}} - run-build-macos-intel: ${{(inputs.tag && inputs.add_macos_intel) || (!inputs.tag && env.add_macos_apple_silicon)}} - run-build-macos-apple-silicon: ${{(inputs.tag && inputs.add_macos_apple_silicon) || (!inputs.tag && env.add_macos_apple_silicon)}} - run_github_release: ${{(inputs.tag && inputs.add_github_release) || (!inputs.tag && env.add_github_release)}} - run_itchio_release: ${{(inputs.tag && inputs.add_itchio_release) || (!inputs.tag && env.add_itchio_release)}} - run_github_pages_release: ${{(inputs.tag && inputs.add_github_pages_release) || (!inputs.tag && env.add_github_pages_release)}} - has_itchio_target: ${{steps.check-itchio-target.outputs.target_exists}} - tag: ${{(inputs.tag || steps.get_version.outcome.tag)}} - - # Build for wasm - release-wasm: + run_build_web: ${{ ( inputs.tag && (contains(inputs.build_for, 'web') || contains(inputs.build_for, 'wasm')) ) || ( !inputs.tag && (contains(env.build_for, 'web') || contains(env.build_for, 'wasm')) ) }} + run_build_linux: ${{ (inputs.tag && contains(inputs.build_for, 'linux')) || (!inputs.tag && contains(env.build_for, 'linux') ) }} + run_build_windows: ${{ ( inputs.tag && contains(inputs.build_for, 'windows')) || (!inputs.tag && contains(env.build_for, 'windows') ) }} + run_build_macos_intel: ${{ ( inputs.tag && (contains(inputs.build_for, 'intel') || contains(inputs.build_for, 'macos')) ) || (!inputs.tag && (contains(env.build_for, 'intel') || contains(env.build_for, 'macos')) ) }} + run_build_macos_apple_silicon: ${{ ( inputs.tag && ( contains(inputs.build_for, 'apple') || contains(inputs.build_for, 'macos') )) || (!inputs.tag && (contains(env.build_for, 'apple') || contains(env.build_for, 'macos')) ) }} + run_publish_github_releases: ${{ ( inputs.tag && contains(inputs.publish_to, 'releases')) || (!inputs.tag && contains(env.publish_to, 'releases') ) }} + run_publish_itchio: ${{ ( inputs.tag && contains(inputs.publish_to, 'itchio')) || (!inputs.tag && contains(env.publish_to, 'itchio') ) }} + run_publish_github_pages: ${{ ( inputs.tag && contains(inputs.publish_to, 'pages')) || (!inputs.tag && contains(env.publish_to, 'pages') ) }} + itchio_target: ${{ inputs.itchio_target || env.itchio_target }} + tag: ${{ ( inputs.tag || steps.get_version.outputs.tag ) }} + + # Build for Web Wasm + build-web: runs-on: ubuntu-latest + needs: load-env + if: needs.load-env.outputs.run_build_web == 'true' + env: + platform: web steps: - - uses: olegtarasov/get-tag@v2.1.2 - id: get_version - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable with: targets: wasm32-unknown-unknown + - name: install wasm-bindgen-cli run: | cargo install wasm-bindgen-cli @@ -116,44 +97,49 @@ jobs: run: | cargo build --release --target wasm32-unknown-unknown + - name: Set file name + id: set_file_name + run: | + echo "file_name=${{ env.binary }}_${{ needs.load-env.outputs.tag }}_${{ env.platform }}" >> "$GITHUB_OUTPUT" + - name: Prepare package run: | wasm-bindgen --no-typescript --out-name bevy_game --out-dir wasm --target web target/wasm32-unknown-unknown/release/${{ env.binary }}.wasm cp -r assets wasm/ + - name: Upload github-page to artifacts + if: needs.load-env.outputs.run_publish_github_pages == 'true' + uses: actions/upload-pages-artifact@v2 + with: + path: ./wasm + retention-days: 1 + - name: Package as a zip working-directory: ./wasm run: | - zip --recurse-paths ../${{ env.binary }}.zip . + zip --recurse-paths ../${{ steps.set_file_name.outputs.file_name }}.zip . - name: Upload binaries to artifacts uses: actions/upload-artifact@v3 with: - path: ${{ env.binary }}.zip - name: wasm + name: ${{ env.platform }} + path: ${{ steps.set_file_name.outputs.file_name }}.zip retention-days: 1 - - name: Upload binaries to release - if: ${{ env.add_github_release == 'true' }} - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ${{ env.binary }}.zip - asset_name: ${{ env.binary }}-wasm-${{ steps.get_version.outputs.tag }}.zip - tag: ${{ github.ref }} - overwrite: true - - # Build for Linux - release-linux: + # Build for Linux x86_64 + build-linux: runs-on: ubuntu-latest - + needs: load-env + if: needs.load-env.outputs.run_build_linux == 'true' + env: + platform: linux steps: - - uses: olegtarasov/get-tag@v2.1.2 - id: get_version - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable with: targets: x86_64-unknown-linux-gnu + - name: install dependencies run: | sudo apt-get update; sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev @@ -162,6 +148,11 @@ jobs: run: | cargo build --release --target x86_64-unknown-linux-gnu + - name: Set file name + id: set_file_name + run: | + echo "file_name=${{ env.binary }}_${{ needs.load-env.outputs.tag }}_${{ env.platform }}" >> "$GITHUB_OUTPUT" + - name: Prepare package run: | mkdir linux @@ -171,33 +162,25 @@ jobs: - name: Package as a zip working-directory: ./linux run: | - zip --recurse-paths ../${{ env.binary }}.zip . + zip --recurse-paths ../${{ steps.set_file_name.outputs.file_name }}.zip . - name: Upload binaries to artifacts uses: actions/upload-artifact@v3 with: - path: ${{ env.binary }}.zip - name: linux + name: ${{ env.platform }} + path: ${{ steps.set_file_name.outputs.file_name }}.zip retention-days: 1 - - name: Upload binaries to release - if: ${{ env.add_github_release == 'true' }} - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ${{ env.binary }}.zip - asset_name: ${{ env.binary }}-linux-${{ steps.get_version.outputs.tag }}.zip - tag: ${{ github.ref }} - overwrite: true - - # Build for Windows - release-windows: + # Build for Windows x86_64 + build-windows: runs-on: windows-latest - + needs: load-env + if: needs.load-env.outputs.run_build_windows == 'true' + env: + platform: windows steps: - - uses: olegtarasov/get-tag@v2.1.2 - id: get_version - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable with: targets: x86_64-pc-windows-msvc @@ -206,7 +189,14 @@ jobs: run: | cargo build --release --target x86_64-pc-windows-msvc + - name: Set file name + id: set_file_name + shell: bash + run: | + echo "file_name=${{ env.binary }}_${{ needs.load-env.outputs.tag }}_${{ env.platform }}" >> "$GITHUB_OUTPUT" + - name: Prepare package + shell: bash run: | mkdir windows cp target/x86_64-pc-windows-msvc/release/${{ env.binary }}.exe windows/ @@ -214,36 +204,29 @@ jobs: - name: Package as a zip run: | - Compress-Archive -Path windows/* -DestinationPath ${{ env.binary }}.zip + Compress-Archive -Path windows/* -DestinationPath "${{ steps.set_file_name.outputs.file_name }}.zip" - name: Upload binaries to artifacts uses: actions/upload-artifact@v3 with: - path: ${{ env.binary }}.zip - name: windows + name: ${{ env.platform }} + path: ${{ steps.set_file_name.outputs.file_name }}.zip retention-days: 1 - - name: Upload binaries to release - if: ${{ env.add_github_release == 'true' }} - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ${{ env.binary }}.zip - asset_name: ${{ env.binary }}-windows-${{ steps.get_version.outputs.tag }}.zip - tag: ${{ github.ref }} - overwrite: true - # Build for MacOS x86_64 - release-macOS-intel: - runs-on: macOS-latest - + build-macos-intel: + runs-on: macos-latest + needs: load-env + if: needs.load-env.outputs.run_build_macos_intel == 'true' + env: + platform: macos_intel steps: - - uses: olegtarasov/get-tag@v2.1.2 - id: get_version - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable with: targets: x86_64-apple-darwin + - name: Environment Setup run: | export CFLAGS="-fno-stack-check" @@ -253,43 +236,42 @@ jobs: run: | cargo build --release --target x86_64-apple-darwin + - name: Set Paths + id: set_paths + run: | + echo "file_name=${{ env.binary }}_${{ needs.load-env.outputs.tag }}_${{ env.platform }}" >> "$GITHUB_OUTPUT" + echo "app_structure=${{ env.binary }}.app/Contents/MacOS" >> "$GITHUB_OUTPUT" + - name: Prepare Package run: | - mkdir -p ${{ env.binary }}.app/Contents/MacOS - cp target/x86_64-apple-darwin/release/${{ env.binary }} ${{ env.binary }}.app/Contents/MacOS/ - cp -r assets ${{ env.binary }}.app/Contents/MacOS/ - hdiutil create -fs HFS+ -volname "${{ env.binary }}" -srcfolder ${{ env.binary }}.app ${{ env.binary }}-macOS-intel.dmg + mkdir -p ${{ steps.set_paths.outputs.app_structure }} + cp target/x86_64-apple-darwin/release/${{ env.binary }} ${{ steps.set_paths.outputs.app_structure }} + cp -r assets ${{ steps.set_paths.outputs.app_structure }} + hdiutil create -fs HFS+ -volname "${{ env.binary }}" -srcfolder ${{ env.binary }}.app ${{ steps.set_paths.outputs.file_name }}.dmg - name: Upload binaries to artifacts uses: actions/upload-artifact@v3 with: - path: ${{ env.binary }}-macOS-intel.dmg - name: macOS-intel + name: ${{ env.platform }} + path: ${{ steps.set_paths.outputs.file_name }}.dmg retention-days: 1 - - name: Upload binaries to release - if: ${{ env.add_github_release == 'true' }} - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ${{ env.binary }}-macOS-intel.dmg - asset_name: ${{ env.binary }}-macOS-intel-${{ steps.get_version.outputs.tag }}.dmg - tag: ${{ github.ref }} - overwrite: true - # Build for MacOS Apple Silicon - release-macOS-apple-silicon: - runs-on: macOS-latest - + build-macos-apple-silicon: + runs-on: macos-latest + needs: load-env + if: needs.load-env.outputs.run_build_macos_apple_silicon == 'true' + env: + platform: macos_apple_silicon steps: - - uses: olegtarasov/get-tag@v2.1.2 - id: get_version - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable with: targets: aarch64-apple-darwin - - name: Environment - # macOS 11 was the first version to support ARM + + - name: Environment + # macos 11 was the first version to support ARM run: | export MACOSX_DEPLOYMENT_TARGET="11" @@ -297,54 +279,95 @@ jobs: run: | cargo build --release --target aarch64-apple-darwin + - name: Set paths + id: set_paths + run: | + echo "file_name=${{ env.binary }}_${{ needs.load-env.outputs.tag }}_${{ env.platform }}" >> "$GITHUB_OUTPUT" + echo "app_structure=${{ env.binary }}.app/Contents/MacOS" >> "$GITHUB_OUTPUT" + - name: Prepare Package run: | - mkdir -p ${{ env.binary }}.app/Contents/MacOS - cp target/aarch64-apple-darwin/release/${{ env.binary }} ${{ env.binary }}.app/Contents/MacOS/ - cp -r assets ${{ env.binary }}.app/Contents/MacOS/ - hdiutil create -fs HFS+ -volname "${{ env.binary }}-macOS-apple-silicon" -srcfolder ${{ env.binary }}.app ${{ env.binary }}-macOS-apple-silicon.dmg + mkdir -p ${{ steps.set_paths.outputs.app_structure }} + cp target/aarch64-apple-darwin/release/${{ env.binary }} ${{ steps.set_paths.outputs.app_structure }} + cp -r assets ${{ steps.set_paths.outputs.app_structure }} + hdiutil create -fs HFS+ -volname "${{ env.binary }}" -srcfolder ${{ env.binary }}.app ${{ steps.set_paths.outputs.file_name }}.dmg - name: Upload binaries to artifacts uses: actions/upload-artifact@v3 with: - path: ${{ env.binary }}-macOS-apple-silicon.dmg - name: macOS-apple-silicon + name: ${{ env.platform }} + path: ${{ steps.set_paths.outputs.file_name }}.dmg retention-days: 1 - - name: Upload binaries to release - if: ${{ env.add_github_release == 'true' }} + # Release binaries in github + publish-github-releases: + name: Release for ${{ matrix.artifact_name }} + needs: + - load-env + - build-web + - build-linux + - build-windows + - build-macos-apple-silicon + - build-macos-intel + if: ${{ always() && !failure() && !cancelled() && needs.load-env.outputs.run_publish_github_releases == 'true'}} + strategy: + fail-fast: false + matrix: + include: + - artifact_name: web + os: ubuntu-latest + - artifact_name: linux + os: ubuntu-latest + - artifact_name: windows + os: windows-latest + - artifact_name: macos_apple_silicon + os: macos-latest + - artifact_name: macos_intel + os: macos-latest + + runs-on: ${{ matrix.os }} + steps: + - uses: xSAVIKx/artifact-exists-action@v0 + id: check_artifact + with: + name: ${{ matrix.artifact_name }} + + - name: Download artifacts + if: steps.check_artifact.outputs.exists == 'true' + uses: actions/download-artifact@v3 + with: + name: ${{ matrix.artifact_name }} + path: ./artifact + + - name: Get file + if: steps.check_artifact.outputs.exists == 'true' + id: get_file_name + shell: bash + working-directory: ./artifact + run: | + ls -R + echo "file_name=$(ls | head -n 1)" >> "$GITHUB_OUTPUT" + + - name: Upload artifact to release + if: steps.check_artifact.outputs.exists == 'true' uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ${{ env.binary }}-macOS-apple-silicon.dmg - asset_name: ${{ env.binary }}-macOS-apple-silicon-${{ steps.get_version.outputs.tag }}.dmg - tag: ${{ github.ref }} + file: ./artifact/${{ steps.get_file_name.outputs.file_name }} + tag: ${{ needs.load-env.outputs.tag }} overwrite: true - check-if-upload-to-itch-is-configured: - runs-on: ubuntu-latest - outputs: - should-upload: ${{ steps.check-env.outputs.has-itch-target }} - steps: - - id: check-env - run: | - if [[ -z "$itch_target" ]]; then - echo "has-itch-target=no" >> $GITHUB_OUTPUT - else - echo "has-itch-target=yes" >> $GITHUB_OUTPUT - fi - - upload-to-itch: + # Publish to itch.io + publish-itchio: runs-on: ubuntu-latest needs: - - check-if-upload-to-itch-is-configured - - release-wasm - - release-linux - - release-windows - - release-macOS-intel - - release-macOS-apple-silicon - if: ${{ needs.check-if-upload-to-itch-is-configured.outputs.should-upload == 'yes' }} - + - load-env + - build-web + - build-linux + - build-windows + - build-macos-apple-silicon + - build-macos-intel + if: ${{ always() && !failure() && !cancelled() && needs.load-env.outputs.run_publish_itchio == 'true' && needs.load-env.outputs.itchio_target != '' }} steps: - name: Download artifacts uses: actions/download-artifact@v3 @@ -357,16 +380,36 @@ jobs: unzip butler.zip chmod +x butler ./butler -V - - uses: olegtarasov/get-tag@v2.1.2 - id: get_version + - name: Upload to itch.io env: BUTLER_API_KEY: ${{ secrets.BUTLER_CREDENTIALS }} run: | for channel in $(ls builds); do + if [ "$channel" = "github-pages" ]; then + continue + fi ./butler push \ - --fix-permissions \ - --userversion="${{ steps.get_version.outputs.tag }}" \ - builds/$channel/* \ - ${{ env.itch_target }}:$channel + --fix-permissions \ + --userversion="${{ needs.load-env.outputs.tag }}" \ + builds/$channel/* \ + ${{ needs.load-env.outputs.itchio_target }}:$channel done + + # Publish to github page + publish-github-pages: + runs-on: ubuntu-latest + needs: + - load-env + - build-web + if: ${{ needs.load-env.outputs.run_publish_github_pages == 'true' }} + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Setup Pages + uses: actions/configure-pages@v3 + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 diff --git a/README.md b/README.md index ed78f59..d08f54a 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,7 @@ Definition: [.github/workflows/ci.yaml](./.github/workflows/ci.yaml) ![ci workflow](https://user-images.githubusercontent.com/104745335/268799840-06b772e8-7901-4b86-9a88-e4afee8a0167.png) - -This workflow runs on every commit to `main` branch, and on every PR targeting the `main` branch. +This workflow runs on every commit to the `main` branch, and for every PR targeting the `main` branch. It will use Rust stable on Linux with caching between different executions. The following commands are executed: @@ -41,17 +40,19 @@ git tag -a "v1.0.0" -m "First official release" git push --tags ``` -You can use the workflow as it is, but check that the name of your repository matches the name of your binary. If they don't match, you can change the environment variable in [release.yaml](.github/workflows/release.yaml#L7) file. By default it will build for the Web, Linux, Windows, and MacOS, and then it will publish the archives on GitHub Release. + By default, the workflow will build for the Web, Linux, Windows, and MacOS. The builds will be uploaded to a GitHub Release. If the name of your repository does not match the name of your binary, you should update the environment variable [`binary`](.github/workflows/release.yaml#L7) in the `release.yaml` file to your binary name. + +You can configure the [build](.github/workflows/release.yaml#L15) and [publish](.github/workflows/release.yaml#L21) targets by changing the [environment variables](.github/workflows/release.yaml#L4) in the `release.yaml` file. -You can configure the builds and publish targets by changing the env variables in the [release.yaml](.github/workflows/release.yaml#L4) file. +#### Manual Workflow run in GitHub You can configure and trigger the workflow directly in your GitHub repository. Navigate to the `Actions` section, click `Release` on the sidebar, then press the `Run workflow` button and select the configuration for the build and publish targets you want. -![Run workflow](https://github-production-user-asset-6210df.s3.amazonaws.com/104745335/268779376-85f4a503-1564-4075-b1ee-2a830fda2b7c.png) +![Run manual workflow](https://user-images.githubusercontent.com/104745335/270079051-b5fb52c8-ed89-4f91-965e-670f38f87ddb.png) -The configuration in GitHub takes priority over the env variables in the [release.yaml](.github/workflows/release.yaml#L4) file, so you don't have to modify your env variables. The manual workflow also enables you to override the tag version eliminating the need to create another tag to trigger the workflow." +The configuration in GitHub takes priority over the environment variables in the [release.yaml](.github/workflows/release.yaml#L4) file. A manual workflow run also enables you to override the tag version eliminating the need to create a tag to trigger the workflow. -For the itch.io target, you can leave it empty if you already have the environment variable set up. +If you want to publish to itch.io, you will either have to configure the environment variable `itchio_target`, or define the `itchio_target` input for every run. ### Build @@ -61,9 +62,9 @@ You can build for the following platforms: * For MacOS, generate two versions: one for Intel x86_64 and one for Apple Silicon ARM64, each packaged in a .dmg image containing a .app file with the assets. * For the Web, produce a .zip archive with the WebAssembly (wasm) binary, JavaScript bindings, an HTML file for loading it, and the assets. -By default, it builds for all platforms, but you can disable specific targets by setting their environment variable `false` in the ([release.yaml](.github/workflows/release.yaml#L9)) file. +By default, it builds for all platforms, but you can disable specific targets by removing their name in the env variable [`build_for`](.github/workflows/release.yaml#L15) in the release.yaml file. -For example, `build_windows: false` will skip the Windows build. +For example, `build_for: web, linux, macos` will build for the Web, Linux and MacOS but will not build for windows. The build files will be uploaded to the artifacts section of their respective workflow runs. To access them, go to your GitHub repository, navigate to the `Actions` section, click on `Release` in the sidebar, select the `workflow run` triggered by your tag, and scroll down to find your artifacts. @@ -73,22 +74,13 @@ The build files will be uploaded to the artifacts section of their respective wo You can publish to the following platforms: -- [Bevy GitHub CI Template](#bevy-github-ci-template) - - [CI](#ci) - - [Release](#release) - - [Run Workflow](#run-workflow) - - [Build](#build) - - [Publish](#publish) - - [Publish on Github Release](#publish-on-github-release) - - [Publish on Itch.io](#publish-on-itchio) - - [Publish on Github pages](#publish-on-github-pages) - - [Adapting the Workflows for Your Project](#adapting-the-workflows-for-your-project) - - [License](#license) - - [Contribution](#contribution) +* [Github Releases](#publish-to-github-releases) +* [Itch.io](#publish-to-itchio) +* [Github Pages](#publish-to-github-pages) -By default, it only publishes to GitHub Releases, but you can enable or disable any target by setting their environment variable to `true` or `false` in the ([release.yaml](.github/workflows/release.yaml#L19)) file. +By default, it only publishes to GitHub Releases, but you can enable or disable any target by writing or removing their name in the env variable [`publish_to`](.github/workflows/release.yaml#L21) in the release.yaml file. -For example, `publish_github_pages: true` will publish the web version of your game to GitHub Pages. +For example, `publish_github_pages: pages` will only publish the web version of your game to GitHub Pages. Every time you trigger this workflow, it will upload the files for every platform you enable in the build process. @@ -100,9 +92,9 @@ The format will be .zip for web, Windows, and Linux, and .dmg for MacOS. For example: `bevy-game_v3.6_linux.zip` -### Publish on Github Release +### Publish to Github Releases -This action will occur automatically every time you push a tag if you have enabled the environment variable `publish_github_releases: true` in the [release.yaml](./.github/workflows/release.yaml#L28) file. +This action will occur automatically every time you push a tag if you have written `github_releases` to the env variable [`publish_to`](./.github/workflows/release.yaml#L28) in the release.yaml file. However, if you prefer more configuration options to manage your releases, you can do so through the GitHub CLI or the web browser: @@ -111,45 +103,48 @@ However, if you prefer more configuration options to manage your releases, you c Once you complete the process, a new release will be available on GitHub, with the archives for each platform accessible as downloadable assets. -![github release](https://user-images.githubusercontent.com/104745335/268805270-ff824032-4191-4528-9d45-a5511fef4f94.png) +If you want to publish by manually triggering a workflow in GitHub, instead of writing your env variables in the release.yaml file, write all your configuration in the GitHub Workflow form and then run the workflow. Refer to the ['Manual Workflow Run in GitHub'](#manual-workflow-run-in-github) +![github release](https://user-images.githubusercontent.com/104745335/268805270-ff824032-4191-4528-9d45-a5511fef4f94.png) -### Publish on Itch.io +### Publish to Itch.io To publish to itch.io, follow this release flow: 1. Create an API key at -2. In your GitHub repository, go to the "Settings" tab, click on "Secrets" under the "Actions" section in the sidebar, and add a repository secret named `BUTLER_CREDENTIALS`, with the API key as its value. +2. In your GitHub repository, go to the `Settings` tab, click on `Secrets` under the `Actions` section in the sidebar, and add a repository secret named `BUTLER_CREDENTIALS`, with the API key as its value. 3. Create your game page on itch.io if you haven't already. -4. In the [release.yaml](./.github/workflows/release.yaml#L22) file, set the environment variable `publish_itchio: true`. -5. Uncomment the `env.itchio_target` in [release.yaml](./.github/workflows/release.yaml#L25) and set it to your itch.io username and the name of the game on itch.io, separated by a slash (`/`). For example: `cart/build-a-better-buddy`. Double-check the URL of your game to ensure the name is correct. +4. In the release.yaml file, write `itchio` in the env variable [`publish_to`](./.github/workflows/release.yaml#L21). +5. Go to the env variable [`itchio_target`](./.github/workflows/release.yaml#L19) in the release.yaml and set it to your itch.io username and the name of the game on itch.io, separated by a slash (`/`). For example: `cart/build-a-better-buddy`. Double-check the URL of your game to ensure the name is correct. Once these steps are completed, any tag pushed to GitHub will trigger an itch.io release, and it will use the tag as the [user version](https://itch.io/docs/butler/pushing.html#specifying-your-own-version-number). -If you want to make your game playable directly on your Itch.io page, follow the steps above, and make sure to build it for the web by setting the environment variable `env.build_web: true`, or by checking the box labeled `Build for Web` when manually triggering the workflow in GitHub. -Next, to make the game visible on your Itch.io page, go to your game's configuration on Itch.io, and change the `Kind of project` to `HTML`. Additionally, locate your uploaded web files and check the box that says, `This file will be played in the browser`." - +If you want to make your game playable directly on your Itch.io page, follow the steps above, and make sure to build it for the web by writing `web` or `wasm` in the env variable [`publish_for`](./.github/workflows/release.yaml#L21). +Next, to make the game visible on your Itch.io page, go to your game's configuration on Itch.io, and change the `Kind of project` to `HTML`. Additionally, locate your uploaded web files and check the box that says, `This file will be played in the browser`. ![Kind of project](https://user-images.githubusercontent.com/104745335/268805329-fb70e23e-44ee-4f2f-9d20-11d58ddeec9a.png) - ![Play in browser](https://github-production-user-asset-6210df.s3.amazonaws.com/104745335/268780679-fa14874c-040b-41ff-8a04-71cf141970dc.png) -### Publish on Github pages +If you want to publish by manually triggering a workflow in GitHub, instead of doing the 4 and 5 steps, write all your configuration to in the GitHub Workflow form and then run the workflow. Refer to the ['Manual Workflow Run in GitHub'](#manual-workflow-run-in-github). + +### Publish to Github pages If you want to publish your game to be playable in the browser on a [GitHub page](https://pages.github.com/) follow these steps: -1. In the [release.yaml](./.github/workflows/release.yaml#L28) file, verify that both environment variables `publish_github_pages` and `build_web` are set to `true`. +1. In the release.yaml file, verify that you are writing `github_pages` to the env variable [`publish_to`](./.github/workflows/release.yaml#L21) and `web` in the env variable [`build_for`](./.github/workflows/release.yaml#L15). 2. Trigger the [release.yaml](./.github/workflows/release.yaml) workflow by pushing a tag. -3. In your GitHub repository, go to the `Settings` tab, then click on `Pages` in the sidebar. Navigate to the `Build and Deployment` section, select the `gh-pages` branch and set the `root` folder. Finally, click on `Save`. ![Github Pages](https://github-production-user-asset-6210df.s3.amazonaws.com/104745335/268780368-af547adf-d8e8-4bdf-90e5-b7ee717493dc.png) +3. In your GitHub repository, go to the `Settings` tab, then click on `Pages` in the sidebar. Navigate to the `Build and Deployment` section and select `Github Actions` as the `Source`. ![Github Pages](https://user-images.githubusercontent.com/104745335/270078892-a6da763e-5a4a-4f55-8d3c-41a14e8423e2.png) 4. Wait a few minutes and your page will be available at a URL following this structure: `https://.github.io//` +If you want to publish by manually triggering a workflow in GitHub, instead of doing the 1 and 2 steps, write all your configuration in the GitHub Workflow form and then run the workflow. Refer to the ['Manual Workflow Run in GitHub'](#manual-workflow-run-in-github). + ## Adapting the Workflows for Your Project If you'd like to use the GitHub workflows provided here for your own project, you may need to make a few adjustments: 1. For web builds, ensure that your project includes an `index.html` file under the `/wasm` directory. -2. Make sure that the name of your repository matches the name of your binary. If the name of your repository is different, simply change the environment variable `binary` in the ([release.yaml](.github/workflows/release.yaml#L7)) file to match the name of your binary. +2. Make sure that the name of your repository matches the name of your binary. If the name of your repository is different, simply change the env variable [`binary`](.github/workflows/release.yaml#L7) in the release.yaml file to match the name of your binary. 3. If your project doesn't have an `assets` folder: 1. You can create one and add a `.gitkeep` file to it to enable you to push it to your repository. 2. Alternatively, if your project does not use assets, you can remove the `cp -r assets` statements from the build jobs in the workflow.