Files
SharpTimer/.github/workflows/nightly.yml
blankdvth 9ce9fc64f6 fix: CI failing due to conflicting tags
The CI automatically creates a tag based on the GitHub run number, however, the CI is presently repeatedly failing due to tags with those run numbers already existing (likely from the fork); this fixes that by bumping the prefix to v1.1 rather than v1.0
2025-03-31 02:22:54 -04:00

100 lines
2.7 KiB
YAML

name: Build and Publish C# Project
on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up .NET 8.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: Cache .NET dependencies
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-dotnet-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-dotnet-
- name: Restore dependencies
run: dotnet restore SharpTimer.csproj
- name: Build the project
run: dotnet build --configuration Release SharpTimer.csproj
- name: Publish the project
run: dotnet publish --configuration Release --output ./publish SharpTimer.csproj
- name: Move files
run: |
mkdir -p publish/addons/counterstrikesharp/plugins/SharpTimer/
find ./publish -mindepth 1 -maxdepth 1 ! -name 'cfg' ! -name 'gamedata' -exec mv {} publish/addons/counterstrikesharp/plugins/SharpTimer/ \;
mv gamedata/ ./publish/addons/counterstrikesharp/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: SharpTimer
path: publish/*
if-no-files-found: error
- name: Set version tag and zip file name
id: version
run: |
VERSION="v1.1.${{ github.run_number }}"
if [[ $GITHUB_REF == 'refs/heads/dev' ]]; then
TAG="Prerelease $VERSION"
else
TAG="$VERSION"
fi
ZIP_NAME="SharpTimer_${VERSION}.zip"
echo "TAG=$TAG" >> $GITHUB_ENV
echo "ZIP_NAME=$ZIP_NAME" >> $GITHUB_ENV
- name: Zip published files
run: |
cd publish
zip -r ${{ env.ZIP_NAME }} .
- name: Create GitHub Release
uses: ncipollo/release-action@v1.16.0
with:
name: ${{ env.TAG }}
artifacts: publish/${{ env.ZIP_NAME }}
prerelease: ${{ contains(github.ref, 'dev') }}
tag: v1.1.${{ github.run_number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
post_webhook:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/dev'
steps:
- name: POST Webhook
run: |
curl -X POST \
--fail \
-F token=${{ secrets.GITLAB_SECRET_TOKEN }} \
-F ref=dev \
https://gitlab.edgegamers.io/api/v4/projects/2683/trigger/pipeline