Skip to content

Commit

Permalink
feat: add cd
Browse files Browse the repository at this point in the history
  • Loading branch information
florianvazelle committed Sep 17, 2023
1 parent 22d1410 commit b34bb2a
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 16 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 }}
12 changes: 11 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,5 @@ 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=(["windows"]="${{ inputs.name }}.exe" ["linux"]="${{ inputs.name }}.x86_64" ["mac"]="${{ inputs.name }}.zip" ["web"]="index.html")
timeout 60 godot --export-release "${{ inputs.preset }}" --headless ./build/${{ inputs.platform }}/${outputs[${{ inputs.platform }}]} || true
1 change: 1 addition & 0 deletions .github/actions/upload-artifact/action.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

name: Upload artifact
description: Upload artifact.
inputs:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: Release Packaging
name: Build

on:
push:
branches: [main]
branches: [4.x]
tags: ['*']
workflow_dispatch:

jobs:
release-packaging:
build:
runs-on: ubuntu-20.04
timeout-minutes: 30

Expand All @@ -15,42 +16,38 @@ jobs:
matrix:
include:
- platform: windows
output: Greeter.exe
preset: Windows Desktop

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

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

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

name: ${{ matrix.preset }} Export
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Setup Versions Vars
run: |
echo "game_version=$(cat .version)" >> $GITHUB_ENV
echo "godot_version=$(cat .godot_version)" >> $GITHUB_ENV
pip install git+https://github.com/MechanicalFlower/backpack.git
bump_version --version-file .version --cfg-file export_presets.cfg
- name: Ensure version is equal to tag
if: startsWith(github.ref, 'refs/tags/v')
run: |
[ "${{ env.game_version }}" == "$GITHUB_REF_NAME" ] || exit 2
- name: Export Greeter
uses: ./.github/actions/export-game
with:
name: Greeter
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: Greeter-${{ 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 }}/Greeter-${{ 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: greeter
ITCH_USER: mechanical-flower
PACKAGE: dist/${{ matrix.platform }}/Greeter-${{ matrix.platform }}-v$GITHUB_REF_NAME.zip
VERSION: $GITHUB_REF_NAME

0 comments on commit b34bb2a

Please sign in to comment.