Skip to content

ci: 💚 Fix CI

ci: 💚 Fix CI #15

Workflow file for this run

name: .NET Build
on:
push:
branches: ["master", "feature/ci"]
create:
tags:
- 'v*'
env:
AppId: 2519830
ProjectName: ResoniteMetricsCounter
ArtifactDLL: ResoniteMetricsCounter.dll
Configuration: Release
jobs:
vtag:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Find csproj file
id: find_csproj
run: |
FILE=$(find . -name "*.csproj" | head -n 1)
echo "::set-output name=FILE::$FILE"
- name: Get version from csproj
id: get_version
run: |
VERSION=$(grep -oPm1 "(?<=<Version>)[^<]+" ${{ steps.find_csproj.outputs.FILE }})
echo "::set-output name=VERSION::$VERSION"
- name: Pull tags
run: git fetch --tags
- name: Check if tag exists
id: check_tag
run: |
TAG_EXISTS=$(git tag -l "v${{ steps.get_version.outputs.VERSION }}")
echo "::set-output name=TAG_EXISTS::$TAG_EXISTS"
- name: Create tag
if: steps.check_tag.outputs.TAG_EXISTS == ''
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag "v${{ steps.get_version.outputs.VERSION }}"
git push origin "v${{ steps.get_version.outputs.VERSION }}"
outputs:
tagged: ${{ steps.check_tag.outputs.TAG_EXISTS == '' }}
tag: v${{ steps.get_version.outputs.VERSION }}
build:
runs-on: windows-latest
steps:
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v2
- name: Setup SteamCMD
uses: CyberAndrii/[email protected]
- id: checkout
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache app
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/${{ env.ProjectName }}/Resonite/
key: app-runtime-2
- name: Update app
run: steamcmd +force_install_dir ${{ github.workspace }}/${{ env.ProjectName }}/Resonite +login ${{ secrets.STEAMLOGIN }} +app_update ${{ env.AppId }} validate +quit
- name: Install ResoniteModLoader
uses: suisei-cn/actions-download-file@v1
with:
url: https://github.com/resonite-modding-group/ResoniteModLoader/releases/latest/download/ResoniteModLoader.dll
target: ${{ github.workspace }}/${{ env.ProjectName }}/Resonite/Libraries/
- name: Install Harmony
uses: suisei-cn/actions-download-file@v1
with:
url: https://github.com/resonite-modding-group/ResoniteModLoader/releases/latest/download/0Harmony.dll
target: ${{ github.workspace }}/${{ env.ProjectName }}/Resonite/rml_libs/
- name: Restore the application
run: msbuild /t:Restore /p:Configuration=${{ env.Configuration }}
- name: Create the app package
run: msbuild /p:Configuration=${{ env.Configuration }}
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.ArtifactDLL }}
path: ${{ env.ProjectName }}/bin/Release/net472/${{ env.ArtifactDLL }}
release:
if: startsWith(github.ref, 'refs/tags/v') || needs.vtag.outputs.tagged
needs:
- vtag
- build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.vtag.outputs.tagged && needs.vtag.outputs.tag || github.ref }}
fetch-depth: 0
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: ${{ env.ArtifactDLL }}
- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
${{ env.ArtifactDLL }}
generate_release_notes: true
tag_name: ${{ needs.vtag.outputs.tagged && needs.vtag.outputs.tag || github.ref }}