Skip to content

Release Warcraft plugin #62

Release Warcraft plugin

Release Warcraft plugin #62

Workflow file for this run

name: Release Warcraft plugin
on:
workflow_dispatch:
jobs:
deploy:
environment:
name: production
name: Build and Release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Read Current Version
id: read_version
run: |
current_version=$(cat version.txt)
echo "current_version=$current_version" >> $GITHUB_ENV
- name: Calculate New Version
id: calculate_version
run: |
current_version=${{ env.current_version }}
# Parse current version into major, minor, and patch
major=$(echo $current_version | cut -d. -f1)
minor=$(echo $current_version | cut -d. -f2)
patch=$(echo $current_version | cut -d. -f3)
# Increment minor by 1
minor=$((minor + 1))
# Check if minor exceeds 9
if [ "$minor" -gt 9 ]; then
minor=0
patch=$((patch + 1))
fi
# Check if patch exceeds 9
if [ "$patch" -gt 9 ]; then
patch=0
minor=0
major=$((major + 1))
fi
# Create new version string
new_version="$major.$minor.$patch"
echo "new_version=$new_version" >> $GITHUB_ENV
- name: Update Version File
run: echo "${{ env.new_version }}" > version.txt
- name: Commit Updated Version
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add version.txt
git commit -m "Release version ${{ env.new_version }}"
git push
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x.x' # Use the version of .NET you need
- name: Update C# Version
run: |
sed -i "s/public override string ModuleVersion => \".*\";/public override string ModuleVersion => \"${{ env.new_version }}\";/g" WarcraftPlugin/WarcraftPlugin.cs
- name: Publish build artifacts
run: dotnet publish WarcraftPlugin/WarcraftPlugin.csproj --configuration Release --output ./publish/WarcraftPlugin
- name: Create CustomHeroes folder
run: mkdir -p ./publish/WarcraftPlugin/CustomHeroes
- name: Create zip of publish directory contents
run: |
cd publish
zip -r ../warcraft-plugin.zip * # Zip the contents of the publish folder
- name: Create Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ env.new_version }}
release_name: Release ${{ env.new_version }}
# body: ${{ github.event.inputs.body }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./warcraft-plugin.zip
asset_name: warcraft-plugin-${{ env.new_version }}.zip
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Pack NuGet package
run: dotnet pack WarcraftPlugin/WarcraftPlugin.csproj --configuration Release --no-build --output nupkgs /p:Version=${{ env.new_version }}
- name: Publish to NuGet
run: dotnet nuget push nupkgs/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
# - name: Github Releases To Discord
# uses: SethCohen/github-releases-to-discord@v1
# with:
# webhook_url: ${{ secrets.WEBHOOK_URL }}
# color: "2105893"
# username: "Release Changelog"
# avatar_url: "https://github.com/Wngui/CS2WarcraftMod/blob/master/WarcraftPlugin/Resources/nuget/wc-icon.png?raw=true"
# content: ""
# footer_title: "Changelog"
# footer_icon_url: "https://github.com/Wngui/CS2WarcraftMod/blob/master/WarcraftPlugin/Resources/nuget/wc-icon.png?raw=true"
# footer_timestamp: true
# max_description: '4096'
# reduce_headings: true