Skip to content

Commit

Permalink
Better release permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
Bwc9876 committed Jul 23, 2023
1 parent 74e74a4 commit 3f3bbab
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 93 deletions.
40 changes: 20 additions & 20 deletions OuterWildsModTemplate.csproj
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<PackageType>Template</PackageType>
<PackageVersion>1.19</PackageVersion>
<PackageId>Bwc9876.OuterWildsModTemplate</PackageId>
<Title>Outer Wilds Mod Template</Title>
<Authors>Bwc9876</Authors>
<Description>Template used to create a mod for the game Outer Wilds</Description>
<PackageTags>dotnet-new;templates;contoso</PackageTags>
<TargetFramework>net48</TargetFramework>
<NoDefaultExcludes>true</NoDefaultExcludes>
<IncludeContentInPack>true</IncludeContentInPack>
<IncludeBuildOutput>false</IncludeBuildOutput>
<ContentTargetFolders>content</ContentTargetFolders>
<NoWarn>NU5128</NoWarn>
</PropertyGroup>
<PropertyGroup>
<PackageType>Template</PackageType>
<PackageVersion>1.20</PackageVersion>
<PackageId>Bwc9876.OuterWildsModTemplate</PackageId>
<Title>Outer Wilds Mod Template</Title>
<Authors>Bwc9876</Authors>
<Description>Template used to create a mod for the game Outer Wilds</Description>
<PackageTags>dotnet-new;templates;contoso</PackageTags>
<TargetFramework>net48</TargetFramework>
<NoDefaultExcludes>true</NoDefaultExcludes>
<IncludeContentInPack>true</IncludeContentInPack>
<IncludeBuildOutput>false</IncludeBuildOutput>
<ContentTargetFolders>content</ContentTargetFolders>
<NoWarn>NU5128</NoWarn>
</PropertyGroup>

<ItemGroup>
<Content Include="templates\**\*" Exclude="templates\**\bin\**;templates\**\obj\**" />
<Compile Remove="**\*" />
</ItemGroup>
<ItemGroup>
<Content Include="templates\**\*" Exclude="templates\**\bin\**;templates\**\obj\**" />
<Compile Remove="**\*" />
</ItemGroup>

</Project>
</Project>
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,3 @@ If you have an existing project and want to add the workflow to it, follow this
2. Change `PROJ_USERNAME` near the top to the safe author name (the string in the `uniqueName` before the `.`).
3. Change the `PROJ_NAME` near the top to the safe project name (the string in the `uniqueName` after the `.`). **Important: The project name must also be the project folder's name. Meaning the folder your .csproj file is in must be both at the root of the repo and have the same name as your project. (Most IDEs set it up this way by default)**
4. That's it! Simply push the new workflow and run it.


Original file line number Diff line number Diff line change
@@ -1,87 +1,90 @@
name: Create Release

on:
workflow_dispatch:
inputs:
prerelease:
description: Prerelease
type: boolean
bypassCheck:
description: Bypass Version Check
type: boolean
workflow_dispatch:
inputs:
prerelease:
description: Prerelease
type: boolean
bypassCheck:
description: Bypass Version Check
type: boolean

permissions:
contents: write

env:
PROJ_USERNAME: $username$
PROJ_NAME: $safeprojectname$
PROJ_USERNAME: $username$
PROJ_NAME: $safeprojectname$

