diff --git a/.github/actions/download-artifact/action.yml b/.github/actions/download-artifact/action.yml new file mode 100644 index 0000000..14b19ce --- /dev/null +++ b/.github/actions/download-artifact/action.yml @@ -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 }} diff --git a/.github/actions/export-game/action.yml b/.github/actions/export-game/action.yml index 2174b6c..c7c8887 100644 --- a/.github/actions/export-game/action.yml +++ b/.github/actions/export-game/action.yml @@ -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 @@ -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 diff --git a/.github/workflows/release-packaging.yml b/.github/workflows/build.yml similarity index 79% rename from .github/workflows/release-packaging.yml rename to .github/workflows/build.yml index a68f0a1..83ffbc6 100644 --- a/.github/workflows/release-packaging.yml +++ b/.github/workflows/build.yml @@ -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 @@ -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 @@ -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 }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..acfeb9e --- /dev/null +++ b/.github/workflows/publish.yml @@ -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/butler-publish-itchio-action@v1.0.3 + 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 \ No newline at end of file