diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index c6c4f05..44e5154 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -5,6 +5,9 @@ on: ["workflow_dispatch", "push", "pull_request"] jobs: build: runs-on: ubuntu-22.04 + permissions: + contents: write + packages: write steps: - uses: actions/checkout@v4 with: @@ -36,11 +39,37 @@ jobs: - uses: actions/upload-artifact@v4 with: - name: AllOfUs.MiraAPI.nupkg - path: MiraAPI/bin/Release/AllOfUs.MiraAPI.*.nupkg - + name: ClazAU.MiraAPI.nupkg + path: MiraAPI/bin/Release/ClazAU.MiraAPI.*.nupkg + + # A push to main whose VersionPrefix has no v tag yet publishes that version: the package to the + # ClazAU feed that mods compile against, and the DLL to a GitHub release. Asks the remote, since a shallow + # checkout has no tags. + - name: Check for an unreleased version + id: release + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + run: | + version=$(grep -oP '(?<=)[^<]+' Directory.Build.props) + echo "version=$version" >> "$GITHUB_OUTPUT" + if [ -n "$(git ls-remote --tags origin "refs/tags/v$version")" ]; then + echo "publish=false" >> "$GITHUB_OUTPUT" + else + echo "publish=true" >> "$GITHUB_OUTPUT" + fi + + - name: Build the release + if: steps.release.outputs.publish == 'true' + run: dotnet build MiraAPI/MiraAPI.csproj --configuration Release -p:Version=${{ steps.release.outputs.version }} + + - name: Publish to the ClazAU NuGet feed + if: steps.release.outputs.publish == 'true' + run: >- + dotnet nuget push "MiraAPI/bin/Release/ClazAU.MiraAPI.${{ steps.release.outputs.version }}.nupkg" + --source "https://nuget.pkg.github.com/ClazAU/index.json" + --api-key "${{ secrets.GITHUB_TOKEN }}" + - uses: softprops/action-gh-release@v2 - if: github.ref_type == 'tag' + if: steps.release.outputs.publish == 'true' with: - draft: true + tag_name: v${{ steps.release.outputs.version }} files: MiraAPI/bin/Release/net6.0/MiraAPI.dll diff --git a/Directory.Build.props b/Directory.Build.props index 4bdcab7..15ee3fc 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -14,7 +14,7 @@ All Of Us, XtraCube, Angxl All Of Us git - https://github.com/All-Of-Us-Mods/MiraAPI + https://github.com/ClazAU/MiraAPI LGPL-2.1-or-later diff --git a/MiraAPI/MiraAPI.csproj b/MiraAPI/MiraAPI.csproj index b6bcb5d..192c920 100644 --- a/MiraAPI/MiraAPI.csproj +++ b/MiraAPI/MiraAPI.csproj @@ -2,7 +2,7 @@ preview Simple and easy to use Among Us modding API. - AllOfUs.MiraAPI + ClazAU.MiraAPI true true IDE0031;IDE0032 diff --git a/build.cake b/build.cake index b3dc40b..737c042 100644 --- a/build.cake +++ b/build.cake @@ -15,7 +15,7 @@ Task("Build") if (tag != null) { - settings.MSBuildSettings.Version = tag; + settings.MSBuildSettings.Version = tag.TrimStart('v'); } else if (buildId != 0) {