Build & Publish #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/**' | |
workflow_dispatch: | |
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\) rapid fire 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: Check contents of bin/Release directory | |
run: | | |
echo "Listing contents of RapidFireFix/bin/Release/net8.0/" | |
ls -la RapidFireFix/bin/Release/net8.0/ | |
- name: Create necessary directory structure and copy files | |
run: | | |
mkdir -p release/addons/counterstrikesharp/plugins/RapidFireFix | |
cp -r RapidFireFix/bin/Release/net8.0/* release/addons/counterstrikesharp/plugins/RapidFireFix/ | |
- name: Create a ZIP file with binaries | |
run: | | |
cd release | |
zip -r ../RapidFireFix-${{ 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: ./RapidFireFix-${{ env.VERSION_NUMBER }}-${{ env.GITHUB_SHA_SHORT }}.zip | |
asset_name: RapidFireFix-${{ env.VERSION_NUMBER }}-${{ env.GITHUB_SHA_SHORT }}.zip | |
asset_content_type: application/zip |