Merge pull request #466 from PiotrKaszuba/fix-issue-457 #1090
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-and-publish | |
# NOTE: disabled this export job because it doesn't work | |
# with webrtc lib. Webrtc lib files need to be included | |
# together with the game but this job for some reason fails | |
# to do it. It only adds executable and .pck file to the | |
# zip. | |
# on: | |
# push: | |
# # Sequence of patterns matched against refs/heads | |
# # branches: | |
# # - workflow* | |
# # Sequence of patterns matched against refs/tags | |
# tags: | |
# - v* | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
name: cache repo with assets | |
steps: | |
- uses: actions/checkout@v3 | |
- name: list assets in gdrive | |
uses: wei/rclone@v1 | |
with: | |
args: lsf -R --filter-from rclone-filter "assets" | sort > .assets-list | |
env: | |
RCLONE_CONF: ${{ secrets.RCLONE_GDRIVE_CONF }} | |
- name: restore cache | |
uses: actions/cache@v3 | |
with: | |
path: assets | |
key: assets-${{ hashFiles('.assets-list') }} | |
- name: sync assets from gdrive via rclone | |
uses: wei/rclone@v1 | |
with: | |
args: sync -P --filter-from rclone-filter "gdrive:assets" "assets" | |
env: | |
RCLONE_CONF: ${{ secrets.RCLONE_GDRIVE_CONF }} | |
- name: upload repo with assets | |
id: upload_repo_with_assets | |
uses: actions/upload-artifact@v3 | |
with: | |
path: | | |
./* | |
!.git/ | |
name: repo-with-assets | |
- name: generate version for the build | |
id: version_generation | |
run: | | |
latest_tag=$(git ls-remote --tags --sort=-v:refname origin | grep -v 'vrefs/heads/main' | grep -o 'refs/tags/[^^{]*' | sed 's/refs\/tags\///' | head -n 1) | |
short_hash=$(git rev-parse --short HEAD) | |
version=${latest_tag:1} | |
echo "tag_version=${latest_tag}-${short_hash}" | tee -a $GITHUB_OUTPUT | |
echo "version=${version}" | tee -a $GITHUB_OUTPUT | |
echo "commit_ref=$GITHUB_REF_NAME" | tee -a $GITHUB_OUTPUT | |
outputs: | |
tag_version: ${{ steps.version_generation.outputs.tag_version }} | |
version: ${{ steps.version_generation.outputs.version }} | |
commit_ref: ${{ steps.version_generation.outputs.commit_ref }} | |
export_game: | |
runs-on: ubuntu-latest | |
needs: setup | |
name: export game | |
steps: | |
- name: download repo with assets | |
uses: actions/download-artifact@v3 | |
with: | |
path: ./ | |
name: repo-with-assets | |
- name: release requested check | |
run: | | |
if [[ ${{ needs.setup.outputs.commit_ref }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] ; then | |
echo "NEED=true" >> "$GITHUB_ENV" | |
echo 'true' | |
else | |
echo "NEED=false" >> "$GITHUB_ENV" | |
echo 'false' | |
fi | |
- name: update project.godot with new version | |
run: | | |
project_godot_file="${{ github.workspace }}/project.godot" | |
sed -i 's/\(config\/version="\).*\("\)/\1'"${{ needs.setup.outputs.tag_version }}"'\2/' "${project_godot_file}" | |
echo "New project.godot contents:" | |
cat "${project_godot_file}" | |
- name: update release version for Sentry lib | |
run: | | |
sed -i "s/youtd2@[0-9]\+\.[0-9]\+\.[0-9]\+/youtd2@${{ needs.setup.outputs.version }}/g" "${{ github.workspace }}/build/web/full-size.html" | |
- name: create .godot dirs | |
run: | | |
mkdir -p .godot/{editor,imported} | |
- name: export game | |
id: export | |
uses: firebelley/[email protected] | |
with: | |
godot_executable_download_url: https://github.com/godotengine/godot-builds/releases/download/4.1.3-stable/Godot_v4.1.3-stable_linux.x86_64.zip | |
godot_export_templates_download_url: https://github.com/godotengine/godot-builds/releases/download/4.1.3-stable/Godot_v4.1.3-stable_export_templates.tpz | |
relative_project_path: ./ | |
export_debug: false | |
archive_output: true | |
cache: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: repack web artifact | |
run: | | |
zip -uj ${{ steps.export.outputs.archive_directory }}/web.zip ${{ github.workspace }}/build/web/* | |
cp ${{ github.workspace }}/build/web/* ${{ steps.export.outputs.build_directory }}/web/ | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: youtd-${{ needs.setup.outputs.tag_version }} | |
path: ${{ steps.export.outputs.archive_directory }}/*.zip | |
if-no-files-found: error | |
outputs: | |
tag_version: ${{ needs.setup.outputs.tag_version }} | |
commit_ref: ${{ needs.setup.outputs.commit_ref }} | |
release_flag: ${{ env.NEED }} | |
upload_artifacts: | |
needs: export_game | |
strategy: | |
matrix: | |
platform: [windows, macos, web, linux] | |
runs-on: ubuntu-latest | |
steps: | |
- name: download exported files | |
uses: actions/download-artifact@v3 | |
with: | |
name: youtd-${{ needs.export_game.outputs.tag_version }} | |
path: exported_files | |
- name: rename artifacts | |
id: rename_artifacts | |
run: | | |
VERSION_TAG="${{ needs.export_game.outputs.tag_version }}" | |
mv "exported_files/${{ matrix.platform }}.zip" "exported_files/${{ matrix.platform }}-$VERSION_TAG.zip" | |
echo "${{ matrix.platform }}=exported_files/$platform-$VERSION_TAG.zip" >> $GITHUB_OUTPUT | |
- name: upload artifacts | |
id: upload_artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.platform }}-${{ needs.export_game.outputs.tag_version }} | |
path: exported_files/${{ matrix.platform }}-${{ needs.export_game.outputs.tag_version }}.zip | |
outputs: | |
macos_artifact: ${{ steps.rename_artifacts.outputs.macos_artifact }} | |
linux_artifact: ${{ steps.rename_artifacts.outputs.linux_artifact }} | |
web_artifact: ${{ steps.rename_artifacts.outputs.web_artifact }} | |
windows_artifact: ${{ steps.rename_artifacts.outputs.windows_artifact }} | |
create_release: | |
name: create release | |
needs: [upload_artifacts, export_game] | |
if: needs.export_game.outputs.release_flag == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: show props | |
run: | | |
echo "Commit ref: $GITHUB_REF_NAME" | |
echo "Release tag: ${{ needs.export_game.outputs.commit_ref }}" | |
- name: download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: . | |
- name: display structure of downloaded files | |
run: ls -R | |
working-directory: . | |
- name: release client | |
uses: ncipollo/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ needs.export_game.outputs.commit_ref }} | |
generateReleaseNotes: true | |
artifacts: ./**/*.zip | |
clean_up_artifacts: | |
needs: [create_release, export_game] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: geekyeggo/delete-artifact@v2 | |
with: | |
name: | | |
youtd-${{ needs.export_game.outputs.tag_version }} | |
repo-with-assets |