Upload Plugin to Godot Asset Library #44
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
# This workflow will upload a Godot Asset to the Asset Library | |
# everytime a tag is pushed or a release is published. | |
name: Upload Plugin to Godot Asset Library | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
push: | |
tags: | |
- 'godot-dice-roller-[0-9]+.[0-9]+.[0-9]+' | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
name: Publish new version to asset lib | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: 3 | |
- name: Install dependencies | |
run: | | |
sudo apt install jq jc | |
# NOT WORKING: godot project is not a ini file as jc understands it | |
- name: Extract Godot project info | |
if: false | |
shell: bash | |
run: | | |
project_var() { | |
cat project.godot | jc --ini | jq "$1" | |
} | |
single_line_var() { | |
echo "$1='$2'" >> "$GITHUB_ENV" | |
} | |
multi_line_var() { | |
printf "$1=\$(cat <<EOF\n%s\nEOF\n)\n" "$2" >> "$GITHUB_ENV" | |
} | |
branch=${{ github.ref_name }} | |
repo=${{ github.repository }} | |
name=$(project_var '.application.["config/name"]') | |
description=$(project_var '.application.["config/description"]') | |
version=$(project_var '.application.["config/version"]') | |
icon=$(project_var '.application.["config/icon"]') | |
icon="https://raw.githubusercontent.com/${repo}/refs/heads/${branch}/$(echo \"$icon\" | sed s.res://..)" | |
godot_version=$project_var 'application.["config/features"]' | sed 's/PackedStringArray("\([0-9.]+\).*/\\1' | |
single_line_var PROJECT_TITLE "$name" | |
single_line_var PROJECT_DESCRIPTION "$description" | |
single_line_var PROJECT_VERSION "$version" | |
single_line_var PROJECT_ICON "$icon" | |
cat "$GITHUB_ENV" | |
- name: Extract Godot project info (using Godot itself) | |
shell: bash | |
run: | | |
branch=${{ github.ref_name }} | |
repo=${{ github.repository }} | |
wget https://github.com/godotengine/godot/releases/download/4.3-stable/Godot_v4.3-stable_linux.x86_64.zip | |
unzip Godot_v4.3-stable_linux.x86_64.zip | |
# use tail to remove Godot banner from output | |
(./Godot_v4.3-stable_linux.x86_64 --display-driver headless --audio-driver Dummy --quit -s ./tools/project2bashvars.gd | tail -n +3) >> $GITHUB_ENV | |
source <(cat $GITHUB_ENV | grep PROJECT_ICON) | |
single_line_var() { | |
echo "$1=$2" >> "$GITHUB_ENV" | |
} | |
icon="https://raw.githubusercontent.com/${repo}/refs/heads/main/$(echo "$PROJECT_ICON" | sed s.res://..)" | |
single_line_var PROJECT_ICON "$icon" | |
description=$(cat README.md CHANGES.md | sed 's/$/\\n/' | tr -d '\n') | |
single_line_var PROJECT_DESCRIPTION "${description}" | |
echo "Results of data extraction:" | |
cat "$GITHUB_ENV" | |
- name: Godot Asset Lib (based on external action) | |
if: false | |
uses: deep-entertainment/godot-asset-lib-action@main | |
with: | |
username: ${{ secrets.ASSET_STORE_USER }} | |
password: ${{ secrets.ASSET_STORE_PASSWORD }} | |
assetId: ${{ secrets.ASSET_STORE_ASSET_ID }} | |
assetTemplate: tools/.asset-template.json.hb | |
- name: Godot Asset Lib (based on my script) | |
shell: bash | |
run: | | |
echo "ASSET_STORE_USER=${{ secrets.ASSET_STORE_USER }}" >> .env | |
echo "ASSET_STORE_PASSWORD=${{ secrets.ASSET_STORE_PASSWORD }}" >> .env | |
pip install requests python-dotenv pyyaml | |
python tools/godot-asset-lib.py | |
# vim: et sw=2 ts=2 |