Skip to content

Build

Build #28

Workflow file for this run

name: .NET Build
on:
push:
branches: ["master", "feature/ci"]
create:
tags:
- 'v*'
env:
project: ResoniteMetricsCounter
artifact: ResoniteMetricsCounter.dll
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:
- id: checkout
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build
uses: esnya/build-rml-mod@v1
with:
project: ${{ env.project }}
steam-login: ${{ secrets.STEAMLOGIN }}
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.artifact }}
path: bin/Release/${{ env.artifact }}
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.artifact }}
- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
${{ env.artifact }}
generate_release_notes: true
tag_name: ${{ needs.vtag.outputs.tagged && needs.vtag.outputs.tag || github.ref }}