Skip to content

chore(ci): fix upload #64

chore(ci): fix upload

chore(ci): fix upload #64

Workflow file for this run

name: CI
env:
PROJECT_DIR: die-gulde
PROJECT_NAME: die-gulde
PROJECT_FRIENDLY_NAME: Die Gulde
SONAR_PROJECT_KEY: europa1400-community_die-gulde
SONAR_PROJECT_NAME: die-gulde
SONAR_PROJECT_ORGANIZATION: europa1400-community
on:
push:
branches:
- master
pull_request:
types:
- opened
- synchronize
- reopened
workflow_dispatch:
jobs:
test:
name: Test
runs-on: ubuntu-latest
container: unityci/editor:ubuntu-2023.2.18f1-base-3.0.1
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache
uses: actions/cache@v4
with:
path: ${{ env.PROJECT_DIR }}/Library
key: Library-${{ hashFiles('${{ env.PROJECT_DIR }}/Assets/**', '${{ env.PROJECT_DIR }}/Packages/**', '${{ env.PROJECT_DIR }}/ProjectSettings/**') }}
restore-keys: |
Library-
- name: Activate license
run: unity-editor -nographics -logFile /dev/stdout -batchmode -serial ${{ secrets.UNITY_SERIAL }} -username ${{ secrets.UNITY_EMAIL }} -password ${{ secrets.UNITY_PASSWORD }} -quit
- name: Run editor Tests
run: unity-editor -nographics -logFile /dev/stdout -projectPath ${{ env.PROJECT_DIR }} -runTests -testPlatform editmode -testResults Tests/editmode-results.xml -enableCodeCoverage -coverageResultsPath Tests -debugCodeOptimization
timeout-minutes: 30
- name: Run play Tests
run: unity-editor -nographics -logFile /dev/stdout -projectPath ${{ env.PROJECT_DIR }} -runTests -testPlatform playmode -testResults Tests/playmode-results.xml -enableCodeCoverage -coverageResultsPath Tests -debugCodeOptimization
timeout-minutes: 30
- name: Store results
uses: actions/upload-artifact@v4
if: always()
with:
name: Test Results
path: ${{ env.PROJECT_DIR }}/Tests
sonar:
name: SonarCloud
needs: test
runs-on: ubuntu-latest
container: unityci/editor:ubuntu-2023.2.18f1-base-3.0.1
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Cache
uses: actions/cache@v4
with:
path: ${{ env.PROJECT_DIR }}/Library
key: Library-${{ hashFiles('${{ env.PROJECT_DIR }}/Assets/**', '${{ env.PROJECT_DIR }}/Packages/**', '${{ env.PROJECT_DIR }}/ProjectSettings/**') }}
restore-keys: |
Library-
- name: Activate license
run: unity-editor -nographics -logFile /dev/stdout -batchmode -serial ${{ secrets.UNITY_SERIAL }} -username ${{ secrets.UNITY_EMAIL }} -password ${{ secrets.UNITY_PASSWORD }} -quit
- name: Generate Solution
run: unity-editor -nographics -logFile /dev/stdout -projectPath ${{ env.PROJECT_DIR }} -executeMethod Packages.Rider.Editor.RiderScriptEditor.SyncSolution -quit
- name: Setup JDK 11
uses: actions/setup-java@v2
with:
distribution: "adopt"
java-version: "17"
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: "6.0.x"
- name: Install SonarScanner .NET
run: dotnet tool install --tool-path . dotnet-sonarscanner
- name: Download test results
id: test-results
uses: actions/download-artifact@v4
with:
name: Test Results
path: Tests
- name: SonarCloud Scan
env:
FRAMEWORK_PATH: /opt/unity/Editor/Data/MonoBleedingEdge/bin
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
./dotnet-sonarscanner begin \
/k:${{ env.SONAR_PROJECT_KEY }} \
/n:${{ env.SONAR_PROJECT_NAME }} \
/o:${{ env.SONAR_PROJECT_ORGANIZATION }} \
/d:sonar.host.url=https://sonarcloud.io \
/d:sonar.token=${{ secrets.SONAR_TOKEN }} \
/d:sonar.exclusions=${{ env.PROJECT_DIR }}/Assets/Plugins/** \
/d:sonar.scm.provider=git \
/d:sonar.cs.nunit.reportsPaths=Tests/editmode-results.xml,Tests/playmode-results.xml \
/d:sonar.cs.opencover.reportsPaths=Tests/${{ env.PROJECT_NAME }}-opencov/EditMode/TestCoverageResults_0000.xml,Tests/${{ env.PROJECT_NAME }}-opencov/PlayMode/TestCoverageResults_0000.xml,Tests/${{ env.PROJECT_NAME }}-opencov/EditMode/TestCoverageResults_0001.xml,Tests/${{ env.PROJECT_NAME }}-opencov/PlayMode/TestCoverageResults_0001.xml
dotnet build ${{ env.PROJECT_DIR }}/${{ env.PROJECT_NAME }}.sln
./dotnet-sonarscanner end /d:sonar.login=${{ secrets.SONAR_TOKEN }}
version:
name: Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.release-version }}
releaseCreated: ${{ steps.version.outputs.new-release-published }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Calculate version
uses: docker://ghcr.io/codfish/semantic-release-action:latest
id: version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_format: "v${version}"
branches: |
[
'master'
]
dry_run: true
- name: Log outputs
run: |
echo "version: ${{ steps.version.outputs.release-version }}"
echo "releaseCreated: ${{ steps.version.outputs.new-release-published }}"
build:
name: Build
runs-on: ubuntu-latest
needs: version
if: ${{ needs.version.outputs.releaseCreated == 'true' }} || github.event_name == 'workflow_dispatch'
strategy:
matrix:
buildTarget:
["StandaloneWindows64", "StandaloneOSX", "StandaloneLinux64"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache
uses: actions/cache@v4
with:
path: ${{ env.PROJECT_DIR }}/Library
key: Library-${{ hashFiles('${{ env.PROJECT_DIR }}/Assets/**', '${{ env.PROJECT_DIR }}/Packages/**', '${{ env.PROJECT_DIR }}/ProjectSettings/**') }}
restore-keys: |
Library-
- name: Build ${{ matrix.buildTarget }}
uses: game-ci/unity-builder@v4
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
targetPlatform: ${{ matrix.buildTarget }}
projectPath: ${{ env.PROJECT_DIR }}
buildName: ${{ env.PROJECT_NAME }}
buildsPath: Builds
versioning: Custom
version: ${{ needs.version.outputs.version }}
- name: Move build
run: |
ls -la
ls -la Builds
ls -la Builds/${{ matrix.buildTarget }}
sudo mv Builds/${{ matrix.buildTarget }} ${{ env.PROJECT_NAME }}-${{ matrix.buildTarget }}
- name: Upload build
uses: actions/upload-artifact@v4
with:
name: ${{ env.PROJECT_NAME }}-${{ matrix.buildTarget }}
path: ${{ env.PROJECT_NAME }}-${{ matrix.buildTarget }}
release:
name: Release
runs-on: ubuntu-latest
needs: build
outputs:
releaseCreated: ${{ steps.release.outputs.new-release-published }}
uploadUrl: ${{ steps.getUploadUrl.outputs.uploadUrl }}
version: ${{ steps.release.outputs.release-version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create release
uses: docker://ghcr.io/codfish/semantic-release-action:latest
id: release
with:
tag_format: "v${version}"
branches: |
[
'master'
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get upload URL
if: ${{ steps.release.outputs.new-release-published == 'true' }}
id: getUploadUrl
env:
VERSION: ${{ steps.release.outputs.release-version }}
run: |
echo "getting upload url for release $VERSION with tag v$VERSION"
uploadUrl=$(curl -sL https://api.github.com/repos/${{ github.repository }}/releases/tags/v$VERSION | jq -r '.upload_url')
echo uploadUrl=$uploadUrl >> $GITHUB_OUTPUT
upload:
name: Upload
runs-on: ubuntu-latest
needs: [build, release]
if: ${{ needs.release.outputs.releaseCreated == 'true' }}
strategy:
matrix:
buildTarget:
["StandaloneWindows64", "StandaloneOSX", "StandaloneLinux64"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download build
uses: actions/download-artifact@v4
with:
name: ${{ env.PROJECT_NAME }}-${{ matrix.buildTarget }}
path: ${{ env.PROJECT_NAME }}-${{ matrix.buildTarget }}
- name: Zip build
run: |
zip -r ${{ env.PROJECT_NAME }}-${{ matrix.buildTarget }}.zip ${{ env.PROJECT_NAME }}-${{ matrix.buildTarget }}/*
- name: Upload build
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.uploadUrl }}
asset_path: ${{ env.PROJECT_NAME }}-${{ matrix.buildTarget }}.zip
asset_name: ${{ env.PROJECT_NAME }}-${{ matrix.buildTarget }}.zip
asset_content_type: application/zip