Skip to content

Update publish.yml

Update publish.yml #17

Workflow file for this run

# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: Publish Game
on:
push:
branches:
- feature/workflows
tags:
- '*'
workflow_dispatch:
jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
cache: true
cache-dependency-path: "**/packages.lock.json"
- name: Cache Content directory
uses: actions/cache@v4
with:
path: Logical/bin/Release/net8.0/linux-x64/publish/Content
key: content-${{ hashFiles('Logical/Content/**') }}
restore-keys: |
content-
#- name: Restore dependencies
# run: dotnet restore
- name: Publish
run: dotnet publish -c Release -r linux-x64 -p:PublishReadyToRun=false -p:TieredCompilation=false -p:PublishAot=true --self-contained
- name: Get latest tag
id: get_latest_tag
run: |
git fetch --tags
echo "tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT
- name: Get last commit SHA
id: get_last_commit
run: |
echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Set artifact name
id: set_artifact_suffix
run: |
if [ -n "${{ steps.get_latest_tag.outputs.tag }}" ]; then
echo "suffix=${{ steps.get_latest_tag.outputs.tag }}" >> $GITHUB_OUTPUT
else
echo "suffix=${{ steps.get_last_commit.outputs.sha }}" >> $GITHUB_OUTPUT
fi
- name: Upload
uses: actions/upload-artifact@v4
with:
name: Re-Logical_linux-x64_${{ steps.set_artifact_suffix.outputs.suffix }}
path: Logical/bin/Release/net8.0/linux-x64/publish
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
cache: true
cache-dependency-path: "**/packages.lock.json"
- name: Cache Content directory
uses: actions/cache@v4
with:
path: Logical/bin/Release/net8.0/win-x64/publish/Content
key: content-${{ hashFiles('Logical/Content/**') }}
restore-keys: |
content-
#- name: Restore dependencies
# run: dotnet restore
- name: Publish
run: dotnet publish -c Release -r win-x64 -p:PublishReadyToRun=false -p:TieredCompilation=false -p:PublishAot=true --self-contained
- name: Get latest tag
id: get_latest_tag
run: |
git fetch --tags
echo "tag=$(git describe --tags --abbrev=0 --always)" >> $GITHUB_OUTPUT
- name: Get last commit SHA
id: get_last_commit
run: |
echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Set artifact name
id: set_artifact_suffix
run: |
|
if ($env:steps_get_latest_tag_outputs_tag) {
"suffix=$($env:steps_get_latest_tag_outputs_tag)" | Out-File -FilePath $env:GITHUB_ENV -Append
}
else {
"suffix=$($env:steps_get_last_commit_outputs_sha)" | Out-File -FilePath $env:GITHUB_ENV -Append
}
- name: Debug artifact suffix
run: |
echo "Artifact suffix is: ${{ steps.set_artifact_suffix.outputs.suffix }}"
- name: Upload
uses: actions/upload-artifact@v4
with:
name: Re-Logical_win-x64_${{ steps.set_artifact_suffix.outputs.suffix }}
path: Logical/bin/Release/net8.0/win-x64/publish