Skip to content

WIP2

WIP2 #45

name: Create Release
on:
push:
# branches:
# - 'master'
# tags:
# - 'v[0-9].[0-9].[0-9](.[0-9])+'
env:
LOWEST_UNITY_VERSION: 2019.4.40f1
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: true
max-parallel: 10
matrix:
unityVersion:
- 2019.4.40f1
- 2020.3.48f1
- 2021.3.45f1
- 2022.3.51f1
- 6000.0.24f1
platform:
- WebGL
- Android
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- name: Extract Version from C# File
id: extract_version
run: |
version=$(grep -oP 'public const string VERSION = "\K[^"]+' Assets/AirConsole/scripts/Settings.cs)
echo "Extracted version: $version"
echo "version=$version" >> $GITHUB_ENV
- name: Validate Version
run: |
if [[ ! "${{ env.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version format. Must be MAJOR.MINOR.PATCH"
exit 1
fi
- name: Check GitHub Releases
id: check_release
run: |
# Fetch releases from GitHub API
releases=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/airconsole/airconsole-unity-plugin/releases")
# Check if a release with the extracted version exists
exists=$(echo "$releases" | jq -r --arg version "v${{ env.version }}" '.[] | select(.tag_name == $version) | .tag_name')
if [[ -n "$exists" ]]; then
echo "Release with version v${{ env.version }} already exists."
exit 1
else
echo "No release with version v${{ env.version }} found."
fi
- uses: actions/cache@v4
with:
path: Library
key: Library-${{ matrix.platform }}-${{ matrix.unityVersion }}
restore-keys: |
Library-${{ matrix.platform }}-${{ matrix.unityVersion }}
# - name: Cache Packages
# uses: actions/cache@v4
# with:
# path: $HOME/.cache/unity3d/packages
# key: Packages-${{ hashFiles('Packages/packages-lock.json') }}-${{ matrix.unityVersion }}
# restore-keys: |
# Packages-${{ hashFiles('Packages/packages-lock.json') }}-${{ matrix.unityVersion }}
# - name: Cache Packages
# uses: actions/cache@v4
# with:
# path: /var/lib/docker/
# key: Docker-Images-${{ matrix.platform }}-${{ matrix.unityVersion }}
# restore-keys: |
# Docker-Images-${{ matrix.platform }}-${{ matrix.unityVersion }}
# - name: Cleanup Docker
# run: |
# docker system prune -af --volumes
# - name: Test ${{ matrix.platform }} in ${{ matrix.unityVersion }}
# uses: game-ci/unity-test-runner@v4
# env:
# UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
# UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
# UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
# with:
# githubToken: ${{ secrets.GITHUB_TOKEN }}
# unityVersion: ${{ matrix.unityVersion }}
# - name: Validate Build
# run: |
# filepath="Builds/${{ matrix.platform }}/release-${{ matrix.unityVersion }}-v${{ env.version }}"
# if [ "${{ matrix.platform }}" == "Android" ]; then
# filepath+=".apk"
# elif [ "${{ matrix.platform }}" == "WebGL" ]; then
# filepath+=".zip"
# fi
# if [ ! -f "$filepath" ]; then
# echo "Build validation failed for ${{ matrix.platform }}"
# exit 1
# fi
- name: Extract release notes
id: extract-release-notes
uses: ffurrer2/extract-release-notes@v2
with:
changelog_file: CHANGELOG.md
prerelease: true
- name: Log Release Notes
run: echo "Release Notes are ${{ steps.extract-release-notes.outputs.release_notes }}\nUnity Version ${{matrix.unityVersion}} == ${{env.LOWEST_UNITY_VERSION}}"
- name: Build project for ${{ matrix.platform }} in ${{ matrix.unityVersion }}
uses: game-ci/unity-builder@v4
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
unityVersion: ${{ matrix.unityVersion }}
targetPlatform: ${{ matrix.platform }}
buildMethod: NDream.Unity.Builder.Build${{ matrix.platform }}
allowDirtyBuild: true
- name: Generate package if ${{ matrix.platform }} is WebGL and Unity version is ${{ env.LOWEST_UNITY_VERSION }}
if: matrix.platform == 'WebGL' && matrix.unityVersion == ${{ env.LOWEST_UNITY_VERSION }}
uses: game-ci/unity-builder@v4
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
unityVersion: ${{ matrix.unityVersion }}
targetPlatform: ${{ matrix.platform }}
buildMethod: NDream.Unity.Packager.Export
allowDirtyBuild: true
# Return License
- name: Return license
uses: game-ci/unity-return-license@v2
if: always()
- name: Validate release package
if: matrix.platform == 'WebGL' && matrix.unityVersion == ${{ env.LOWEST_UNITY_VERSION }}
run: |
filepath="Builds/airconsole-unity-plugin-v${{ env.version }}.unitypackage"
if [ ! -f "$filepath" ]; then
echo "Build validation of airconsole-unity-plugin-v${{ env.version }}unitypackage failed"
exit 1
fi
# - name: Commit and Push
# run: |
# git config user.name "GitHub Actions"
# git config user.email "[email protected]"
# git commit -m "e: Update Release package to v${{ env.version }}"
# git push
# - name: Create GitHub Release
# uses: softprops/action-gh-release@v1
# if: startsWith(github.ref, 'refs/tags/')
# with:
# files: Builds/release-${{ github.event.inputs.version }}.unitypackage
# body: ${{ steps.extract-release-notes.outputs.release_notes }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}