Skip to content

⬆️ Bump files with dotnet-file sync #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# normalize by default
* text=auto encoding=UTF-8
*.sh text eol=lf
*.sbn eol=lf

# These are windows specific files which we may as well ensure are
# always crlf on checkout
Expand Down
35 changes: 35 additions & 0 deletions .github/actions/dotnet/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: ⚙ dotnet
description: Configures dotnet if the repo/org defines the DOTNET custom property

runs:
using: composite
steps:
- name: 🔎 dotnet
id: dotnet
shell: bash
run: |
VERSIONS=$(gh api repos/${{ github.repository }}/properties/values | jq -r '.[] | select(.property_name == "DOTNET") | .value')
# Remove extra whitespace from VERSIONS
VERSIONS=$(echo "$VERSIONS" | tr -s ' ' | tr -d ' ')
# Convert comma-separated to newline-separated
NEWLINE_VERSIONS=$(echo "$VERSIONS" | tr ',' '\n')
# Validate versions
while IFS= read -r version; do
if ! [[ $version =~ ^[0-9]+(\.[0-9]+(\.[0-9]+)?)?(\.x)?$ ]]; then
echo "Error: Invalid version format: $version"
exit 1
fi
done <<< "$NEWLINE_VERSIONS"
# Write multiline output to $GITHUB_OUTPUT
{
echo 'versions<<EOF'
echo "$NEWLINE_VERSIONS"
echo 'EOF'
} >> $GITHUB_OUTPUT

- name: ⚙ dotnet
if: steps.dotnet.outputs.versions != ''
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
${{ steps.dotnet.outputs.versions }}
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ updates:
Extensions:
patterns:
- "Microsoft.Extensions*"
exclude-patterns:
- "Microsoft.Extensions.AI*"
ExtensionsAI:
patterns:
- "Microsoft.Extensions.AI*"
Web:
patterns:
- "Microsoft.AspNetCore*"
Expand All @@ -38,3 +43,6 @@ updates:
ProtoBuf:
patterns:
- "protobuf-*"
Spectre:
patterns:
- "Spectre.Console*"
9 changes: 8 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
MSBUILDTERMINALLOGGER: auto
Configuration: ${{ github.event.inputs.configuration || 'Release' }}
SLEET_FEED_URL: ${{ vars.SLEET_FEED_URL }}

defaults:
run:
Expand Down Expand Up @@ -64,6 +65,9 @@ jobs:
submodules: recursive
fetch-depth: 0

- name: ⚙ dotnet
uses: devlooped/actions-dotnet-env@v1

- name: 🙏 build
run: dotnet build -m:1 -bl:build.binlog

Expand All @@ -73,7 +77,7 @@ jobs:
dotnet retest -- --no-build

- name: 🐛 logs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: runner.debug && always()
with:
name: logs
Expand All @@ -96,6 +100,9 @@ jobs:
submodules: recursive
fetch-depth: 0

- name: ⚙ dotnet
uses: devlooped/actions-dotnet-env@v1

- name: ✓ ensure format
run: |
dotnet format whitespace --verify-no-changes -v:diag --exclude ~/.nuget
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/dotnet-env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: dotnet-env
on:
workflow_dispatch:
push:
branches:
- main
paths:
- '**/*.*proj'

