OpenMod.Templates #265
Workflow file for this run
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: OpenMod.Templates | |
on: | |
create: | |
tags: | |
- "*" | |
push: | |
branches: [ main ] | |
paths: | |
- 'templates/**' | |
pull_request: | |
branches: [ main ] | |
paths: | |
- 'templates/**' | |
jobs: | |
build: | |
name: "OpenMod.Templates Build" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-dotnet@v3 | |
name: Setup .NET | |
with: | |
dotnet-version: 7.x | |
# Generate semver compatible version from current tag and commit hash | |
- name: Create version | |
id: get-version | |
run: echo "version=$(git describe --tags `git rev-list --tags --max-count=1`)+$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Check Prerelease | |
id: check-prerelease | |
run: "if ${{ contains(steps.get-version.outputs.version, '-') }}; then | |
echo is_prerelease=true >> $GITHUB_OUTPUT; | |
else | |
echo is_prerelease=false >> $GITHUB_OUTPUT; | |
fi" | |
shell: bash | |
# Update project versions | |
- name: Update OpenMod Templates version | |
run: "sed -i \"s#0.0.0#${{ steps.get-version.outputs.version }}#\" templates/OpenMod.Templates.csproj" | |
- name: Update OpenMod Templates Universal version | |
run: "sed -i \"s#0.0.0#${{ steps.get-version.outputs.version }}#\" templates/templates/universal/PluginTemplate.csproj" | |
- name: Update OpenMod Templates Unturned version | |
run: "sed -i \"s#0.0.0#${{ steps.get-version.outputs.version }}#\" templates/templates/unturned/PluginTemplate.csproj" | |
- name: Build | |
run: dotnet build ./templates --configuration Release | |
# Push to GitHub packages on each commit and release | |
- name: Push to NuGet (Nightly) | |
if: github.event_name == 'push' || (github.event_name == 'create' && github.event.ref_type == 'tag') | |
run: dotnet nuget push templates/bin/Release/*.nupkg | |
--skip-duplicate | |
--api-key ${{ secrets.GITHUB_TOKEN }} | |
--source https://nuget.pkg.github.com/openmod/index.json | |
# Push to NuGet on each tag, but only if the tag is not a pre-release version | |
- name: Push to NuGet (Release) | |
if: github.event_name == 'create' && github.event.ref_type == 'tag' && steps.check-prerelease.outputs.is_prerelease == 'false' | |
run: dotnet nuget push templates/bin/Release/*.nupkg | |
--skip-duplicate | |
--api-key ${{ secrets.NUGET_DEPLOY_KEY }} | |
--source https://api.nuget.org/v3/index.json |