Release builds #11
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: Release builds | |
on: | |
workflow_dispatch: | |
inputs: | |
version_name: | |
description: 'Version name (e.g., 0.12.2)' | |
required: true | |
upload_to_itch: | |
description: 'Upload exported files to itch.io?' | |
required: false | |
default: 'true' | |
type: boolean | |
mark_prerelease: | |
description: 'Mark as prerelease' | |
required: true | |
default: 'false' | |
type: boolean | |
jobs: | |
commit-vercode-changes: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
outputs: | |
new_version_code: ${{ steps.prev_version.outputs.new_code }} # Add this to share the output for the release | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GH_TOKEN }} | |
- name: Validate Version in Changelog | |
run: | | |
if ! grep -q "## v${{ inputs.version_name }}" CHANGELOG.md; then | |
echo "Error: Version ${{ inputs.version_name }} not found in CHANGELOG.md" | |
exit 1 | |
fi | |
- name: Get Previous Version Code | |
id: prev_version | |
run: | | |
PREV_CODE=$(grep -o 'version/code=[0-9]*' export_presets.cfg | head -1 | cut -d= -f2) | |
NEW_CODE=$((PREV_CODE + 10)) | |
echo "prev_code=${PREV_CODE}" >> $GITHUB_OUTPUT | |
echo "new_code=${NEW_CODE}" >> $GITHUB_OUTPUT | |
- name: Check Existing Version Code | |
run: | | |
if [ -f "./fastlane/metadata/android/en-US/changelogs/${{ steps.prev_version.outputs.new_code }}.txt" ]; then | |
echo "Error: Version code ${{ steps.prev_version.outputs.new_code }} already exists in metadata" | |
exit 1 | |
fi | |
- name: Extract Changelog | |
run: | | |
mkdir -p ./fastlane/metadata/android/en-US/changelogs | |
sed -n "/## v${{ inputs.version_name }}/,/## v/p" CHANGELOG.md | \ | |
sed '$d' | sed '1s/^## //' > \ | |
"./fastlane/metadata/android/en-US/changelogs/${{ steps.prev_version.outputs.new_code }}.txt" | |
- name: Commit Previous Version Code | |
run: | | |
echo "Previous version code: ${{ steps.prev_version.outputs.prev_code }}" | |
echo "New version code: ${{ steps.prev_version.outputs.new_code }}" | |
VERSION_CODE=${{ steps.prev_version.outputs.new_code }} | |
sed -i "/version\/name=\".*\"/s//version\/name=\"${{ inputs.version_name }}\"/" export_presets.cfg | |
# Update version codes | |
sed -i "0,/version\/code=[0-9]*/s//version\/code=$VERSION_CODE/" export_presets.cfg | |
sed -i "0,/version\/code=[0-9]*/! {0,/version\/code=[0-9]*/s//version\/code=$((VERSION_CODE+1))/}" export_presets.cfg | |
sed -i "$(grep -n 'version/code=' export_presets.cfg | tail -n1 | cut -d: -f1),\$s/version\/code=[0-9]*/version\/code=$((VERSION_CODE+2))/" export_presets.cfg | |
- name: Commit Changes | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git pull | |
git add export_presets.cfg | |
git add ./fastlane/metadata/android/en-US/changelogs/${{ steps.prev_version.outputs.new_code }}.txt | |
git commit -m "Update version to ${{ inputs.version_name }} (${{ steps.prev_version.outputs.new_code }})" | |
git push | |
prepare-and-build: | |
needs: commit-vercode-changes | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
strategy: | |
matrix: | |
platform: ["Windows Desktop", "Linux/X11", "macOS", "Android arm32", "Android arm64", "Linux/X11 arm64", "Android x86 and x86 64", "Web"] | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
# - name: Update Version Info | |
# run: | | |
# sed -i "/version\/name=\".*\"/s//version\/name=\"${{ inputs.version_name }}\"/" export_presets.cfg | |
# sed -i "0,/version\/code=[0-9]*/s//version\/code=${{ inputs.version_code }}/" export_presets.cfg | |
# sed -i "0,/version\/code=[0-9]*/! s/version\/code=[0-9]*/version\/code=$((VERSION_CODE+1))/" export_presets.cfg | |
# sed -i "$(grep -n 'version/code=' export_presets.cfg | tail -n1 | cut -d: -f1),\$s/version\/code=[0-9]*/version\/code=$((VERSION_CODE+2))/" export_presets.cfg | |
# env: | |
# VERSION_CODE: ${{ inputs.version_code }} | |
- name: Build | |
uses: mlm-games/godot-build-action@main | |
with: | |
EXPORT_PRESET_NAME: ${{ matrix.platform }} | |
ITCH_USER_SLASH_GAME: "ragebreaker/asteroids-revenge" | |
BUTLER_CREDENTIALS: ${{ secrets.BUTLER_CREDENTIALS }} | |
RELEASE_KEYSTORE: ${{ secrets.RELEASE_KEYSTORE }} | |
KEYSTORE_PASSPHRASE: ${{ secrets.KEYSTORE_PASSPHRASE }} | |
KEY_ALIAS: ${{ secrets.KEY_ALIAS }} | |
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
BUTLER_UPLOAD: ${{ inputs.upload_to_itch }} | |
- name: Set artifact name and pull latest | |
id: artifact-name | |
shell: bash | |
run: | | |
PLATFORM="${{ matrix.platform }}" | |
SAFE_NAME="${PLATFORM//[^a-zA-Z0-9_]/_}" | |
echo "name=${SAFE_NAME}" >> $GITHUB_OUTPUT | |
git pull | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.artifact-name.outputs.name }}-build | |
path: ${{ github.workspace }}/builds/ | |
- name: Upload to Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: ${{ github.workspace }}/builds/* | |
name: ${{ inputs.version_name }} | |
tag_name: ${{ inputs.version_name }} | |
body_path: ./fastlane/metadata/android/en-US/changelogs/${{ needs.commit-vercode-changes.outputs.new_version_code }}.txt | |
prerelease: ${{ inputs.mark_prerelease }} | |
generate_release_notes: true |