Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve pipeline to publish release builds #170

Merged
merged 5 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/get_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ name: 🆚 Get godot version

on:
workflow_call:
# Map the workflow outputs to job outputs
outputs:
version:
description: "Which version we should use based on target branch"
value: ${{ jobs.version.outputs.version }}

# We use a godot tag(rc version) as default version for master
# because the api is changing often and this would lead to a lot of struggle
env:
MASTER_VERSION: 4.1

jobs:
version:
name: Get godot version
Expand All @@ -18,13 +22,15 @@ jobs:
steps:
- name: 🏷 Get and set godot version
id: version
# TODO: GH-Action should extract target branch; branches should be named according to godot engine branches
run: |
VERSION="4.1"
VERSION="${{ github.event.pull_request.base.ref || github.base_ref || github.event.release.target_commitish }}"
if [[ $VERSION == "master" ]]; then
VERSION="$MASTER_VERSION"
echo "We are overwrite master to latest rc version: $VERSION"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT

- name: 🌳 Log Valid Version
env:
VERSION: ${{ steps.version.outputs.version }}
run: echo "$VERSION"

85 changes: 85 additions & 0 deletions .github/workflows/release_builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: 🦅 Release Builds
on:
workflow_call:
inputs:
version:
required: true
type: string

concurrency:
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-android
cancel-in-progress: true

permissions:
contents: write

jobs:
rename:
runs-on: ubuntu-latest
steps:
- name: ⏬ Checkout repo
uses: actions/checkout@v4

- name: 📛 Add version to release name
uses: actions/github-script@v6
with:
result-encoding: json
script: |
const { repo, owner } = context.repo;
const date = new Date();
const year = date.getFullYear().toString();
const month = (date.getMonth() + 1).toString().padStart(2,"0");
const day = (date.getDay() + 1).toString().padStart(2,"0");
await github.rest.repos.updateRelease({
owner,
repo,
release_id: context.payload.release.id,
name: '${{ inputs.version }}-' + context.payload.release.name + '-' + year + month + day,
});

release:
runs-on: ubuntu-latest
name: ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
name:
- android-template
- ios-template
- linux-editor-mono
- linux-template-minimal
- linux-template-mono
- macos-editor
- macos-template
- web-template
- windows-editor
- windows-template
steps:
- name: ⏬ Checkout repo
uses: actions/checkout@v4

- name: ⏬ Download build
uses: actions/download-artifact@v3
with:
name: ${{ matrix.name }}
path: ${{ matrix.name }}

- name: 📦 Pack build as zip
run: zip -r ${{ matrix.name }}.zip ${{ matrix.name }}
shell: bash

- name: ⏫ Upload Release Asset
id: upload-release-asset
uses: actions/github-script@v6
with:
result-encoding: json
script: |
const FS = require('node:fs')
const { repo, owner } = context.repo;
return await github.rest.repos.uploadReleaseAsset({
owner,
repo,
release_id: context.payload.release.id,
name: '${{ matrix.name }}.zip',
data: FS.readFileSync('${{ github.workspace }}/${{ matrix.name }}.zip')
});
60 changes: 59 additions & 1 deletion .github/workflows/runner.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
name: 🔗 GHA
on: [push, pull_request]

# Only run pipeline on open pull_requests and master + versions + releases
# we don't need it on every push and some parameters are not available for push only
on:
pull_request:
push:
branches:
- "master"
- "3.4"
- "4.1"
release:
types: [published]

concurrency:
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-runner
Expand Down Expand Up @@ -58,3 +69,50 @@ jobs:
uses: ./.github/workflows/web_builds.yml
with:
version: ${{ needs.get-version.outputs.version }}

checks-done:
if: ${{ always() }}
name: ✅ Check builds
runs-on: ubuntu-latest
steps:
- name: 🎉 Checks done
run: |
resultWebBuild="${{ needs.web-build.result }}"
resultWindowsBuild="${{ needs.windows-build.result }}"
resultMacosBuild="${{ needs.macos-build.result }}"
resultLinuxBuild="${{ needs.linux-build.result }}"
resultIosBuild="${{ needs.ios-build.result }}"
resultAndroidBuild="${{ needs.android-build.result }}"
if [[
$resultWebBuild == "success" &&
$resultWindowsBuild == "success" &&
$resultMacosBuild == "success" &&
$resultLinuxBuild == "success" &&
$resultIosBuild == "success" &&
$resultAndroidBuild == "success"
]];
then
echo "🎉 All builds were successful."
exit 0
else
echo "😥 Some builds were failing."
exit 1
fi
needs:
[
web-build,
windows-build,
macos-build,
linux-build,
ios-build,
android-build
]

release:
name: 🦅 Release
if: github.event_name == 'release' && github.event.action == 'published'
needs: [checks-done]
uses: ./.github/workflows/release_builds.yml
secrets: inherit
with:
version: ${{ needs.get-version.outputs.version }}
Loading