Merge pull request #7 from HvH-gg/update-signature #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build & Publish | |
on: | |
push: | |
branches: | |
- master | |
paths-ignore: | |
- 'README.MD' | |
- '.github/workflows/**' | |
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\) Teleport/Crasher Fix \()[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: Build | |
run: dotnet build -c Release --no-restore /p:Version=${{ env.VERSION_NUMBER }} | |
- name: Find CSSharpUtils.dll | |
run: | | |
echo "Listing contents of NuGet packages directory" | |
find ~/.nuget/packages/cssharputils/ -name "CSSharpUtils.dll" | |
- name: Copy CSSharpUtils.dll | |
run: | | |
mkdir -p release/addons/counterstrikesharp/plugins/TeleportFix | |
# Assuming `find` step shows the exact path of CSSharpUtils.dll | |
CSSharpUtilsDllPath=$(find ~/.nuget/packages/cssharputils/ -name "CSSharpUtils.dll" | head -n 1) | |
if [ -z "$CSSharpUtilsDllPath" ]; then | |
echo "CSSharpUtils.dll not found. Exiting." | |
exit 1 | |
fi | |
cp "$CSSharpUtilsDllPath" release/addons/counterstrikesharp/plugins/TeleportFix/ | |
- name: Check contents of bin/Release directory | |
run: | | |
echo "Listing contents of TeleportFix/bin/Release/net8.0/" | |
ls -la TeleportFix/bin/Release/net8.0/ | |
- name: Create necessary directory structure and copy files | |
run: | | |
mkdir -p release/addons/counterstrikesharp/configs/plugins/TeleportFix | |
mkdir -p release/addons/counterstrikesharp/plugins/TeleportFix | |
mkdir -p release/addons/counterstrikesharp/gamedata | |
cp TeleportFix/TeleportFix.json.gamedata release/addons/counterstrikesharp/gamedata/TeleportFix.json | |
cp TeleportFix/TeleportFix.json.config.example release/addons/counterstrikesharp/configs/plugins/TeleportFix/TeleportFix.json | |
cp -r TeleportFix/bin/Release/net8.0/* release/addons/counterstrikesharp/plugins/TeleportFix/ | |
- name: Create a ZIP file with binaries | |
run: | | |
cd release | |
zip -r ../TeleportFix-${{ 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: ./TeleportFix-${{ env.VERSION_NUMBER }}-${{ env.GITHUB_SHA_SHORT }}.zip | |
asset_name: TeleportFix-${{ env.VERSION_NUMBER }}-${{ env.GITHUB_SHA_SHORT }}.zip | |
asset_content_type: application/zip |