Create Release #47
Workflow file for this run
This file contains hidden or 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: Create Release | |
on: | |
workflow_dispatch: | |
branches: | |
- master | |
- marc-changelog-update | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
max-parallel: 1 | |
matrix: | |
unityVersion: | |
# - 2019.4.40f1 | |
# - 2020.3.48f1 | |
# - 2021.3.31f1 | |
- 2022.3.61f1 | |
platform: | |
- WebGL | |
# - Android | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
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/Runtime/Settings.cs) | |
echo "Extracted version: $version" | |
echo "version=$version" >> $GITHUB_ENV | |
- name: Validate Version | |
run: | | |
if [[ ! "${{ env.version }}" =~ ^[0-9]+\.[0-9]+$ ]]; then | |
echo "Invalid version format. Must be MAJOR.MINOR" | |
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@v3 | |
with: | |
path: Library | |
key: Library-AUP-${{ matrix.platform }} | |
restore-keys: | | |
Library-AUP- | |
Library- | |
- name: Test ${{ matrix.platform }} in ${{ matrix.unityVersion }} | |
uses: game-ci/unity-builder@v3 | |
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: 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@v1 | |
with: | |
changelog_file: CHANGELOG.md | |
- name: Log Release Notes | |
run: echo "Release Notes are ${{ steps.extract-release-notes.outputs.release_notes }}" | |
- name: Generate unitypackage release | |
uses: game-ci/unity-builder@v3 | |
env: | |
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} | |
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | |
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | |
if: matrix.platform == 'WebGL' && matrix.unityVersion == '2019.4.40f1' | |
with: | |
unityVersion: ${{ matrix.unityVersion }} | |
targetPlatform: ${{ matrix.platform }} | |
buildMethod: NDream.Unity.Builder.Build${{ matrix.platform }} | |
allowDirtyBuild: true | |
# - name: Generate Release unity package | |
# run: | | |
# unity -quit -batchmode -executeMethod NDream.Unity.Packager.Export -projectPath . # -outputPath Builds/release-${{ github.event.inputs.version }}.unitypackage | |
# Return License | |
- name: Return license | |
uses: game-ci/unity-return-license@v2 | |
if: always() | |
- name: Validate release package | |
if: matrix.platform == 'WebGL' && matrix.unityVersion == '2019.4.40f1' | |
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 }} |