Skip to content

Commit

Permalink
ci: (wip) build automcatically C# binaries
Browse files Browse the repository at this point in the history
The workflow is for now triggered on every commit. We will detect the C# changes later down the line.
  • Loading branch information
JoeFwd committed Jun 20, 2024
1 parent 6032313 commit 7cd6d5f
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 1 deletion.
106 changes: 106 additions & 0 deletions .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Build Binaries

on:
push:
branches:
- develop
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Restore dependencies
run: dotnet restore src/DellarteDellaGuerra.sln

- name: Build solution
run: |
artifact=$(pwd)/artifact
mkdir -p $artifact
dotnet build src/DellarteDellaGuerra.sln --configuration Release -p:GameFolder="$artifact"
- name: Compress Artifact
run: |
7z a -t7z artifact.7z ./artifact/* -mx9
- name: Install Bannerlord.ChangelogParser
run: dotnet tool install -g Bannerlord.ChangelogParser
shell: pwsh

- name: Set Version
id: set_version
run: |
vers=$(bannerlord_changelog_parser latestversion -f "src/changelog.txt")
echo "::set-output name=mod_version::$vers"
- name: Set Description
id: set_description
run: |
desc=$(bannerlord_changelog_parser fulldescription -f "src/changelog.txt")
desc="${desc//'%'/'%25'}"
desc="${desc//$'"'/'%22'}"
desc="${desc//$'\n'/'%0A'}"
desc="${desc//$'\r'/'%0D'}"
echo "::set-output name=mod_description::$desc"
- name: Get branch name
id: get_branch
run: |
branch_name=${GITHUB_REF#refs/heads/}
echo "Branch name is: $branch_name"
echo "::set-output name=branch_name::$branch_name"
- name: Check for existing release
id: check_release
run: |
TAG=latest-${{ steps.get_branch.outputs.branch_name }}-bin
RELEASE_ID=$(curl -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG" | jq '.id' || echo "none")
echo "release_id=$RELEASE_ID" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Delete existing release if any
if: env.release_id != 'none'
run: |
TAG=latest-${{ steps.get_branch.outputs.branch_name }}-bin
curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/releases/${{ env.release_id }}"
curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/git/refs/tags/$TAG"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Release
uses: actions/create-release@v1
id: create_release
with:
tag_name: latest-${{ steps.get_branch.outputs.branch_name }}-bin
release_name: Latest ${{ steps.get_branch.outputs.branch_name }} binaries
body: ${{ steps.set_description.outputs.mod_description }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifact.7z
asset_name: latest-${{ steps.get_branch.outputs.branch_name }}-bin.7z
asset_content_type: application/x-7z-compressed
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 9 additions & 0 deletions src/DellarteDellaGuerra.sln
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DellarteDellaGuerra.Infrast
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DellarteDellaGuerra.Infrastructure.Tests", "DellarteDellaGuerra.Infrastructure.Tests\DellarteDellaGuerra.Infrastructure.Tests.csproj", "{3FA3639C-31CF-45D6-8AE0-12C99A663281}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{DC0E0D39-ABB7-4F0C-BC60-0C7F22013D30}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{4EB07234-ED44-4ED0-99C5-3354815693F4}"
ProjectSection(SolutionItems) = preProject
..\.github\workflows\build-binaries.yml = ..\.github\workflows\build-binaries.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand Down Expand Up @@ -90,6 +97,8 @@ Global
{F3FF0EA7-9E28-4D27-9FA8-70754A123DF7} = {12CCA2B5-A874-47B3-BB43-799275014D7B}
{F1AF53B1-6B28-4A2D-A967-B7BE6EC15C84} = {12CCA2B5-A874-47B3-BB43-799275014D7B}
{10714220-ACE7-40E5-9DC2-ACE17923B206} = {12CCA2B5-A874-47B3-BB43-799275014D7B}
{DC0E0D39-ABB7-4F0C-BC60-0C7F22013D30} = {12CCA2B5-A874-47B3-BB43-799275014D7B}
{4EB07234-ED44-4ED0-99C5-3354815693F4} = {DC0E0D39-ABB7-4F0C-BC60-0C7F22013D30}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B3D4AB65-9162-4EE2-9413-1867C12DC041}
Expand Down
2 changes: 1 addition & 1 deletion src/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---------------------------------------------------------------------------------------------------
Version: 1.2.0
Game Versions: v1.2.8
Game Versions: v1.2.9
* Add a system allowing equipment troops to be better randomised.
---------------------------------------------------------------------------------------------------
Version: 1.1.0
Expand Down

0 comments on commit 7cd6d5f

Please sign in to comment.