My GitHub Action for Godot game publishing
Тьмоки » Devlog
Hi, I would like to share my GitHub Actions workflow. I spent a lot of time on it. Hope it will help someone. The major part of the content has been taken from this tutorial. I also added comments to the script so you can easily understand how this all works
*this workflow require a VERSION file to be in your directory. It is just a simple txt file with the project version number typed in it (like)
This Workflow does:
- export Godot project
- create GitHub release with the project files and the version from the version file added to the exported files'names
- export all the files to the Itch.io project page
- drop a notification in your discord chat
In order to run the script you need to fill the variables in the ENV block, add this workflow to the GitHub repository (tutorial) and push some commits to the main branch
Unfortunately, Itch.io do not allow to upload external files so you have to copy that:
# Here is the Github Action name name: Deploy Game # Here we tell when this action should be launched on: push: branches: - main # Here we declare all variables we will use below env: # Itch variables BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }} ITCH_PROJECT_NAME: "project name from the ith.io page" ITCH_USERNAME: "your username" # Other EXPORT_NAME: "the name of the exported file" IS_MAIN: ${{contains(github.ref, 'main')}} # Discord variables DISCORD_WEBHOOK: ${{secrets.DISCORD_WEBHOOK}} ITCH_PROJECT_LINK: "the ithch.io project page link" # Here are all the steps of the Action jobs: # Here the script uses external machine to export pushed project BuildAndPublish: name: Checkout Source Code runs-on: ubuntu-20.04 container: image: barichello/godot-ci:3.3 steps: - name: Download + Authorize Godot uses: actions/checkout@v2.3.4 - name: Setup templates run: | mkdir -p ~/.local/share/godot/templates/ mv /root/.local/share/godot/templates/$GODOT_VERSION.stable ~/.local/share/godot/templates/$GODOT_VERSION.stable - name: Export (Windows) run: | mkdir -p dist/windows/ godot -v --export "Windows Desktop" "dist/windows/$EXPORT_NAME.exe" - name: Export (macOS) run: | mkdir -p dist/mac/ godot -v --export "Mac OSX" "dist/mac/$EXPORT_NAME.zip" - name: Export (Linux) run: | mkdir -p dist/linux/ godot -v --export "Linux/X11" "dist/linux/$EXPORT_NAME.x86_64" - name: Add Version Number to Exports # This action requires the VERSION file to be in the directory run: | cp ./VERSION ./dist/VERSION - name: Upload Artifact uses: actions/upload-artifact@v2.2.3 with: name: exports path: dist # Creating Github release CreateNewGithubRelease: needs: BuildAndPublish if: ${{ contains(github.ref, 'main') }} runs-on: ubuntu-latest steps: - name: Checkout Source Code uses: actions/checkout@v2 with: fetch-depth: 0 - name: Download Exports uses: actions/download-artifact@v2 with: name: exports path: exports - name: Zip Exports run: zip -r exports.zip exports - name: Read Version Number id: version_number uses: juliangruber/read-file-action@v1 with: path: ./VERSION - name: Test Release Variables run: | echo "Version Number $VERSION_NUMBER" echo "Commit Message $COMMIT_MESSAGE" echo "Project Name $PROJECT_NAME" env: VERSION_NUMBER: ${{ steps.version_number.outputs.content }} COMMIT_MESSAGE: ${{ github.event.head_commit.message }} - name: Create New Release uses: actions/create-release@v1 id: create_release env: GITHUB_TOKEN: ${{ secrets.INFINITY_GITHUB_TOKEN }} with: tag_name: ${{ steps.version_number.outputs.content }} release_name: Release ${{ steps.version_number.outputs.content }} body: ${{ github.event.head_commit.message }} draft: false prerelease: false - name: Upload Exports id: upload-release-asset uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.INFINITY_GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: ./exports.zip asset_name: exports.zip asset_content_type: application/zip # Here all the created files being exported to the itch page PushExportsToItch: needs: BuildAndPublish if: ${{ contains(github.ref, 'main') }} runs-on: ubuntu-latest steps: - name: Download Exports uses: actions/download-artifact@v2 with: name: exports path: dist - name: Download + Authorize Butler run: | curl -L -o butler.zip <a href="https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default ">https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default </a> unzip butler.zip chmod +x butler ./butler -V - name: Login To Butler run: ./butler login - name: Push Windows Export To Itch # Here the script adds the version in the VERSION file to the file name run: ./butler push ./dist/windows/$EXPORT_NAME.exe $ITCH_USERNAME/$ITCH_PROJECT_NAME:win --userversion-file ./dist/VERSION - name: Push Mac Export To Itch run: ./butler push ./dist/mac/$EXPORT_NAME.zip $ITCH_USERNAME/$ITCH_PROJECT_NAME:mac --userversion-file ./dist/VERSION - name: Push Linux Export To Itch run: ./butler push ./dist/linux/$EXPORT_NAME.x86_64 $ITCH_USERNAME/$ITCH_PROJECT_NAME:linux --userversion-file ./dist/VERSION # Here we drop a notification in the Discord chat AlertPipelineResult: needs: [BuildAndPublish, CreateNewGithubRelease, PushExportsToItch] if: ${{ always() }} env: DID_PREV_JOBS_SUCCEED: ${{ contains(needs.BuildAndPublish.result, 'success' ) && contains(needs.CreateNewGithubRelease.result, 'success' ) && contains(needs.PushExportsToItch.result, 'success' ) }} runs-on: ubuntu-latest steps: - name: Read VERSION file id: getversion run: echo "::set-output name=version::$(cat dist/VERSION)" - name: Send Discord Success Message if: ${{ env.IS_MAIN && env.DID_PREV_JOBS_SUCCEED == 'true' }} # You can change messages below run: | curl --location --request POST $DISCORD_WEBHOOK \ --header 'Content-Type: application/json' \ --data-raw "{\"content\": \"$ITCH_PROJECT_NAME ${{ steps.getversion.outputs.version }} has successfully released and deployed! Check out here - $ITCH_PROJECT_LINK\"}" - name: Send Discord Failure Message if: ${{ env.IS_MAIN && env.DID_PREV_JOBS_SUCCEED != 'true' }} run: | curl --location --request POST $DISCORD_WEBHOOK \ --header 'Content-Type: application/json' \ --data-raw "{\"content\": \"$ITCH_PROJECT_NAME ${{ steps.getversion.outputs.version }} release and/or deployment has failed!\"}"
Get Тьмоки
Тьмоки
Милый платформер для моей девушки
Status | In development |
Author | Lemonbrush |
Genre | Platformer |
Tags | 2D, Godot, Metroidvania, Pixel Art |
More posts
- Update 1.1.096 days ago
- Release 1.0.0Mar 07, 2024
- Update 1.10.0 BetaDec 19, 2023
- Update 1.9.0 BetaAug 12, 2023
- Update 1.8.0 BetaJun 18, 2023
- Update 1.7.0 AlphaJun 01, 2023
- Update 1.6.0 AlphaApr 17, 2023
- Update 1.5.0 AlphaFeb 05, 2023
- Update 1.4.0 AlphaNov 20, 2022
- Hotfix 1.3.1 AlphaOct 16, 2022
Comments
Log in with itch.io to leave a comment.
GIT is hard thing! It has itw own commands. Pretty hard logic for understanding how it all works. So some help or tool is very nice!
Aw, I haven't thought that someone could see this post. Well, I edited it properly so you could better understand this