Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 43 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,88 @@

jobs:
build:
name: Build Job
name: Build and Test
runs-on: macos-15
outputs:
version: ${{ steps.gitversion.outputs.semVer }}
defaults:
run:
working-directory: Source

steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0 # Required for Calculate Version step (e.g. GitVersion)

# Required by GitVersion

- name: Install .NET 8.0
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0

- name: Install Workloads
run: dotnet workload restore

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@51d325634925d7d9ce0a7efc2c586c0bc2b9eee6 #v3.2.1
with:
versionSpec: '6.3.0'

- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@51d325634925d7d9ce0a7efc2c586c0bc2b9eee6 #v3.2.1
with:
useConfigFile: true
updateProjectFiles: true

- name: NuGet
- name: NuGet Restore
run: dotnet restore

# Smoke test to make sure the Example Client builds. We don't do a release build
# of the Example Client because it takes a long time and we don't publish it.
- name: Debug Build of Solution to Smoke test Example Client
- name: Debug Build of Solution to Smoke Test Example Client
run: dotnet build -c Debug

- name: Create NuGet Package
run: dotnet pack SaturdayMP.XPlugins.iOS.BEMCheckBox/SaturdayMP.XPlugins.iOS.BEMCheckBox.csproj -c Release

- name: Upload NuGet Package Artifact
uses: actions/upload-artifact@v4
with:
name: nuget-package
path: Source/SaturdayMP.XPlugins.iOS.BEMCheckBox/bin/Release/SaturdayMP.XPlugins.iOS.BEMCheckBox.${{ steps.gitversion.outputs.semVer }}.nupkg
retention-days: 90

- name: Publish to MyGet
run: dotnet nuget push SaturdayMP.XPlugins.iOS.BEMCheckBox/bin/Release/SaturdayMP.XPlugins.iOS.BEMCheckBox.${{ steps.gitversion.outputs.semVer }}.nupkg -k ${{ secrets.MYGET_API_KEY }} -s https://www.myget.org/F/saturdaymp/api/v3/index.json

# Only push tagged builds to NuGet. These will be production or release candidates.
- name: Upload to NuGet
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
run: dotnet nuget push SaturdayMP.XPlugins.iOS.BEMCheckBox/bin/Release/SaturdayMP.XPlugins.iOS.BEMCheckBox.${{ steps.gitversion.outputs.semVer }}.nupkg -k ${{ secrets.NUGET_API_KEY }} --skip-duplicate --no-symbols -s https://api.nuget.org/v3/index.json
publish-nuget:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI about 2 months ago

To fix this problem, add a permissions block to the build job in .github/workflows/ci.yml, specifying the minimal privileges it requires. Because the steps in the build job only need to read from the repository (e.g., checkout code, restore packages), the permission can be set to contents: read, which is the safest minimal value. This change should be introduced directly under the job’s name (after name: Build and Test and before other block entries). No other workflow structure or step logic is altered.


Suggested changeset 1
.github/workflows/ci.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -10,6 +10,8 @@
 jobs:
   build:
     name: Build and Test
+    permissions:
+      contents: read
     runs-on: macos-15
     outputs:
       version: ${{ steps.gitversion.outputs.semVer }}
EOF
@@ -10,6 +10,8 @@
jobs:
build:
name: Build and Test
permissions:
contents: read
runs-on: macos-15
outputs:
version: ${{ steps.gitversion.outputs.semVer }}
Copilot is powered by AI and may make mistakes. Always verify output.
name: Publish to NuGet
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
permissions:
id-token: write # Required for Trusted Publishing (OIDC token generation)

steps:
- name: Install .NET 8.0
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0

- name: Download NuGet Package Artifact
uses: actions/download-artifact@v4
with:
name: nuget-package
path: ./packages

# Authenticate to NuGet.org using Trusted Publishing (OIDC)
- name: Login to NuGet
uses: NuGet/login@v1

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'CI' step
Uses Step: nuget-login
uses 'NuGet/login' with ref 'v1', not a pinned commit hash
id: nuget-login
with:
user: ${{ secrets.NUGET_USERNAME }}

# Only push tagged builds to NuGet. These will be production or release candidates.
- name: Publish to NuGet
run: dotnet nuget push ./packages/SaturdayMP.XPlugins.iOS.BEMCheckBox.${{ needs.build.outputs.version }}.nupkg --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY}} --skip-duplicate --no-symbols -s https://api.nuget.org/v3/index.json
Loading
Loading