Skip to content

Commit

Permalink
feat: improve pipeline to publish release builds (godotjs#170)
Browse files Browse the repository at this point in the history
* feat: improve pipeline to publish release builds

* fix: issues with workflows

* refactor: publish process

* fix: overwrite godot master to 4.1 because the api changed from 4.1->4.2

* fix: issue with wrong version name for release
  • Loading branch information
nmerget authored Oct 9, 2023
1 parent 3d86e6c commit e544bca
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 5 deletions.
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 }}

0 comments on commit e544bca

Please sign in to comment.