Skip to content

Commit

Permalink
ci: add a publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
florianvazelle committed Sep 9, 2023
1 parent 9f31a04 commit 810b718
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 8 deletions.
19 changes: 19 additions & 0 deletions .github/actions/download-artifact/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

name: Download artifact
description: Download artifact.
inputs:
name:
description: The artifact name.
default: "${{ github.job }}"
path:
description: The path to download.
required: true
default: "dist/*"
runs:
using: "composite"
steps:
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: ${{ inputs.name }}
path: ${{ inputs.path }}
18 changes: 17 additions & 1 deletion .github/actions/export-game/action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
name: Export Godot game
description: Export Godot game.
inputs:
name:
description: The game name.
required: true
platform:
description: The game platform.
required: true
type: choice
options:
- windows
- linux
- mac
- web
output:
description: The game output.
required: true
Expand Down Expand Up @@ -46,4 +55,11 @@ runs:
run: |
[ -d build ] && rm -r build
mkdir -v -p build/${{ inputs.platform }}
timeout 60 godot --export-release "${{ inputs.preset }}" --headless ./build/${{ inputs.platform }}/${{ inputs.output }} || true
declare -A outputs
outputs['windows'] = '${{ inputs.name }}.exe'
outputs['linux'] = '${{ inputs.name }}.x86_64'
outputs['mac'] = '${{ inputs.name }}.zip'
outputs['web'] = 'index.html'
timeout 60 godot --export-release "${{ inputs.preset }}" --headless ./build/${{ inputs.platform }}/outputs[${{ inputs.platform }}] || true
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
name: Release Packaging
name: Build

on:
push:
branches: [main]
tags: ['*']
workflow_dispatch:

jobs:
release-packaging:
pre_check:
runs-on: ubuntu-22.04

name: Pre-check
steps:
- name: Ensure version is bump for tag
run: |
game_version=$(cat .version)
if [[ "${{ github.ref }}" =~ ^refs/tags/* ]]; then
echo "A tag is pushed"
[ "$game_version" == "$GITHUB_REF_NAME" ] && echo "The version file is correct" || exit 2
fi
build:
needs: pre_check
runs-on: ubuntu-20.04
timeout-minutes: 30

Expand All @@ -15,19 +30,15 @@ jobs:
matrix:
include:
- platform: windows
output: Marble.exe
preset: Windows Desktop

- platform: linux
output: Marble.x86_64
preset: Linux/X11

# - platform: web
# output: index.html
# preset: Web

- platform: mac
output: Marble.zip
preset: macOS

name: ${{ matrix.preset }} Export
Expand All @@ -43,8 +54,8 @@ jobs:
- name: Export Marble
uses: ./.github/actions/export-game
with:
name: Marble
platform: ${{ matrix.platform }}
output: ${{ matrix.output }}
preset: ${{ matrix.preset }}
version: ${{ env.game_version }}
godot_version: ${{ env.godot_version }}
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Publish

# Only trigger, when the build workflow succeeded
on:
workflow_run:
workflows: ["Build"]
types: [completed]
tags: ['[0-9]+.[0-9]+.[0-9]+']

jobs:
create_release:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-22.04

name: Create Release
steps:
- name: Create Draft release
run: |
gh release create "$GITHUB_REF_NAME" \
--repo="$GITHUB_REPOSITORY" \
--title="v$GITHUB_REF_NAME" \
--draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish:
needs: create_release
runs-on: ubuntu-20.04

strategy:
fail-fast: false
matrix:
include:
- platform: windows
preset: Windows Desktop

- platform: linux
preset: Linux/X11

# - platform: web
# preset: Web

- platform: mac
preset: macOS

name: ${{ matrix.preset }} Publish
steps:
- name: Download artifact
uses: ./.github/actions/upload-artifact
with:
name: Marble-${{ matrix.platform }}-v$GITHUB_REF_NAME
path: dist/${{ matrix.platform }}

- name: Upload to release
run: |
gh release upload "$GITHUB_REF_NAME" \
--repo="$GITHUB_REPOSITORY" \
--clobber \
dist/${{ matrix.platform }}/Marble-${{ matrix.platform }}-v$GITHUB_REF_NAME.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload to itch.io
uses: josephbmanley/[email protected]
env:
BUTLER_CREDENTIALS: ${{ secrets.BUTLER_API_KEY }}
CHANNEL: ${{ matrix.platform }}-v$GITHUB_REF_NAME
ITCH_GAME: marble
ITCH_USER: mechanical-flower
PACKAGE: dist/${{ matrix.platform }}/Marble-${{ matrix.platform }}-v$GITHUB_REF_NAME.zip
VERSION: $GITHUB_REF_NAME

0 comments on commit 810b718

Please sign in to comment.