From 1db92578b0a5d6ed670f67c98ef18431c715fec3 Mon Sep 17 00:00:00 2001 From: Idan Arye Date: Tue, 6 Sep 2022 13:31:16 +0300 Subject: [PATCH] Publish on itch.io as part of the tag release workflow --- .github/workflows/release.yaml | 79 ++++++++++++++++++++++++++++++++++ README.md | 12 ++++++ 2 files changed, 91 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e91e8df..537dbf7 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -8,6 +8,8 @@ on: env: # update with the name of the main binary binary: bevy_github_ci_template + add_binaries_to_github_release: true + #itch_target: / jobs: @@ -43,7 +45,14 @@ jobs: files: wasm dest: ${{ env.binary }}.zip + - name: Upload binaries to artifacts + uses: actions/upload-artifact@v3 + with: + path: ${{ env.binary }}.zip + name: wasm + - name: Upload binaries to release + if: ${{ env.add_binaries_to_github_release == 'true' }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} @@ -84,7 +93,14 @@ jobs: files: linux dest: ${{ env.binary }}.zip + - name: Upload binaries to artifacts + uses: actions/upload-artifact@v3 + with: + path: ${{ env.binary }}.zip + name: linux + - name: Upload binaries to release + if: ${{ env.add_binaries_to_github_release == 'true' }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} @@ -122,7 +138,14 @@ jobs: files: windows dest: ${{ env.binary }}.zip + - name: Upload binaries to artifacts + uses: actions/upload-artifact@v3 + with: + path: ${{ env.binary }}.zip + name: windows + - name: Upload binaries to release + if: ${{ env.add_binaries_to_github_release == 'true' }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} @@ -160,7 +183,14 @@ jobs: cp -r assets ${{ env.binary }}.app/Contents/MacOS/ hdiutil create -fs HFS+ -volname "${{ env.binary }}" -srcfolder ${{ env.binary }}.app ${{ env.binary }}.dmg + - name: Upload binaries to artifacts + uses: actions/upload-artifact@v3 + with: + path: ${{ env.binary }}.dmg + name: mac + - name: Upload binaries to release + if: ${{ env.add_binaries_to_github_release == 'true' }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} @@ -168,3 +198,52 @@ jobs: asset_name: ${{ env.binary }}-macos-${{ steps.get_version.outputs.tag }}.dmg tag: ${{ github.ref }} 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 "::set-output name=has-itch-target::no" + else + echo "::set-output name=has-itch-target::yes" + fi + + upload-to-itch: + runs-on: ubuntu-latest + needs: + - check-if-upload-to-itch-is-configured + - release-wasm + - release-linux + - release-windows + - release-macos + if: ${{ needs.check-if-upload-to-itch-is-configured.outputs.should-upload == 'yes' }} + + steps: + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + path: ./builds + + - name: Install butler + run: | + curl -L -o butler.zip https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default + unzip butler.zip + chmod +x butler + ./butler -V + - uses: little-core-labs/get-git-tag@v3.0.1 + id: get_version + - name: Upload to itch.io + env: + BUTLER_API_KEY: ${{ secrets.BUTLER_CREDENTIALS }} + run: | + for channel in $(ls builds); do + ./butler push \ + --fix-permissions \ + --userversion="${{ steps.get_version.outputs.tag }}" \ + builds/$channel/* \ + ${{ env.itch_target }}:$channel + done diff --git a/README.md b/README.md index 864bd0c..7020cbf 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ It will build: If you don't want to target some of those platforms, you can remove the corresponding job from the file [release.yaml](./.github/workflows/release.yaml). +If you don't want to attach the builds to the GitHub release, set `env.add_binaries_to_github_release` to `false`. + ### Git Tag from GitHub UI You can follow [Managing releases in a repository](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository) @@ -53,3 +55,13 @@ A new release will be available in GitHub, with the archives per platform availb The `git` commands above produced this release: [my-game-1.0]( https://github.com/bevyengine/bevy_github_ci_template/releases/tag/my-game-1.0). + +### Publish on itch.io + +The release flow can be configured to push the releases to itch.io: + +1. Create an API key in https://itch.io/user/settings/api-keys +2. Go to the repository's Settings tab in GitHub, click on Secrets->Actions in the sidebar,and add a repository secret named `BUTLER_CREDENTIALS` set to the API key. +3. Uncomment `env.itch_target` in `release.yaml` and set it to the itch.io username and the name of the game on itch.io, separated by a slash (`/`) + +Once that is done, any tag pushed to GitHub will trigger an itch.io release and use the tag as the [user version](https://itch.io/docs/butler/pushing.html#specifying-your-own-version-number).