From 23941e655bd1bfcf0a59b49046ffff0215ea76a3 Mon Sep 17 00:00:00 2001 From: Kemal Bektas Date: Tue, 16 Jan 2024 22:11:18 +0100 Subject: [PATCH] ci: add github export action --- .github/workflows/build_all.yml | 30 +++++++++++ .github/workflows/build_single_preset.yml | 65 +++++++++++++++++++++++ .github/workflows/main.yml | 11 ++++ .github/workflows/release_all.yml | 55 +++++++++++++++++++ .github/workflows/release_single.yml | 34 ++++++++++++ 5 files changed, 195 insertions(+) create mode 100644 .github/workflows/build_all.yml create mode 100644 .github/workflows/build_single_preset.yml create mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/release_all.yml create mode 100644 .github/workflows/release_single.yml diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml new file mode 100644 index 0000000..ebd28be --- /dev/null +++ b/.github/workflows/build_all.yml @@ -0,0 +1,30 @@ +name: Build all presets + +on: + # Used when triggering this workflow from another workflow + workflow_call: + inputs: + debug-mode: + description: "Whether to export the preset in debug mode. Defaults to false" + required: false + type: boolean + default: false + +jobs: + build_all: + name: Build all presets + strategy: + matrix: + platform: + - godot-export-preset: "Linux/X11" + file-extension: zip + - godot-export-preset: "Web" + file-extension: zip + - godot-export-preset: "Windows Desktop" + file-extension: exe + + uses: ./.github/workflows/build_single_preset.yml + with: + godot-export-preset: ${{ matrix.platform.godot-export-preset }} + file-extension: ${{ matrix.platform.file-extension }} + debug-mode: ${{ inputs.debug-mode }} \ No newline at end of file diff --git a/.github/workflows/build_single_preset.yml b/.github/workflows/build_single_preset.yml new file mode 100644 index 0000000..28e5d81 --- /dev/null +++ b/.github/workflows/build_single_preset.yml @@ -0,0 +1,65 @@ +name: Build one specific preset + +on: + # Used when triggering this workflow from another workflow + workflow_call: + inputs: + debug-mode: + description: "Whether to export the preset in debug mode. Defaults to true" + required: false + type: boolean + default: true + export-file-name: + description: "Name of the file that will be generated from the export" + required: false + type: string + default: ${{ vars.ARTIFACT_NAME }} + file-extension: + description: "Extension to export to" + required: true + type: string + godot-export-preset: + description: "Name of the Godot export preset to use to export the project" + required: true + type: string + outputs: + artifact-name: + description: "Name of the uploaded artifact" + value: ${{ jobs.build.outputs.artifact-name }} + +env: + GODOT_VERSION: 4.2.1 + +jobs: + build: + name: ${{ inputs.godot-export-preset }} + runs-on: ubuntu-latest + container: + image: barichello/godot-ci:4.2.1 + outputs: + artifact-name: ${{ steps.add-artifact-name.outputs.artifact-name }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup + run: | + mkdir -v -p ~/.local/share/godot/export_templates + mv /root/.local/share/godot/templates/${GODOT_VERSION}.stable ~/.local/share/godot/export_templates/${GODOT_VERSION}.stable + + - name: Build ${{ inputs.godot-export-preset }} + run: | + mkdir -v -p build/${{ inputs.godot-export-preset }} + godot --headless --verbose --export-release "${{ inputs.godot-export-preset }}" ./build/${{ inputs.godot-export-preset }}/${{ inputs.export-file-name }}.zip + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ vars.ARTIFACT_NAME }}-${{ inputs.godot-export-preset }}-${{ github.sha }} + path: ./build/${{ inputs.godot-export-preset }} + if-no-files-found: error + + - name: Add artifact name to output + id: add-artifact-name + run: echo "artifact-name=${{ vars.ARTIFACT_NAME }}-${{ inputs.godot-export-preset }}-${{ github.sha }}" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..3ceb48a --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,11 @@ +name: Release to production + +on: + push + +jobs: + build_all: + name: Build + uses: ./.github/workflows/build_all.yml + with: + debug-mode: false \ No newline at end of file diff --git a/.github/workflows/release_all.yml b/.github/workflows/release_all.yml new file mode 100644 index 0000000..206e445 --- /dev/null +++ b/.github/workflows/release_all.yml @@ -0,0 +1,55 @@ +name: Release an artifact + +on: + # Used when triggering this workflow from another workflow + workflow_call: + inputs: + web-artifact-name: + required: true + type: string + linux-artifact-name: + required: true + type: string + windows-artifact-name: + required: true + type: string + +jobs: + release_to_itch: + name: ${{ inputs.release-channel }} + runs-on: ubuntu-latest + + steps: + - uses: actions/download-artifact@v4 + id: download-artifact + name: Download artifact to release + with: + name: ${{ inputs.artifact-name }} + + - uses: manleydev/butler-publish-itchio-action@v1.0.3 + name: Upload artifact to Itch.io ${{ inputs.release-channel }} channel + env: + BUTLER_CREDENTIALS: ${{ secrets.BUTLER_CREDENTIALS }} + CHANNEL: ${{ inputs.release-channel }} + ITCH_GAME: ${{ secrets.ITCH_GAME }} + ITCH_USER: ${{ secrets.ITCH_USER }} + PACKAGE: ${{ steps.download-artifact.outputs.download-path }} + VERSION: ${{ github.ref_name }} + +jobs: + release_all: + name: Release all artifacts + strategy: + matrix: + platform: + - release-channel: web-production + artifact-name: ${{ inputs.web-artifact-name }} + - release-channel: linux-production + artifact-name: ${{ inputs.linux-artifact-name }} + - release-channel: windows-production + artifact-name: ${{ inputs.windows-artifact-name }} + + uses: ./.github/workflows/release_single.yml + with: + release-channel: ${{ matrix.platform.release-channel }} + artifact-name: ${{ matrix.platform.artifact-name }} \ No newline at end of file diff --git a/.github/workflows/release_single.yml b/.github/workflows/release_single.yml new file mode 100644 index 0000000..f979e77 --- /dev/null +++ b/.github/workflows/release_single.yml @@ -0,0 +1,34 @@ +name: Release an artifact + +on: + # Used when triggering this workflow from another workflow + workflow_call: + inputs: + release-channel: + required: true + type: string + artifact-name: + required: true + type: string + +jobs: + release_to_itch: + name: ${{ inputs.release-channel }} + runs-on: ubuntu-latest + + steps: + - uses: actions/download-artifact@v4 + id: download-artifact + name: Download artifact to release + with: + name: ${{ inputs.artifact-name }} + + - uses: manleydev/butler-publish-itchio-action@v1.0.3 + name: Upload artifact to Itch.io ${{ inputs.release-channel }} channel + env: + BUTLER_CREDENTIALS: ${{ secrets.BUTLER_CREDENTIALS }} + CHANNEL: ${{ inputs.release-channel }} + ITCH_GAME: ${{ secrets.ITCH_GAME }} + ITCH_USER: ${{ secrets.ITCH_USER }} + PACKAGE: ${{ steps.download-artifact.outputs.download-path }} + VERSION: ${{ github.ref_name }} \ No newline at end of file