Skip to content

Commit

Permalink
ci: add github export action
Browse files Browse the repository at this point in the history
  • Loading branch information
bektaskemal committed Jan 16, 2024
1 parent 7943789 commit 23941e6
Show file tree
Hide file tree
Showing 5 changed files with 195 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/build_all.yml
Original file line number Diff line number Diff line change
@@ -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 }}
65 changes: 65 additions & 0 deletions .github/workflows/build_single_preset.yml
Original file line number Diff line number Diff line change
@@ -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"
11 changes: 11 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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
55 changes: 55 additions & 0 deletions .github/workflows/release_all.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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 }}
34 changes: 34 additions & 0 deletions .github/workflows/release_single.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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 }}

0 comments on commit 23941e6

Please sign in to comment.