jobs:
which-dotnet:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: 🤖 defaults
uses: devlooped/actions-bot@v1
with:
name: ${{ secrets.BOT_NAME }}
email: ${{ secrets.BOT_EMAIL }}
gh_token: ${{ secrets.GH_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: 🤘 checkout
uses: actions/checkout@v4
with:
token: ${{ env.GH_TOKEN }}

- name: 🤌 dotnet
uses: devlooped/actions-which-dotnet@v1

- name: ✍ pull request
uses: peter-evans/create-pull-request@v7
with:
base: main
branch: which-dotnet
delete-branch: true
labels: dependencies
title: "⚙ Update dotnet versions"
body: "Update dotnet versions"
commit-message: "Update dotnet versions"
token: ${{ env.GH_TOKEN }}
95 changes: 95 additions & 0 deletions .github/workflows/dotnet-file-core.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Synchronizes .netconfig-configured files with dotnet-file
name: dotnet-file-core
on:
workflow_call:
secrets:
BOT_NAME:
required: false
BOT_EMAIL:
required: false
GH_TOKEN:
required: false

env:
DOTNET_NOLOGO: true

defaults:
run:
shell: pwsh

jobs:
sync:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: 🤖 defaults
uses: devlooped/actions-bot@v1
with:
name: ${{ secrets.BOT_NAME }}
email: ${{ secrets.BOT_EMAIL }}
gh_token: ${{ secrets.GH_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: 🤘 checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
token: ${{ env.GH_TOKEN }}

- name: ⌛ rate
if: github.event_name != 'workflow_dispatch'
run: |
# add random sleep since we run on fixed schedule
sleep (get-random -max 60)
# get currently authenticated user rate limit info
$rate = gh api rate_limit | convertfrom-json | select -expandproperty rate
# if we don't have at least 100 requests left, wait until reset
if ($rate.remaining -lt 10) {
$wait = ($rate.reset - (Get-Date (Get-Date).ToUniversalTime() -UFormat %s))
echo "Rate limit remaining is $($rate.remaining), waiting for $($wait / 1000) seconds to reset"
sleep $wait
$rate = gh api rate_limit | convertfrom-json | select -expandproperty rate
echo "Rate limit has reset to $($rate.remaining) requests"
}

- name: 🔄 sync
run: |
dotnet tool update -g dotnet-gcm
# store credentials in plaintext for linux compat
git config --local credential.credentialStore plaintext
dotnet gcm store --protocol=https --host=github.com --username=$env:GITHUB_ACTOR --password=$env:GH_TOKEN
gh auth status

dotnet tool update -g dotnet-file
$changelog = "$([System.IO.Path]::GetTempPath())dotnet-file.md"
dotnet file sync -c:$changelog
if (test-path $changelog) {
echo 'CHANGES<<EOF' >> $env:GITHUB_ENV
cat $changelog >> $env:GITHUB_ENV
echo 'EOF' >> $env:GITHUB_ENV
cat $changelog
} else {
echo 'No changelog was generated'
}

- name: +Mᐁ includes
uses: devlooped/actions-includes@v1
with:
validate: false

- name: ✍ pull request
uses: peter-evans/create-pull-request@v7
with:
base: main
branch: dotnet-file-sync
delete-branch: true
labels: dependencies
author: ${{ env.BOT_AUTHOR }}
committer: ${{ env.BOT_AUTHOR }}
commit-message: ⬆️ Bump files with dotnet-file sync

${{ env.CHANGES }}
title: "⬆️ Bump files with dotnet-file sync"
body: ${{ env.CHANGES }}
token: ${{ env.GH_TOKEN }}
7 changes: 6 additions & 1 deletion .github/workflows/dotnet-file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@ env:

jobs:
run:
permissions:
contents: write
uses: devlooped/oss/.github/workflows/dotnet-file-core.yml@main
secrets: inherit
secrets:
BOT_NAME: ${{ secrets.BOT_NAME }}
BOT_EMAIL: ${{ secrets.BOT_EMAIL }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
3 changes: 3 additions & 0 deletions .github/workflows/includes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
jobs:
includes:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: 🤖 defaults
uses: devlooped/actions-bot@v1
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ env:
VersionLabel: ${{ github.ref }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
MSBUILDTERMINALLOGGER: auto

SLEET_FEED_URL: https://api.nuget.org/v3/index.json

jobs:
publish:
runs-on: ${{ vars.PUBLISH_AGENT || 'ubuntu-latest' }}
Expand All @@ -26,6 +27,9 @@ jobs:
submodules: recursive
fetch-depth: 0

- name: ⚙ dotnet
uses: devlooped/actions-dotnet-env@v1

- name: 🙏 build
run: dotnet build -m:1 -bl:build.binlog

Expand All @@ -35,7 +39,7 @@ jobs:
dotnet retest -- --no-build

- name: 🐛 logs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: runner.debug && always()
with:
name: logs
Expand Down
Loading
Loading