diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e3baf31..a72ab44 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -8,10 +8,10 @@ env: # Build platforms - # Valid platforms: "web, linux, windows, intel, apple_silicon" - # - "intel" and "apple_silicon" are for build to MacOS, - # for breviety you can write "macos" to build for both. - # - you can also write "wasm" to build for web. + # 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 @@ -28,8 +28,11 @@ env: # Check the url of your game page in itch.io 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: @@ -47,7 +50,7 @@ on: default: web,linux,windows,macos publish_to: description: "Publish to:" - default: releases,itchio,pages + default: github_releases itchio_target: description: "Itchio target: /" type: string @@ -71,11 +74,14 @@ jobs: itchio_target: ${{ inputs.itchio_target || env.itchio_target }} tag: ${{ ( inputs.tag || steps.get_version.outputs.tag ) }} - # Build for Web Wasm + # 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: actions/checkout@v4 @@ -91,21 +97,33 @@ 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 }}_${{ needs.load-env.outputs.tag }}_web.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 }}_${{ needs.load-env.outputs.tag }}_web.zip - name: web + name: ${{ env.platform }} + path: ${{ steps.set_file_name.outputs.file_name }}.zip retention-days: 1 # Build for Linux x86_64 @@ -113,6 +131,8 @@ jobs: runs-on: ubuntu-latest needs: load-env if: needs.load-env.outputs.run_build_linux == 'true' + env: + platform: linux steps: - uses: actions/checkout@v4 @@ -128,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 @@ -137,13 +162,13 @@ jobs: - name: Package as a zip working-directory: ./linux run: | - zip --recurse-paths ../${{ env.binary }}_${{ needs.load-env.outputs.tag }}_linux.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 }}_${{ needs.load-env.outputs.tag }}_linux.zip - name: linux + name: ${{ env.platform }} + path: ${{ steps.set_file_name.outputs.file_name }}.zip retention-days: 1 # Build for Windows x86_64 @@ -151,6 +176,8 @@ jobs: runs-on: windows-latest needs: load-env if: needs.load-env.outputs.run_build_windows == 'true' + env: + platform: windows steps: - uses: actions/checkout@v4 @@ -162,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/ @@ -170,13 +204,13 @@ jobs: - name: Package as a zip run: | - Compress-Archive -Path windows/* -DestinationPath "${{ env.binary }}_${{ needs.load-env.outputs.tag }}_windows.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 }}_${{ needs.load-env.outputs.tag }}_windows.zip - name: windows + name: ${{ env.platform }} + path: ${{ steps.set_file_name.outputs.file_name }}.zip retention-days: 1 # Build for MacOS x86_64 @@ -184,6 +218,8 @@ jobs: runs-on: macos-latest needs: load-env if: needs.load-env.outputs.run_build_macos_intel == 'true' + env: + platform: macos_intel steps: - uses: actions/checkout@v4 @@ -200,18 +236,24 @@ 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 }}_${{ needs.load-env.outputs.tag }}_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 }}_${{ needs.load-env.outputs.tag }}_macos_intel.dmg - name: macos_intel + name: ${{ env.platform }} + path: ${{ steps.set_paths.outputs.file_name }}.dmg retention-days: 1 # Build for MacOS Apple Silicon @@ -219,6 +261,8 @@ jobs: 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: actions/checkout@v4 @@ -235,18 +279,24 @@ 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 }}" -srcfolder ${{ env.binary }}.app ${{ env.binary }}_${{ needs.load-env.outputs.tag }}_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 }}_${{ needs.load-env.outputs.tag }}_macos_apple_silicon.dmg - name: macos_apple_silicon + name: ${{ env.platform }} + path: ${{ steps.set_paths.outputs.file_name }}.dmg retention-days: 1 # Release binaries in github @@ -282,28 +332,28 @@ jobs: with: name: ${{ matrix.artifact_name }} - # check for zip or dmg file - - uses: haya14busa/action-cond@v1 - if: steps.check_artifact.outputs.exists == 'true' - id: condval - with: - cond: ${{ matrix.os == 'macos-latest' }} - if_true: "dmg" - if_false: "zip" - - 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 }}_${{ needs.load-env.outputs.tag }}_${{ matrix.artifact_name }}.${{ steps.condval.outputs.value }} - asset_name: ${{ env.binary }}_${{ needs.load-env.outputs.tag }}_${{ matrix.artifact_name }}.${{ steps.condval.outputs.value }} + file: ./artifact/${{ steps.get_file_name.outputs.file_name }} tag: ${{ needs.load-env.outputs.tag }} overwrite: true @@ -331,19 +381,19 @@ jobs: 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="${{ needs.load-env.outputs.tag }}" \ - builds/$channel/* \ - ${{ inputs.itchio_target || env.itchio_target }}:$channel + --fix-permissions \ + --userversion="${{ needs.load-env.outputs.tag }}" \ + builds/$channel/* \ + ${{ needs.load-env.outputs.itchio_target }}:$channel done # Publish to github page @@ -353,20 +403,13 @@ jobs: - 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: - - uses: actions/checkout@v3 - - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - name: web - - - name: Unzip artifact - run: | - unzip ./${{ env.binary }}_${{ needs.load-env.outputs.tag }}_web.zip -d web + - name: Setup Pages + uses: actions/configure-pages@v3 - name: Deploy to GitHub Pages - uses: JamesIves/github-pages-deploy-action@v4 - with: - folder: web - branch: gh-pages + id: deployment + uses: actions/deploy-pages@v2