Skip to content

Merge pull request #15 from HvH-gg/feat-cs2-customvotes #3

Merge pull request #15 from HvH-gg/feat-cs2-customvotes

Merge pull request #15 from HvH-gg/feat-cs2-customvotes #3

Workflow file for this run

name: Build & Publish
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Prepare env
shell: bash
run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v3
- name: Extract version number from README.md
id: extract_version
run: |
VERSION=$(grep -oP '(?<=# \[HvH\.gg\]\(https:\/\/hvh\.gg\) CS2 Essentials \()[0-9]+\.[0-9]+\.[0-9]+' README.MD)
if [ -z "$VERSION" ]; then
echo "No version number found in README.md. Exiting."
exit 1
fi
echo "VERSION_NUMBER=$VERSION" >> $GITHUB_ENV
- name: Check if version already exists
id: check_version
run: |
if gh release view "${{ env.VERSION_NUMBER }}" > /dev/null 2>&1; then
echo "Version ${{ env.VERSION_NUMBER }} already exists. Exiting."
exit 0
fi
- name: Build runtime ${{ env.VERSION_NUMBER }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Publish artifacts
run: dotnet build -c Release --no-restore /p:Version=${{ env.VERSION_NUMBER }}
- name: Check contents of bin/Release directory
run: |
echo "Listing contents of CS2-Essentials/bin/Release/net8.0/"
ls -la CS2-Essentials/bin/Release/net8.0/
- name: Create necessary directory structure and copy files
run: |
mkdir -p release/addons/counterstrikesharp/configs/plugins/CS2-Essentials
mkdir -p release/addons/counterstrikesharp/plugins/CS2-Essentials
mkdir -p release/addons/counterstrikesharp/gamedata/CS2-Essentials
cp CS2-Essentials.json.gamedata release/addons/counterstrikesharp/gamedata/CS2-Essentials.json
cp CS2-Essentials.json.config.example release/addons/counterstrikesharp/configs/plugins/CS2-Essentials/CS2-Essentials.json
cp -r CS2-Essentials/bin/Release/net8.0/* release/addons/counterstrikesharp/plugins/CS2-Essentials/
- name: Create a ZIP file with binaries
run: |
cd release
zip -r ../CS2-Essentials-${{ env.VERSION_NUMBER }}-${{ env.GITHUB_SHA_SHORT }}.zip addons
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.VERSION_NUMBER }}
release_name: ${{ env.VERSION_NUMBER }}
draft: false
prerelease: false
body: |
## Changes
- Auto-generated release
${{ github.event.head_commit.message }}
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./CS2-Essentials-${{ env.VERSION_NUMBER }}-${{ env.GITHUB_SHA_SHORT }}.zip
asset_name: CS2-Essentials-${{ env.VERSION_NUMBER }}-${{ env.GITHUB_SHA_SHORT }}.zip
asset_content_type: application/zip