jobs:
pre_job:
name: Check For Other Releases
outputs:
version: ${{ steps.out.outputs.version }}
exists: ${{ steps.out.outputs.exists }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: "actions/checkout@v3"

- name: Fetch
run: git fetch
pre_job:
name: Check For Other Releases
outputs:
version: ${{ steps.out.outputs.version }}
exists: ${{ steps.out.outputs.exists }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: "actions/checkout@v3"

- name: Fetch
run: git fetch

- name: Read Manifest
id: read-manifest
run: echo "manifest=$(< ./${{ env.PROJ_NAME }}/manifest.json sed ':a;N;$!ba;s/\n/ /g')" >> $GITHUB_OUTPUT

- name: Read Manifest
id: read-manifest
run: echo "manifest=$(< ./${{ env.PROJ_NAME }}/manifest.json sed ':a;N;$!ba;s/\n/ /g')" >> $GITHUB_OUTPUT
- name: Check For Release
id: check-tag
run: echo "exists=$(git ls-remote --exit-code --tags origin ${{ env.TAG }} >/dev/null 2>&1 && echo true || echo false)" >> $GITHUB_OUTPUT
env:
TAG: "v${{fromJson(steps.read-manifest.outputs.manifest).version}}"

- name: Check For Release
id: check-tag
run: echo "exists=$(git ls-remote --exit-code --tags origin ${{ env.TAG }} >/dev/null 2>&1 && echo true || echo false)" >> $GITHUB_OUTPUT
env:
TAG: "v${{fromJson(steps.read-manifest.outputs.manifest).version}}"

- name: Output Version Info
id: out
run: |
echo "version=${{fromJson(steps.read-manifest.outputs.manifest).version}}" >> $GITHUB_OUTPUT
echo "exists=${{steps.check-tag.outputs.exists}}" >> $GITHUB_OUTPUT
- name: Output Version Info
id: out
run: |
echo "version=${{fromJson(steps.read-manifest.outputs.manifest).version}}" >> $GITHUB_OUTPUT
echo "exists=${{steps.check-tag.outputs.exists}}" >> $GITHUB_OUTPUT
- name: Error
if: ${{ steps.out.outputs.exists != 'false' && (!inputs.bypassCheck) }}
run: echo "::error file=manifest.json,title=Refusing to Release::Your mod was not released because there is already a release with the version in manifest.json"
release:
needs: pre_job
if: ${{ (needs.pre_job.outputs.version != '0.0.0') && (needs.pre_job.outputs.exists == 'false') || (inputs.bypassCheck) }}
name: Create Release
runs-on: windows-latest
steps:
- name: Checkout
uses: "actions/checkout@v3"
- name: Error
if: ${{ steps.out.outputs.exists != 'false' && (!inputs.bypassCheck) }}
run: echo "::error file=manifest.json,title=Refusing to Release::Your mod was not released because there is already a release with the version in manifest.json"
release:
needs: pre_job
if: ${{ (needs.pre_job.outputs.version != '0.0.0') && (needs.pre_job.outputs.exists == 'false') || (inputs.bypassCheck) }}
name: Create Release
runs-on: windows-latest
steps:
- name: Checkout
uses: "actions/checkout@v3"

- name: Setup .NET
uses: "actions/setup-dotnet@v3"
- name: Setup .NET
uses: "actions/setup-dotnet@v3"

- name: Remove .csproj.user
run: if (Test-Path ${{ env.PROJ_NAME }}/${{ env.PROJ_NAME }}.csproj.user) { rm ${{ env.PROJ_NAME }}/${{ env.PROJ_NAME }}.csproj.user }
- name: Remove .csproj.user
run: if (Test-Path ${{ env.PROJ_NAME }}/${{ env.PROJ_NAME }}.csproj.user) { rm ${{ env.PROJ_NAME }}/${{ env.PROJ_NAME }}.csproj.user }

- name: Build Mod
run: dotnet build -c Release
- name: Build Mod
run: dotnet build -c Release

- name: Upload Artifact
uses: "actions/upload-artifact@v3"
with:
name: "${{ env.PROJ_USERNAME }}.${{ env.PROJ_NAME }}"
path: "${{ env.PROJ_NAME }}/bin/Release"
- name: Upload Artifact
uses: "actions/upload-artifact@v3"
with:
name: "${{ env.PROJ_USERNAME }}.${{ env.PROJ_NAME }}"
path: "${{ env.PROJ_NAME }}/bin/Release"

- name: Zip For Release
run: 7z a ${{ env.PROJ_USERNAME }}.${{ env.PROJ_NAME }}.zip ./${{ env.PROJ_NAME }}/bin/Release/**
- name: Zip For Release
run: 7z a ${{ env.PROJ_USERNAME }}.${{ env.PROJ_NAME }}.zip ./${{ env.PROJ_NAME }}/bin/Release/**

- name: Create Release
uses: "ncipollo/release-action@v1"
with:
allowUpdates: true
commit: ${{ github.ref_name }}
tag: v${{ needs.pre_job.outputs.version }}
name: Version ${{ needs.pre_job.outputs.version }}
omitBodyDuringUpdate: true
artifacts: "${{ env.PROJ_USERNAME}}.${{ env.PROJ_NAME }}.zip"
draft: true
prerelease: ${{ inputs.prerelease }}
- name: Create Release
uses: "ncipollo/release-action@v1"
with:
allowUpdates: true
commit: ${{ github.ref_name }}
tag: v${{ needs.pre_job.outputs.version }}
name: Version ${{ needs.pre_job.outputs.version }}
omitBodyDuringUpdate: true
artifacts: "${{ env.PROJ_USERNAME}}.${{ env.PROJ_NAME }}.zip"
draft: true
prerelease: ${{ inputs.prerelease }}

0 comments on commit 3f3bbab

Please sign in to comment.